| Conditions | 5 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 17 | public function __construct(Identity $identity, array $events) |
||
| 18 | { |
||
| 19 | $this->identity = $identity; |
||
| 20 | |||
| 21 | foreach ($events as $event) { |
||
| 22 | if (!$event instanceof DomainEvent || !$event->getAggregateIdentity()->equals($identity)) { |
||
| 23 | throw new CorruptAggregateHistory; |
||
| 24 | } |
||
| 25 | |||
| 26 | $this->events[] = $event; |
||
| 27 | } |
||
| 28 | |||
| 29 | if (count($events) > 0) { |
||
| 30 | $this->fromVersion = array_shift(array_values($events)); |
||
|
|
|||
| 31 | $this->toVersion = array_pop(array_values($events)); |
||
| 32 | reset($this->events); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 46 |