Conditions | 5 |
Paths | 7 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public static function current() |
||
|
|||
35 | { |
||
36 | if (defined('PHPUNIT_RUNNING')) { |
||
37 | return 'http://localhost'; |
||
38 | } |
||
39 | |||
40 | $protocol = (!empty($_SERVER['HTTPS']) |
||
41 | && $_SERVER['HTTPS'] !== 'off' |
||
42 | || (int) $_SERVER['SERVER_PORT'] === 443) ? 'https://' : 'http://'; |
||
43 | |||
44 | return $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
||
45 | } |
||
46 | } |
||
47 |
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: