| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 15 | final class EventProjector implements EventProjectorInterface |
||
| 16 | { |
||
| 17 | private array $eventExpressions; |
||
| 18 | |||
| 19 | private ProjectorInterface $projector; |
||
| 20 | |||
| 21 | public function __construct(array $eventExpressions, ProjectorInterface $projector) |
||
| 22 | { |
||
| 23 | $this->eventExpressions = $eventExpressions; |
||
| 24 | $this->projector = $projector; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function matches(DomainEventInterface $event): bool |
||
| 28 | { |
||
| 29 | $eventFqcn = get_class($event); |
||
| 30 | return array_reduce( |
||
| 31 | $this->eventExpressions, |
||
| 32 | fn(bool $carry, string $eventExpression): bool => $carry || $eventExpression === $eventFqcn, |
||
| 33 | false |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function getProjector(): ProjectorInterface |
||
| 38 | { |
||
| 39 | return $this->projector; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getEventExpressions(): array |
||
| 45 | } |
||
| 46 | } |
||
| 47 |