Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
33 | 1 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
34 | { |
||
35 | 1 | foreach ($this->queryParams as $name => $value) { |
|
36 | 1 | $uri = $request->getUri(); |
|
37 | 1 | $array = []; |
|
38 | 1 | parse_str($uri->getQuery(), $array); |
|
39 | |||
40 | // If query value is not found |
||
41 | 1 | if (!isset($array[$name])) { |
|
42 | 1 | $array[$name] = $value; |
|
43 | |||
44 | // Create a new request with the new URI with the added query param |
||
45 | 1 | $request = $request->withUri( |
|
46 | 1 | $uri->withQuery(http_build_query($array)) |
|
47 | 1 | ); |
|
48 | 1 | } |
|
49 | 1 | } |
|
50 | |||
51 | 1 | return $next($request); |
|
52 | } |
||
53 | } |
||
54 |