Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | 1 | public static function reconstituteFromSnapshotAndEvents(Snapshot $snapshot, Generator $events): AggregateRoot |
|
33 | { |
||
34 | 1 | $id = $snapshot->aggregateRootId(); |
|
35 | /** @var static&AggregateRoot $aggregateRoot */ |
||
36 | 1 | $aggregateRoot = static::reconstituteFromSnapshotState($id, $snapshot->state()); |
|
37 | 1 | $aggregateRoot->aggregateRootVersion = $snapshot->aggregateRootVersion(); |
|
|
|||
38 | |||
39 | 1 | foreach ($events as $event) { |
|
40 | 1 | $aggregateRoot->apply($event); |
|
41 | } |
||
42 | |||
43 | 1 | $aggregateRoot->aggregateRootVersion = $events->getReturn() ?: $aggregateRoot->aggregateRootVersion; |
|
44 | |||
45 | 1 | return $aggregateRoot; |
|
46 | } |
||
50 |