| Conditions | 3 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function handle(EnvelopeInterface $envelope): bool |
||
| 20 | { |
||
| 21 | $commit = $envelope->getMessage(); |
||
| 22 | Assertion::isInstanceOf($commit, CommitInterface::class); |
||
| 23 | |||
| 24 | if ($commit->getStreamRevision()->toNative() === 1) { |
||
| 25 | $projection = $this->repository->makeProjection(); |
||
| 26 | } else { |
||
| 27 | $aggregateId = $commit->getStreamId()->toNative(); |
||
| 28 | $projection = $this->repository->findById($aggregateId); |
||
| 29 | } |
||
| 30 | |||
| 31 | foreach ($commit->getEventLog() as $domainEvent) { |
||
| 32 | $projection = $projection->applyEvent($domainEvent); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $this->repository->persist($projection); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |