| Total Complexity | 9 |
| Total Lines | 102 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Event implements EventInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var AggregateUuid |
||
| 19 | */ |
||
| 20 | private $uuid; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $type; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var int |
||
| 29 | */ |
||
| 30 | private $version; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | private $payload; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var mixed |
||
| 39 | */ |
||
| 40 | private $body; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var \DateTimeImmutable |
||
| 44 | */ |
||
| 45 | private $occurred_on; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Event constructor. |
||
| 49 | * |
||
| 50 | * @param AggregateUuid $eventId |
||
| 51 | * @param $type |
||
| 52 | * @param $body |
||
| 53 | * @param null $version |
||
| 54 | * @param null $occurred_on |
||
| 55 | */ |
||
| 56 | public function __construct( |
||
| 57 | AggregateUuid $eventId, |
||
| 58 | $type, |
||
| 59 | $body, |
||
| 60 | $version = null, |
||
| 61 | $occurred_on = null |
||
| 62 | ) { |
||
| 63 | $this->uuid = $eventId; |
||
| 64 | $this->type = $type; |
||
| 65 | $this->body = $body; |
||
| 66 | $this->payload = get_class($this); |
||
| 67 | $this->version = ($version) ?: 0; |
||
| 68 | $this->occurred_on = ($occurred_on) ? new \DateTimeImmutable($occurred_on) : new \DateTimeImmutable(); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return AggregateUuid |
||
| 73 | */ |
||
| 74 | public function uuid() |
||
| 75 | { |
||
| 76 | return $this->uuid; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @return string |
||
| 81 | */ |
||
| 82 | public function type() |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @return string |
||
| 89 | */ |
||
| 90 | public function version() |
||
| 91 | { |
||
| 92 | return $this->version; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @return string |
||
| 97 | */ |
||
| 98 | public function payload() |
||
| 99 | { |
||
| 100 | return $this->payload; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @return mixed |
||
| 105 | */ |
||
| 106 | public function body() |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @return \DateTimeImmutable |
||
| 113 | */ |
||
| 114 | public function occurredOn() |
||
| 117 | } |
||
| 118 | } |
||
| 119 |