| Total Complexity | 4 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class CommandBus |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | private $handlers = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param object $command |
||
| 21 | * |
||
| 22 | * @throws HandlerNotFoundException |
||
| 23 | */ |
||
| 24 | public function handle(object $command): void |
||
| 25 | { |
||
| 26 | $handler = $this->commandToHandler(\get_class($command)); |
||
| 27 | /* @var CommandBusAbstract $handler */ |
||
| 28 | $handler($command); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function addCommandHandler(object $handler): void |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $command |
||
| 38 | * |
||
| 39 | * @return CommandHandlerInterface |
||
| 40 | * |
||
| 41 | * @throws HandlerNotFoundException |
||
| 42 | */ |
||
| 43 | private function commandToHandler(string $command): CommandHandlerInterface |
||
| 57 |