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

BadRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatus() 0 4 1
A getType() 0 4 1
A withInvalidParameters() 0 7 1
A getInvalidParameters() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\ApiProblem;
6
7
final class BadRequest extends AbstractApiProblem
8
{
9
    /**
10
     * @var array[]
11
     */
12
    private $invalidParameters = [];
13
14
    /**
15
     * @return int
16
     */
17 2
    public function getStatus(): int
18
    {
19 2
        return 400;
20
    }
21
22
    /**
23
     * @return string
24
     */
25 2
    public function getType(): string
26
    {
27 2
        return 'https://tools.ietf.org/html/rfc2616#section-10.4.1';
28
    }
29
30
    /**
31
     * @param string[] $invalidParameters
32
     *
33
     * @return ApiProblemInterface
34
     */
35 1
    public function withInvalidParameters(array $invalidParameters): ApiProblemInterface
36
    {
37 1
        $clone = clone $this;
38 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...
39
40 1
        return $clone;
41
    }
42
43
    /**
44
     * @return array
45
     */
46 2
    public function getInvalidParameters(): array
47
    {
48 2
        return $this->invalidParameters;
49
    }
50
}
51