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

Input::__invoke()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 3
eloc 17
nc 3
nop 1
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