| 1 | <?php |
||
| 10 | final class VersionTwo implements Event |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var AggregateRootId |
||
| 14 | */ |
||
| 15 | private $aggregateRootId; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var PointInTime |
||
| 19 | */ |
||
| 20 | private $timeOfRecording; |
||
| 21 | |||
| 22 | public function __construct( |
||
| 23 | AggregateRootId $aggregateRootId, |
||
| 24 | PointInTime $timeOfRecording |
||
| 25 | ) { |
||
| 26 | $this->aggregateRootId = $aggregateRootId; |
||
| 27 | $this->timeOfRecording = $timeOfRecording; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function aggregateRootId(): AggregateRootId |
||
| 31 | { |
||
| 32 | return $this->aggregateRootId; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function eventVersion(): int |
||
| 36 | { |
||
| 37 | return 2; |
||
| 38 | } |
||
| 39 | |||
| 40 | public function timeOfRecording(): PointInTime |
||
| 41 | { |
||
| 42 | return $this->timeOfRecording; |
||
| 43 | } |
||
| 44 | |||
| 45 | public static function fromPayload( |
||
| 46 | array $payload, |
||
| 47 | AggregateRootId $aggregateRootId, |
||
| 48 | PointInTime $timeOfRecording): Event |
||
| 49 | { |
||
| 50 | return new VersionTwo( |
||
| 51 | $aggregateRootId, |
||
| 52 | $timeOfRecording |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | public function toPayload(): array |
||
| 57 | { |
||
| 58 | return []; |
||
| 59 | } |
||
| 60 | |||
| 61 | public static function with(AggregateRootId $aggregateRootId, PointInTime $timeOfRecording): VersionTwo |
||
| 62 | { |
||
| 63 | return new VersionTwo( |
||
| 64 | $aggregateRootId, |
||
| 65 | $timeOfRecording |
||
| 66 | ); |
||
| 67 | } |
||
| 68 | |||
| 69 | } |
||
| 70 | |||
| 72 |