| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | public function initalize() |
||
| 43 | { |
||
| 44 | if (isset($this->backup)) { |
||
| 45 | throw new BadMethodCallException('Environment already backed up, can\'t initialize any longer'); |
||
| 46 | } |
||
| 47 | |||
| 48 | if (!is_array($GLOBALS['argv'])) { |
||
| 49 | throw new \UnexpectedValueException('Need argv to work'); |
||
| 50 | } |
||
| 51 | |||
| 52 | $basename = basename($GLOBALS['argv'][0]); |
||
| 53 | |||
| 54 | foreach ($this->keys as $key) { |
||
| 55 | $buffer = $_SERVER[$key]; |
||
| 56 | $this->backup[$key] = $buffer; |
||
| 57 | $_SERVER[$key] = str_replace($basename, 'index.php', $buffer); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 74 |
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: