Total Complexity | 4 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | trait SnapshottingBehaviour |
||
12 | { |
||
13 | abstract public function aggregateRootVersion(): int; |
||
14 | |||
15 | abstract public function aggregateRootId(): AggregateRootId; |
||
16 | |||
17 | abstract protected function apply(object $event): void; |
||
18 | |||
19 | 1 | public function createSnapshot(): Snapshot |
|
20 | { |
||
21 | 1 | return new Snapshot($this->aggregateRootId(), $this->aggregateRootVersion(), $this->createSnapshotState()); |
|
22 | } |
||
23 | |||
24 | abstract protected function createSnapshotState(); |
||
25 | |||
26 | /** |
||
27 | * @param Snapshot $snapshot |
||
28 | * @param Generator $events |
||
29 | * |
||
30 | * @return static |
||
31 | */ |
||
32 | 1 | public static function reconstituteFromSnapshotAndEvents(Snapshot $snapshot, Generator $events): AggregateRoot |
|
46 | } |
||
47 | |||
48 | abstract protected static function reconstituteFromSnapshotState(AggregateRootId $id, $state): AggregateRootWithSnapshotting; |
||
49 | } |
||
50 |