ParseQueryParamModifier   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A modify() 0 6 1
1
<?php
2
3
namespace Thruster\Component\HttpModifiers;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use Thruster\Component\HttpModifier\ServerRequestModifierInterface;
7
8
/**
9
 * Class ParseQueryParamModifier
10
 *
11
 * @package Thruster\Component\HttpModifiers\ResponseModifier
12
 * @author  Aurimas Niekis <[email protected]>
13
 */
14
class ParseQueryParamModifier implements ServerRequestModifierInterface
15
{
16 1
    public function modify(ServerRequestInterface $request) : ServerRequestInterface
17
    {
18 1
        parse_str($request->getUri()->getQuery(), $queryParams);
19
20 1
        return $request->withQueryParams($queryParams);
0 ignored issues
show
Bug introduced by
It seems like $queryParams can also be of type null; however, Psr\Http\Message\ServerR...face::withQueryParams() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
21
    }
22
23
}
24