| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** |
| 6 | * This file is part of the Carbon package. |
| 7 | * |
| 8 | * (c) Brian Nesbitt <[email protected]> |
| 9 | * |
| 10 | * For the full copyright and license information, please view the LICENSE |
| 11 | * file that was distributed with this source code. |
| 12 | */ |
| 13 | |
| 14 | namespace Carbon; |
| 15 | |
| 16 | class CarbonPeriodImmutable extends CarbonPeriod |
| 17 | { |
| 18 | /** |
| 19 | * Default date class of iteration items. |
| 20 | * |
| 21 | * @var string |
| 22 | */ |
| 23 | protected const DEFAULT_DATE_CLASS = CarbonImmutable::class; |
| 24 | |
| 25 | /** |
| 26 | * Date class of iteration items. |
| 27 | */ |
| 28 | protected string $dateClass = CarbonImmutable::class; |
| 29 | |
| 30 | /** |
| 31 | * Prepare the instance to be set (self if mutable to be mutated, |
| 32 | * copy if immutable to generate a new instance). |
| 33 | */ |
| 34 | protected function copyIfImmutable(): static |
| 35 | { |
| 36 | return $this->constructed ? clone $this : $this; |
| 37 | } |
| 38 | } |