Passed
Push — master ( eba56b...0dd639 )
by Sebastian
01:52
created

Command::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console;
13
14
use CaptainHook\App\Console\Runtime\Resolver;
15
use Symfony\Component\Console\Command\Command as SymfonyCommand;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Class Command
21
 *
22
 * @package CaptainHook
23
 * @author  Sebastian Feldmann <[email protected]>
24
 * @link    https://github.com/captainhookphp/captainhook
25
 * @since   Class available since Release 5.0.0
26
 */
27
abstract class Command extends SymfonyCommand
28
{
29
    /**
30
     * Input output handler
31
     *
32
     * @var \CaptainHook\App\Console\IO
33
     */
34
    private $io;
35
36
    /**
37
     * Runtime resolver
38
     *
39
     * @var \CaptainHook\App\Console\Runtime\Resolver
40
     */
41
    protected $resolver;
42
43
    /**
44
     * Command constructor
45
     *
46
     * @param \CaptainHook\App\Console\Runtime\Resolver $resolver
47
     */
48
    public function __construct(Resolver $resolver)
49
    {
50
        $this->resolver = $resolver;
51
        parent::__construct();
52
    }
53
54
    /**
55
     * IO setter
56
     *
57
     * @param \CaptainHook\App\Console\IO $io
58
     */
59
    public function setIO(IO $io): void
60
    {
61
        $this->io = $io;
62
    }
63
64
    /**
65
     * IO interface getter
66
     *
67
     * @param  \Symfony\Component\Console\Input\InputInterface   $input
68
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
69
     * @return \CaptainHook\App\Console\IO
70
     */
71
    public function getIO(InputInterface $input, OutputInterface $output): IO
72
    {
73
        if (null === $this->io) {
74
            $this->io = new IO\DefaultIO($input, $output, $this->getHelperSet());
75
        }
76
        return $this->io;
77
    }
78
}
79