Conditions | 3 |
Paths | 4 |
Total Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
42 | 7 | public function get() |
|
|
|||
43 | { |
||
44 | 7 | $connectionLocator = $this->injector->getInstance(ConnectionLocatorInterface::class, $this->context); |
|
45 | 7 | $isGetRequest = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET'; |
|
46 | 7 | $pdo = $isGetRequest ? $connectionLocator->getRead() : $connectionLocator->getWrite(); |
|
47 | |||
48 | 7 | return $pdo; |
|
49 | } |
||
50 | } |
||
51 |
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: