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

CommandBusInteractiveConsoleCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 10 1
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