Completed
Pull Request — master (#1)
by Woody
27:07 queued 01:07
created

Input   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 27 3
1
<?php
2
3
namespace Equip;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use Equip\Adr\InputInterface;
7
8
class Input implements InputInterface
9
{
10
    /**
11
     * Flatten all input from the request
12
     *
13
     * @param ServerRequestInterface $request
14
     *
15
     * @return array
16
     */
17 10
    public function __invoke(
18
        ServerRequestInterface $request
19
    ) {
20 10
        $attrs = $request->getAttributes();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
21 10
        $body = $request->getParsedBody();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
22 10
        $cookies = $request->getCookieParams();
23 10
        $query = $request->getQueryParams();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24 10
        $uploads = $request->getUploadedFiles();
25
26 10
        if (empty($body)) {
27 8
            $body = [];
28 3
        } elseif (is_object($body)) {
29
            // Because the parsed body may also be represented as an object,
30
            // additional parsing is required. This is a bit dirty but works
31
            // very well for anonymous objects.
32 1
            $body = json_decode(json_encode($body), true);
33
        }
34
35
        // Order matters here! Important values go last!
36 10
        return array_replace(
37
            $query,
38
            $body,
39
            $uploads,
40
            $cookies,
41
            $attrs
42
        );
43
    }
44
}
45