Conditions | 4 |
Paths | 5 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function generate() |
||
|
|||
21 | { |
||
22 | if (!isset($_SERVER['REQUEST_URI'])) { |
||
23 | throw new RuntimeException("Can't auto-detect current page identity"); |
||
24 | } |
||
25 | |||
26 | $port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (':'.$_SERVER['SERVER_PORT']); |
||
27 | $scheme = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === 0 ? 'https' : 'http'; |
||
28 | |||
29 | return md5($scheme . '://'.$_SERVER['HTTP_HOST']. $port . $_SERVER['REQUEST_URI']); |
||
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: