HelpCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getApplication() 0 4 1
A help() 0 7 1
A getHelpDocument() 0 4 1
1
<?php
2
namespace Consolidation\AnnotatedCommand\Help;
3
4
use Symfony\Component\Console\Application;
5
use Symfony\Component\Console\Descriptor\XmlDescriptor;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class HelpCommand
10
{
11
    /** var Application */
12
    protected $application;
13
14
    /**
15
     * Create a help document from a Symfony Console command
16
     */
17
    public function __construct(Application $application)
18
    {
19
        $this->application = $application;
20
    }
21
22
    public function getApplication()
23
    {
24
        return $this->application;
25
    }
26
27
    /**
28
     * Run the help command
29
     *
30
     * @command my-help
31
     * @return \Consolidation\AnnotatedCommand\Help\HelpDocument
32
     */
33
    public function help($commandName = 'help')
34
    {
35
        $command = $this->getApplication()->find($commandName);
36
37
        $helpDocument = $this->getHelpDocument($command);
38
        return $helpDocument;
39
    }
40
41
    /**
42
     * Create a help document.
43
     */
44
    protected function getHelpDocument($command)
45
    {
46
        return new HelpDocument($command);
47
    }
48
}
49