| Conditions | 3 |
| Paths | 1 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function register() |
||
|
|
|||
| 15 | { |
||
| 16 | $this->getContainer()->share(Client::class, function () { |
||
| 17 | $headers = [ |
||
| 18 | 'transfer-encoding' => 'chunked', |
||
| 19 | ]; |
||
| 20 | if (array_key_exists('HTTP_X_REAL_IP', $_SERVER)) { |
||
| 21 | $headers['x-real-ip'] = $_SERVER['HTTP_X_REAL_IP']; |
||
| 22 | } |
||
| 23 | if (array_key_exists('HTTP_X_SESSION', $_SERVER)) { |
||
| 24 | $headers['x-session'] = $_SERVER['HTTP_X_SESSION']; |
||
| 25 | } |
||
| 26 | return new Client([ |
||
| 27 | 'headers' => $headers |
||
| 28 | ]); |
||
| 29 | }); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |
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: