| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 3 | public function run(array $args) |
|
|
|
|||
| 19 | { |
||
| 20 | 3 | if (empty($args)) { |
|
| 21 | 1 | $globals = $this->globalsCopy(); // Recusion kills fromPhpType. |
|
| 22 | 1 | return self::fromPhpType($globals); |
|
| 23 | } |
||
| 24 | 2 | $this->expectArguments('.post', [['Symbol', 'String']], $args); |
|
| 25 | 2 | $index = $args[0]->value(); |
|
| 26 | 2 | if (isset($args[1])) { |
|
| 27 | 1 | $GLOBALS[$index] = $args[1]->value(); |
|
| 28 | } |
||
| 29 | 2 | return self::fromPhpType($GLOBALS[$index]); |
|
| 30 | } |
||
| 31 | |||
| 44 |
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: