| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | 1 | public function __invoke(ContainerInterface $container): Console |
|
| 17 | { |
||
| 18 | 1 | $config = $container->get('config')['console']; |
|
| 19 | /** @var Console $console */ |
||
| 20 | 1 | $console = new Console(); |
|
| 21 | 1 | $commands = $config['commands'] ?? []; |
|
| 22 | 1 | $lazyCommands = []; |
|
| 23 | 1 | foreach ($commands as $name => $command) { |
|
| 24 | 1 | $lazyCommands[$name] = static function () use ($command, $container): Command { |
|
| 25 | 1 | return $container->get($command); |
|
| 26 | }; |
||
| 27 | } |
||
| 28 | 1 | $console->setCommandLoader(new FactoryCommandLoader($lazyCommands)); |
|
| 29 | 1 | array_walk( |
|
| 30 | 1 | $config['helper-sets'], |
|
| 31 | 1 | static function (string $helperSet) use ($console, $container): void { |
|
| 32 | 1 | $console->setHelperSet($container->get($helperSet)); |
|
| 33 | 1 | } |
|
| 34 | ); |
||
| 35 | |||
| 36 | 1 | return $console; |
|
| 37 | } |
||
| 39 |