Passed
Push — master ( 62679a...2b0c72 )
by Gerard van
07:11
created

HelpCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 40.91%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 44
ccs 9
cts 22
cp 0.4091
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 14 1
A setCommand() 0 4 1
A execute() 0 12 2
1
<?php
2
3
namespace Zicht\Tool\Command;
4
5
use Symfony\Component\Console\Helper\DescriptorHelper;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Symfony\Component\Console\Input;
8
use Symfony\Component\Console\Command\Command;
9
10
class HelpCommand extends Command
11
{
12
    private $command;
13
14 1
    protected function configure()
15
    {
16 1
        $this->ignoreValidationErrors();
17
18 1
        $this
19 1
            ->setName('z:help')
20 1
            ->setDescription('Shows help')
21 1
            ->setDefinition(
22
                array(
23 1
                    new Input\InputArgument('command_name', Input\InputArgument::OPTIONAL, 'The command name', 'z:help'),
24
                )
25 1
            )
26
        ;
27 1
    }
28
29
30
    /**
31
     * Sets the command
32
     *
33
     * @param Command $command The command to set
34
     */
35
    public function setCommand(Command $command)
36
    {
37
        $this->command = $command;
38
    }
39
40
41
    protected function execute(Input\InputInterface $input, OutputInterface $output)
42
    {
43
        if (null === $this->command) {
44
            $this->command = $this->getApplication()->find($input->getArgument('command_name'));
45
        }
46
47
        $helper = new DescriptorHelper();
48
        $helper->describe($output, $this->command, array(
49
            'format' => 'txt',
50
            'raw_text' => false,
51
        ));
52
    }
53
}
54