1 | <?php |
||
25 | abstract class AbstractEvent extends LeagueEvent implements Event |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var EventId |
||
30 | */ |
||
31 | protected $eventId; |
||
32 | |||
33 | /** |
||
34 | * @var DateTimeImmutable |
||
35 | */ |
||
36 | protected $occurredOn; |
||
37 | |||
38 | /** |
||
39 | * @var null|AggregateRootIdentifier |
||
40 | */ |
||
41 | protected $author; |
||
42 | |||
43 | /** |
||
44 | * Creates an Abstract Event |
||
45 | * |
||
46 | * @param AggregateRootIdentifier|null $author |
||
47 | */ |
||
48 | public function __construct(AggregateRootIdentifier $author = null) |
||
58 | |||
59 | /** |
||
60 | * Event identifier |
||
61 | * |
||
62 | * @return EventId |
||
63 | */ |
||
64 | public function eventId(): EventId |
||
68 | |||
69 | /** |
||
70 | * Date and time event has occurred |
||
71 | * |
||
72 | * @return DateTimeImmutable |
||
73 | */ |
||
74 | public function occurredOn(): DateTimeImmutable |
||
78 | |||
79 | /** |
||
80 | * The aggregate identifier of the entity responsible for this event |
||
81 | * |
||
82 | * @return null|AggregateRootIdentifier |
||
83 | */ |
||
84 | public function author(): ?AggregateRootIdentifier |
||
88 | |||
89 | /** |
||
90 | * Specify data which should be serialized to JSON |
||
91 | * |
||
92 | * @return mixed data which can be serialized by json_encode(), |
||
93 | * which is a value of any type other than a resource. |
||
94 | */ |
||
95 | abstract public function jsonSerialize(); |
||
96 | |||
97 | /** |
||
98 | * Used to unserialize from a stored event |
||
99 | * |
||
100 | * @param mixed $data |
||
101 | */ |
||
102 | abstract public function unserializeEvent($data): void; |
||
103 | } |
||
104 |