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