Completed
Pull Request — master (#51)
by Greg
02:34
created

CommandData   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 72
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A annotationData() 0 4 1
A input() 0 4 1
A output() 0 4 1
A arguments() 0 4 1
A options() 0 4 1
A getArgsWithoutAppName() 0 11 1
A getArgsAndOptions() 0 7 1
1
<?php
2
namespace Consolidation\AnnotatedCommand;
3
4
use Symfony\Component\Console\Input\InputInterface;
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
class CommandData
8
{
9
    /** var AnnotationData */
10
    protected $annotationData;
11
    /** var InputInterface */
12
    protected $input;
13
    /** var OutputInterface */
14
    protected $output;
15
    /** var boolean */
16
    protected $usesInputInterface;
17
    /** var boolean */
18
    protected $usesOutputInterface;
19
20
    public function __construct(
21
        AnnotationData $annotationData,
22
        InputInterface $input,
23
        OutputInterface $output,
24
        $usesInputInterface,
25
        $usesOutputInterface
26
    ) {
27
        $this->annotationData = $annotationData;
28
        $this->input = $input;
29
        $this->output = $output;
30
        $this->usesInputInterface = $usesInputInterface;
31
        $this->usesOutputInterface = $usesOutputInterface;
32
    }
33
34
    public function annotationData()
35
    {
36
        return $this->annotationData;
37
    }
38
39
    public function input()
40
    {
41
        return $this->input;
42
    }
43
44
    public function output()
45
    {
46
        return $this->output;
47
    }
48
49
    public function arguments()
50
    {
51
        return $this->input->getArguments();
52
    }
53
54
    public function options()
55
    {
56
        return $this->input->getOptions();
57
    }
58
59
    public function getArgsWithoutAppName()
60
    {
61
        $args = $this->arguments();
62
63
        // When called via the Application, the first argument
64
        // will be the command name. The Application alters the
65
        // input definition to match, adding a 'command' argument
66
        // to the beginning.
67
        array_shift($args);
68
        return $args;
69
    }
70
71
    public function getArgsAndOptions()
72
    {
73
        // Get passthrough args, and add the options on the end.
74
        $args = $this->getArgsWithoutAppName();
75
        $args['options'] = $this->options();
76
        return $args;
77
    }
78
}
79