Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
33 | 3 | public function getParams() |
|
|
|||
34 | { |
||
35 | 3 | if (!isset($this->_args)) { |
|
36 | if (isset($_SERVER['argv'])) { |
||
37 | $args = $_SERVER['argv']; |
||
38 | $this->_self = array_shift($args); |
||
39 | $command = $args[0]; |
||
40 | $alias = Yii::$app->config->aliases->get($command); |
||
41 | if ($alias) { |
||
42 | array_shift($args); |
||
43 | $args = array_merge($alias, $args); |
||
44 | } |
||
45 | $this->_args = $args; |
||
46 | } else { |
||
47 | $this->_args = []; |
||
48 | } |
||
49 | $this->setParams($this->_args); |
||
50 | } |
||
51 | |||
52 | 3 | return $this->_args; |
|
53 | } |
||
54 | |||
61 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: