Conditions | 2 |
Paths | 2 |
Total Lines | 31 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
15 | 1 | public function __invoke(ContainerInterface $container, string $name, callable $callback): Console |
|
16 | { |
||
17 | /** @var Console $console */ |
||
18 | 1 | $console = $callback(); |
|
19 | 1 | $definition = $console->getDefinition(); |
|
20 | 1 | $definition->addOption(new InputOption( |
|
21 | 1 | 'connection', |
|
22 | 1 | 'c', |
|
23 | 1 | InputArgument::OPTIONAL, |
|
24 | 1 | 'Doctrine connection name.', |
|
25 | 1 | 'orm_default' |
|
26 | )); |
||
27 | 1 | $input = $console->getInput(); |
|
28 | try { |
||
29 | 1 | $input->bind($definition); |
|
30 | 1 | } catch (\Throwable $e) { |
|
31 | // Errors must be ignored, full binding/validation happens later when the command is known. |
||
32 | } |
||
33 | |||
34 | /** @var string $connection */ |
||
35 | 1 | $connection = $input->getOption('connection') ?? 'orm_default'; |
|
36 | 1 | $console->setHelperSet((new DoctrineCliHelperSetFactory())->__invoke( |
|
37 | 1 | $container, |
|
38 | $connection |
||
39 | )); |
||
40 | |||
41 | 1 | $helperSet = $console->getHelperSet(); |
|
42 | 1 | $helperSet->set(new QuestionHelper(), 'question'); |
|
43 | 1 | $console->setHelperSet($helperSet); |
|
44 | |||
45 | 1 | return $console; |
|
46 | } |
||
48 |