| Total Complexity | 8 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait AggregateRootBehaviour |
||
| 13 | { |
||
| 14 | use AggregateAlwaysAppliesEvents { |
||
| 15 | apply as protected; |
||
| 16 | } |
||
| 17 | |||
| 18 | private AggregateRootId $aggregateRootId; |
||
| 19 | private int $aggregateRootVersion = 0; |
||
| 20 | /** @var object[] */ |
||
| 21 | private array $recordedEvents = []; |
||
| 22 | |||
| 23 | private function __construct(AggregateRootId $aggregateRootId) |
||
| 24 | { |
||
| 25 | $this->aggregateRootId = $aggregateRootId; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function aggregateRootId(): AggregateRootId |
||
| 31 | 17 | } |
|
| 32 | 17 | ||
| 33 | /** |
||
| 34 | 14 | * @see AggregateRoot::aggregateRootVersion |
|
| 35 | */ |
||
| 36 | 14 | public function aggregateRootVersion(): int |
|
| 37 | { |
||
| 38 | return $this->aggregateRootVersion; |
||
| 39 | } |
||
| 40 | |||
| 41 | protected function recordThat(object $event): void |
||
| 42 | 16 | { |
|
| 43 | $this->apply($event); |
||
| 44 | 16 | $this->recordedEvents[] = $event; |
|
| 45 | } |
||
| 46 | |||
| 47 | 11 | /** |
|
| 48 | * @return object[] |
||
| 49 | 11 | */ |
|
| 50 | 11 | public function releaseEvents(): array |
|
| 56 | 9 | } |
|
| 57 | 9 | ||
| 58 | 9 | /** |
|
| 59 | * @see AggregateRoot::reconstituteFromEvents |
||
| 60 | */ |
||
| 61 | public static function reconstituteFromEvents(AggregateRootId $aggregateRootId, Generator $events): static |
||
| 73 | } |
||
| 74 | } |
||
| 75 |