| Total Complexity | 6 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 9 | class Dispatcher |
||
| 10 | { |
||
| 11 | /** @var EventHandler[][] */ |
||
| 12 | private $handlers; |
||
| 13 | |||
| 14 | public function __construct(EventHandler ...$handlers) |
||
| 19 | } |
||
| 20 | } |
||
| 21 | } |
||
| 22 | |||
| 23 | public function dispatch(DomainEvent $event): void |
||
| 24 | { |
||
| 25 | foreach ($this->handlers[get_class($event)] ?? [] as $handler) { |
||
| 26 | $handler->handle($event); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | public function registerHandler(string $event, EventHandler $handler): void |
||
| 33 | } |
||
| 34 | } |
||
| 35 |