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

HelpCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
crap 1
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