Completed
Push — master ( 550846...8c8483 )
by Anton
09:53
created

AbstractCommand::getOption()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 48
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 8.7396
c 0
b 0
f 0
cc 4
eloc 23
nc 6
nop 1
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/bluzman
5
 */
6
7
namespace Bluzman\Command;
8
9
use Bluzman\Application\Application;
10
use Symfony\Component\Console;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Filesystem\Filesystem;
14
15
/**
16
 * Class AbstractCommand
17
 * @package Bluzman\Command
18
 *
19
 * @method Application getApplication()
20
 *
21
 * @author Pavel Machekhin
22
 * @created 2013-11-28 15:47
23
 */
24
abstract class AbstractCommand extends Console\Command\Command
25
{
26
    /**
27
     * @var InputInterface
28
     */
29
    protected $input;
30
31
    /**
32
     * @var OutputInterface
33
     */
34
    protected $output;
35
36
    /**
37
     * @var Filesystem
38
     */
39
    protected $fs;
40
41
    /**
42
     * @param InputInterface $input
43
     */
44
    public function setInput(InputInterface $input)
45
    {
46
        $this->input = $input;
47
    }
48
49
    /**
50
     * @return InputInterface
51
     */
52
    public function getInput()
53
    {
54
        return $this->input;
55
    }
56
57
    /**
58
     * @param OutputInterface $output
59
     */
60
    public function setOutput(OutputInterface $output)
61
    {
62
        $this->output = $output;
63
    }
64
65
    /**
66
     * @return OutputInterface
67
     */
68
    public function getOutput()
69
    {
70
        return $this->output;
71
    }
72
73
    /**
74
     * @param \Symfony\Component\Filesystem\Filesystem $fs
75
     */
76
    public function setFs($fs)
77
    {
78
        $this->fs = $fs;
79
    }
80
81
    /**
82
     * @return \Symfony\Component\Filesystem\Filesystem
83
     */
84
    public function getFs()
85
    {
86
        if (!$this->fs) {
87
            $this->fs = new Filesystem();
88
        }
89
        return $this->fs;
90
    }
91
92
    /**
93
     * @param  InputInterface $input
94
     * @param  OutputInterface $output
95
     * @return integer
96
     */
97
    final public function run(InputInterface $input, OutputInterface $output)
98
    {
99
        $this->setInput($input);
100
        $this->setOutput($output);
101
102
        return parent::run($input, $output);
103
    }
104
105
    /**
106
     * @param $message
107
     * @return void
108
     */
109
    public function write($message)
110
    {
111
        $this->getOutput()->writeln($message);
112
    }
113
114
    /**
115
     * @param $message
116
     * @return void
117
     */
118
    public function info($message)
119
    {
120
        $this->write("<info>$message</info>");
121
    }
122
123
    /**
124
     * @param $message
125
     * @return void
126
     */
127
    public function comment($message)
128
    {
129
        $this->write("<comment>$message</comment>");
130
    }
131
132
    /**
133
     * @param $message
134
     * @return void
135
     */
136
    public function question($message)
137
    {
138
        $this->write("<question>$message</question>:");
139
    }
140
141
    /**
142
     * @param $message
143
     * @return void
144
     */
145
    public function error($message)
146
    {
147
        $this->write("<error>$message</error>");
148
    }
149
150
    /**
151
     * @internal param $output
152
     */
153
    public function callForContribute()
154
    {
155
        $this->info(
156
            ' This command is not implemented yet. Don\'t be indifferent - you can contribute!' .
157
            ' https://github.com/bluzphp/bluzman. '
158
        );
159
    }
160
}
161