Passed
Pull Request — master (#2)
by Dominik
02:16
created

UnprocessableEntity::getStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\ApiProblem\ClientError;
6
7
use Chubbyphp\ApiHttp\ApiProblem\AbstractApiProblem;
8
use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
9
10 View Code Duplication
final class UnprocessableEntity extends AbstractApiProblem
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * @var array[]
14
     */
15
    private $invalidParameters = [];
16
17
    /**
18
     * @return int
19
     */
20 2
    public function getStatus(): int
21
    {
22 2
        return 422;
23
    }
24
25
    /**
26
     * @return string
27
     */
28 2
    public function getType(): string
29
    {
30 2
        return 'https://tools.ietf.org/html/rfc4918#section-11.2';
31
    }
32
33
    /**
34
     * @param string[] $invalidParameters
35
     *
36
     * @return ApiProblemInterface
37
     */
38 1
    public function withInvalidParameters(array $invalidParameters): ApiProblemInterface
39
    {
40 1
        $clone = clone $this;
41 1
        $clone->invalidParameters = $invalidParameters;
0 ignored issues
show
Documentation Bug introduced by
It seems like $invalidParameters of type array<integer,string> is incompatible with the declared type array<integer,array> of property $invalidParameters.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
43 1
        return $clone;
44
    }
45
46
    /**
47
     * @return array
48
     */
49 2
    public function getInvalidParameters(): array
50
    {
51 2
        return $this->invalidParameters;
52
    }
53
}
54