Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
 
12
namespace Carbon\Traits;
13
 
14
use Carbon\Carbon;
15
use Carbon\CarbonImmutable;
16
 
17
/**
18
 * Trait Mutability.
19
 *
20
 * Utils to know if the current object is mutable or immutable and convert it.
21
 */
22
trait Mutability
23
{
24
    use Cast;
25
 
26
    /**
27
     * Returns true if the current class/instance is mutable.
28
     *
29
     * @return bool
30
     */
31
    public static function isMutable()
32
    {
33
        return false;
34
    }
35
 
36
    /**
37
     * Returns true if the current class/instance is immutable.
38
     *
39
     * @return bool
40
     */
41
    public static function isImmutable()
42
    {
43
        return !static::isMutable();
44
    }
45
 
46
    /**
47
     * Return a mutable copy of the instance.
48
     *
49
     * @return Carbon
50
     */
51
    public function toMutable()
52
    {
53
        /** @var Carbon $date */
54
        $date = $this->cast(Carbon::class);
55
 
56
        return $date;
57
    }
58
 
59
    /**
60
     * Return a immutable copy of the instance.
61
     *
62
     * @return CarbonImmutable
63
     */
64
    public function toImmutable()
65
    {
66
        /** @var CarbonImmutable $date */
67
        $date = $this->cast(CarbonImmutable::class);
68
 
69
        return $date;
70
    }
71
}