1 | <?php |
||
13 | final class Timestamp implements SerializableInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var DateTimeInterface |
||
17 | */ |
||
18 | private $startDate; |
||
19 | |||
20 | /** |
||
21 | * @var DateTimeInterface |
||
22 | */ |
||
23 | private $endDate; |
||
24 | |||
25 | /** |
||
26 | * @var Status |
||
27 | */ |
||
28 | private $status; |
||
29 | |||
30 | public function __construct( |
||
31 | DateTimeInterface $startDate, |
||
32 | DateTimeInterface $endDate, |
||
33 | Status $status = null |
||
34 | ) { |
||
35 | if ($endDate < $startDate) { |
||
36 | throw new InvalidArgumentException('End date can not be earlier than start date.'); |
||
37 | } |
||
38 | |||
39 | $this->startDate = $startDate; |
||
40 | $this->endDate = $endDate; |
||
41 | $this->status = $status ?? new Status(StatusType::available(), []); |
||
42 | } |
||
43 | |||
44 | public function withStatus(Status $status): self |
||
45 | { |
||
46 | $clone = clone $this; |
||
47 | $clone->status = $status; |
||
48 | return $clone; |
||
49 | } |
||
50 | |||
51 | public function getStartDate(): DateTimeInterface |
||
55 | |||
56 | public function getEndDate(): DateTimeInterface |
||
57 | { |
||
60 | |||
61 | public function getStatus(): Status |
||
65 | |||
66 | public static function deserialize(array $data): Timestamp |
||
79 | |||
80 | public function serialize(): array |
||
88 | |||
89 | public function toJsonLd(): array |
||
96 | |||
97 | public static function fromUdb3ModelSubEvent(SubEvent $subEvent): Timestamp |
||
105 | } |
||
106 |