1 | <?php |
||
8 | final class Date implements ValueObjectInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | public const NATIVE_FORMAT = "Y-m-d"; |
||
14 | |||
15 | /** |
||
16 | * @var null |
||
17 | */ |
||
18 | private const NIL = null; |
||
19 | |||
20 | /** |
||
21 | * @var DateTimeImmutable|null |
||
22 | */ |
||
23 | private $value; |
||
24 | |||
25 | public static function today(): self |
||
29 | |||
30 | 16 | public static function createFromString(string $value, string $format = self::NATIVE_FORMAT): self |
|
35 | |||
36 | /** |
||
37 | * @param string|null $nativeValue |
||
38 | * @return self |
||
39 | */ |
||
40 | 16 | public static function fromNative($nativeValue): self |
|
45 | |||
46 | 4 | public function toNative(): ?string |
|
50 | |||
51 | 1 | public function equals(ValueObjectInterface $otherValue): bool |
|
55 | |||
56 | 1 | public function __toString(): string |
|
60 | |||
61 | 16 | private function __construct(DateTimeImmutable $value = self::NIL) |
|
65 | } |
||
66 |