| Conditions | 5 |
| Paths | 7 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public static function current() |
||
|
|
|||
| 16 | { |
||
| 17 | if (defined('PHPUNIT_RUNNING')) { |
||
| 18 | return 'http://localhost'; |
||
| 19 | } |
||
| 20 | |||
| 21 | $protocol = (!empty($_SERVER['HTTPS']) |
||
| 22 | && $_SERVER['HTTPS'] !== 'off' |
||
| 23 | || (int) $_SERVER['SERVER_PORT'] === 443) ? 'https://' : 'http://'; |
||
| 24 | |||
| 25 | return $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
||
| 26 | } |
||
| 27 | } |
||
| 28 |
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: