Completed
Pull Request — master (#11)
by
unknown
09:17 queued 06:40
created

CommandBusInteractiveConsoleCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Clearcode\CommandBusConsole\Bundle\Command;
4
5
use Matthias\SymfonyConsoleForm\Console\Helper\FormHelper;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use tests\Clearcode\CommandBusConsole\Bundle\Type\DummyCommandType;
11
12
class CommandBusInteractiveConsoleCommand extends ContainerAwareCommand
13
{
14
    const SUCCESS_CODE = 0;
15
    const ERROR_CODE = 1;
16
17
    const INTERACTIVE_COMMAND = 'command-bus:handle';
18
19
    private static $commandToFormTypeMap = [
0 ignored issues
show
Unused Code introduced by
The property $commandToFormTypeMap is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
20
        'DummyCommand' => DummyCommandType::class,
21
    ];
22
23
    protected function configure()
24
    {
25
        $this
26
            ->setName(self::INTERACTIVE_COMMAND)
27
            ->setDescription('Interactive CLI for command bus.')
28
            ->addArgument('commandName', InputArgument::REQUIRED);
29
    }
30
31
    /** {@inheritdoc} */
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        /** @var FormHelper $formHelper */
35
        $formHelper = $this->getHelper('form');
36
37
        $commandName = $input->getArgument('commandName');
38
        $command = $formHelper->interactUsingForm(new self::$commandToFormTypeMap[$commandName](), $input, $output);
39
40
        $output->writeln(print_r($command, true));
41
    }
42
}
43