1 | <?php namespace C4tech\RayEmitter\Domain; |
||
6 | abstract class Event implements EventInterface |
||
7 | { |
||
8 | /** |
||
9 | * Global identifier for the entity related to this event. |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $identifier; |
||
13 | |||
14 | /** |
||
15 | * Version sequence number. |
||
16 | * @var integer |
||
17 | */ |
||
18 | protected $sequence = 0; |
||
19 | |||
20 | /** |
||
21 | * Date object of when the event occurred. |
||
22 | * @var DateTime |
||
23 | */ |
||
24 | protected $timestamp; |
||
25 | |||
26 | /** |
||
27 | * Payload of event alterations. |
||
28 | * @var object |
||
29 | */ |
||
30 | protected $payload; |
||
31 | |||
32 | 7 | public function __construct($identifier, array $payload) |
|
33 | { |
||
34 | 7 | $this->identifier = $identifier; |
|
35 | |||
36 | 7 | $this->payload = new stdClass; |
|
37 | 7 | foreach ($payload as $key => $value) { |
|
38 | 7 | $this->payload->$key = $value; |
|
39 | 7 | } |
|
40 | 7 | } |
|
41 | |||
42 | /** |
||
43 | * @inheritDoc |
||
44 | */ |
||
45 | 1 | public function getId() |
|
49 | |||
50 | /** |
||
51 | * @inheritDoc |
||
52 | */ |
||
53 | 2 | public function getPayload() |
|
57 | |||
58 | /** |
||
59 | * @inheritDoc |
||
60 | */ |
||
61 | 2 | public function getSequence() |
|
65 | |||
66 | /** |
||
67 | * @inheritDoc |
||
68 | */ |
||
69 | 2 | public function getTimestamp() |
|
73 | |||
74 | /** |
||
75 | * @inheritDoc |
||
76 | */ |
||
77 | 1 | public function serialize() |
|
89 | |||
90 | /** |
||
91 | * @inheritDoc |
||
92 | */ |
||
93 | 1 | public static function unserialize($record) |
|
109 | } |
||
110 |