Boundaries.php
2 months ago
Cast.php
2 months ago
Comparison.php
2 months ago
Converter.php
2 months ago
Creator.php
2 months ago
Date.php
2 months ago
DeprecatedProperties.php
2 months ago
Difference.php
2 months ago
IntervalRounding.php
2 months ago
IntervalStep.php
2 months ago
Localization.php
2 months ago
Macro.php
2 months ago
MagicParameter.php
2 months ago
Mixin.php
2 months ago
Modifiers.php
2 months ago
Mutability.php
2 months ago
ObjectInitialisation.php
2 months ago
Options.php
2 months ago
Rounding.php
2 months ago
Serialization.php
2 months ago
Test.php
2 months ago
Timestamp.php
2 months ago
ToStringFormat.php
2 months ago
Units.php
2 months ago
Week.php
2 months ago
Mutability.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This file is part of the Carbon package. |
| 5 | * |
| 6 | * (c) Brian Nesbitt <brian@nesbot.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace ProfilePressVendor\Carbon\Traits; |
| 12 | |
| 13 | use ProfilePressVendor\Carbon\Carbon; |
| 14 | use ProfilePressVendor\Carbon\CarbonImmutable; |
| 15 | /** |
| 16 | * Trait Mutability. |
| 17 | * |
| 18 | * Utils to know if the current object is mutable or immutable and convert it. |
| 19 | */ |
| 20 | trait Mutability |
| 21 | { |
| 22 | use Cast; |
| 23 | /** |
| 24 | * Returns true if the current class/instance is mutable. |
| 25 | * |
| 26 | * @return bool |
| 27 | */ |
| 28 | public static function isMutable() |
| 29 | { |
| 30 | return \false; |
| 31 | } |
| 32 | /** |
| 33 | * Returns true if the current class/instance is immutable. |
| 34 | * |
| 35 | * @return bool |
| 36 | */ |
| 37 | public static function isImmutable() |
| 38 | { |
| 39 | return !static::isMutable(); |
| 40 | } |
| 41 | /** |
| 42 | * Return a mutable copy of the instance. |
| 43 | * |
| 44 | * @return Carbon |
| 45 | */ |
| 46 | public function toMutable() |
| 47 | { |
| 48 | /** @var Carbon $date */ |
| 49 | $date = $this->cast(Carbon::class); |
| 50 | return $date; |
| 51 | } |
| 52 | /** |
| 53 | * Return a immutable copy of the instance. |
| 54 | * |
| 55 | * @return CarbonImmutable |
| 56 | */ |
| 57 | public function toImmutable() |
| 58 | { |
| 59 | /** @var CarbonImmutable $date */ |
| 60 | $date = $this->cast(CarbonImmutable::class); |
| 61 | return $date; |
| 62 | } |
| 63 | } |
| 64 |