| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function __invoke($params = [], $reuseMatchedParams = true, $resetCurrentParams = false) |
||
|
|
|||
| 16 | {
|
||
| 17 | $currentParams = []; |
||
| 18 | if (!$resetCurrentParams) {
|
||
| 19 | $queryString = $_SERVER['QUERY_STRING']; |
||
| 20 | $currentParamPairs = explode('&', $queryString);
|
||
| 21 | if (!empty($currentParamPairs[0])) {
|
||
| 22 | foreach ($currentParamPairs as $pair) {
|
||
| 23 | $data = explode('=', $pair);
|
||
| 24 | $currentParams[$data[0]] = urldecode($data[1]); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | } |
||
| 28 | $queryString = http_build_query(array_merge($currentParams, $params)); |
||
| 29 | return $this->getView()->url(null, [], [], $reuseMatchedParams) . '?' . $queryString; |
||
| 30 | } |
||
| 31 | } |
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: