Conditions | 3 |
Paths | 2 |
Total Lines | 19 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php namespace Comodojo\Cookies; |
||
32 | protected static function encryptKey($key) { |
||
|
|||
33 | |||
34 | if ( isset($_SERVER['REMOTE_ADDR']) ) { |
||
35 | |||
36 | $client_hash = md5($_SERVER['REMOTE_ADDR'].(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ''), true); |
||
37 | |||
38 | $server_hash = md5($key, true); |
||
39 | |||
40 | $cookie_key = $client_hash.$server_hash; |
||
41 | |||
42 | } else { |
||
43 | |||
44 | $cookie_key = hash('sha256', $key); |
||
45 | |||
46 | } |
||
47 | |||
48 | return $cookie_key; |
||
49 | |||
50 | } |
||
51 | |||
53 |
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: