CarbonPeriodImmutable.php 870 B

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