| Conditions | 3 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 20 | public function provision( |
||
| 21 | Injector $injector, |
||
| 22 | ConfigProviderInterface $configProvider, |
||
| 23 | ServiceDefinitionInterface $serviceDefinition |
||
| 24 | ): void { |
||
| 25 | $commandConfigs = (array)$configProvider->get('services.daikon.command_router.commands', []); |
||
| 26 | $injector |
||
| 27 | ->share(CommandRouter::class) |
||
| 28 | ->delegate( |
||
| 29 | CommandRouter::class, |
||
| 30 | function (UnitOfWorkMap $uowMap) use ($injector, $commandConfigs): CommandRouter { |
||
| 31 | $handlerMap = []; |
||
| 32 | foreach ($commandConfigs as $uowKey => $registeredHandlers) { |
||
| 33 | foreach ($registeredHandlers as $commandFqcn => $handlerFqcn) { |
||
| 34 | $handlerMap[$commandFqcn] = fn(): CommandHandler => $injector->make( |
||
| 35 | $handlerFqcn, |
||
| 36 | [':unitOfWork' => $uowMap->get($uowKey)] |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | return new CommandRouter($handlerMap); |
||
| 41 | } |
||
| 45 |