InputAwareTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setInput() 0 6 1
A input() 0 7 2
A getInput() 0 4 1
1
<?php
2
3
namespace Robo\Common;
4
5
use Symfony\Component\Console\Input\ArgvInput;
6
use Symfony\Component\Console\Input\InputInterface;
7
8
trait InputAwareTrait
9
{
10
    /**
11
     * @var \Symfony\Component\Console\Input\InputInterface
12
     */
13
    protected $input;
14
15
    /**
16
     * @param \Symfony\Component\Console\Input\InputInterface $input
17
     *
18
     * @return $this
19
     *
20
     * @see \Symfony\Component\Console\Input\InputAwareInterface::setInput()
21
     */
22
    public function setInput(InputInterface $input)
23
    {
24
        $this->input = $input;
25
26
        return $this;
27
    }
28
29
    /**
30
     * @return \Symfony\Component\Console\Input\InputInterface
31
     */
32
    protected function input()
33
    {
34
        if (!isset($this->input)) {
35
            $this->setInput(new ArgvInput());
36
        }
37
        return $this->input;
38
    }
39
40
    /**
41
     * Backwards compatibility.
42
     *
43
     * @return \Symfony\Component\Console\Input\InputInterface
44
     *
45
     * @deprecated
46
     */
47
    protected function getInput()
48
    {
49
        return $this->input();
50
    }
51
}
52