Conditions | 3 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
40 | 4 | public function __invoke($varName, array $query, InjectorInterface $injector) |
|
|
|||
41 | { |
||
42 | 4 | $superGlobals = static::$globals ? static::$globals : $GLOBALS; |
|
43 | 4 | $webContextParam = $this->webContextParam; |
|
44 | 4 | $phpWebContext = $superGlobals[$webContextParam::GLOBAL_KEY]; |
|
45 | |||
46 | 4 | if (isset($phpWebContext[$this->webContextParam->key])) { |
|
47 | 2 | return $phpWebContext[$this->webContextParam->key]; |
|
48 | } |
||
49 | |||
50 | 2 | return $this->defaultParam->__invoke($varName, $query, $injector); |
|
51 | } |
||
52 | |||
58 |
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: