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 |
||
37 | 1 | public static function reconstituteFromSnapshotAndEvents(Snapshot $snapshot, Generator $events): AggregateRoot |
|
38 | { |
||
39 | 1 | $id = $snapshot->aggregateRootId(); |
|
40 | /** @var static&AggregateRoot $aggregateRoot */ |
||
41 | 1 | $aggregateRoot = static::reconstituteFromSnapshotState($id, $snapshot->state()); |
|
42 | 1 | $aggregateRoot->aggregateRootVersion = $snapshot->aggregateRootVersion(); |
|
43 | |||
44 | 1 | foreach ($events as $event) { |
|
45 | 1 | $aggregateRoot->apply($event); |
|
46 | } |
||
47 | |||
48 | 1 | $aggregateRoot->aggregateRootVersion = $events->getReturn() ?: $aggregateRoot->aggregateRootVersion; |
|
49 | |||
50 | 1 | return $aggregateRoot; |
|
51 | } |
||
55 |