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