| Conditions | 5 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 6.2017 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 25 | public function __construct($token) |
|
|
|
|||
| 28 | { |
||
| 29 | 25 | if (empty($token)) { |
|
| 30 | 1 | throw new Exception('Token is empty'); |
|
| 31 | } |
||
| 32 | |||
| 33 | 25 | $this->token = $token; |
|
| 34 | |||
| 35 | 25 | if ($_SERVER['USER'] == 'dp') { |
|
| 36 | $this->host = 'http://eop.local'; |
||
| 37 | } |
||
| 38 | |||
| 39 | 25 | if (\session_status() === PHP_SESSION_NONE && !\headers_sent()) { |
|
| 40 | session_start(); |
||
| 41 | } |
||
| 42 | 25 | } |
|
| 43 | |||
| 62 | } |
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: