Failed Conditions
Push — master ( a26426...65249a )
by Arnold
14:53 queued 04:44
created

Body::getValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 2
nop 4
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jasny\Controller\Parameter;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
7
#[\Attribute]
8
class Body implements Parameter
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Body
Loading history...
9
{
10
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $request should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $type should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $required should have a doc-comment as per coding-style.
Loading history...
11
     * Get body or body parameters.
12
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
13
    public function getValue(ServerRequestInterface $request, string $name, ?string $type, bool $required = false): mixed
14
    {
15
        return $type === 'string'
16
            ? (string)$request->getBody()
17
            : $request->getParsedBody();
18
    }
19
}
20