Total Complexity | 7 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
12 | abstract class TimestampValueObject implements TimestampValueObjectInterface |
||
13 | { |
||
14 | private $value; |
||
15 | |||
16 | /** |
||
17 | * @throws Exception if value is invalid |
||
18 | */ |
||
19 | public function __construct(?DateTimeImmutable $value) |
||
20 | { |
||
21 | try { |
||
22 | $this->guard($value); |
||
23 | } catch (Throwable $e) { |
||
24 | throw $this->throwException($value, $e); |
||
25 | } |
||
26 | $this->value = $value; |
||
27 | } |
||
28 | |||
29 | public function getDateTime(): ?DateTimeImmutable |
||
35 | } |
||
36 | |||
37 | public function equals(TimestampValueObjectInterface $other): bool |
||
43 | } |
||
44 | |||
45 | public function getValue(): ?int |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @throws Throwable if value is invalid |
||
52 | */ |
||
53 | abstract protected function guard(?DateTimeImmutable $value): void; |
||
54 | |||
55 | abstract protected function throwException(?DateTimeImmutable $value, Throwable $e): Exception; |
||
56 | } |
||
57 |