@@ 10-53 (lines=44) @@ | ||
7 | use Chubbyphp\ApiHttp\ApiProblem\AbstractApiProblem; |
|
8 | use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface; |
|
9 | ||
10 | final class BadRequest extends AbstractApiProblem |
|
11 | { |
|
12 | /** |
|
13 | * @var array[] |
|
14 | */ |
|
15 | private $invalidParameters = []; |
|
16 | ||
17 | /** |
|
18 | * @return int |
|
19 | */ |
|
20 | public function getStatus(): int |
|
21 | { |
|
22 | return 400; |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * @return string |
|
27 | */ |
|
28 | public function getType(): string |
|
29 | { |
|
30 | return 'https://tools.ietf.org/html/rfc2616#section-10.4.1'; |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * @param string[] $invalidParameters |
|
35 | * |
|
36 | * @return ApiProblemInterface |
|
37 | */ |
|
38 | public function withInvalidParameters(array $invalidParameters): ApiProblemInterface |
|
39 | { |
|
40 | $clone = clone $this; |
|
41 | $clone->invalidParameters = $invalidParameters; |
|
42 | ||
43 | return $clone; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @return array |
|
48 | */ |
|
49 | public function getInvalidParameters(): array |
|
50 | { |
|
51 | return $this->invalidParameters; |
|
52 | } |
|
53 | } |
|
54 |
@@ 10-53 (lines=44) @@ | ||
7 | use Chubbyphp\ApiHttp\ApiProblem\AbstractApiProblem; |
|
8 | use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface; |
|
9 | ||
10 | final class UnprocessableEntity extends AbstractApiProblem |
|
11 | { |
|
12 | /** |
|
13 | * @var array[] |
|
14 | */ |
|
15 | private $invalidParameters = []; |
|
16 | ||
17 | /** |
|
18 | * @return int |
|
19 | */ |
|
20 | public function getStatus(): int |
|
21 | { |
|
22 | return 422; |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * @return string |
|
27 | */ |
|
28 | public function getType(): string |
|
29 | { |
|
30 | return 'https://tools.ietf.org/html/rfc4918#section-11.2'; |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * @param string[] $invalidParameters |
|
35 | * |
|
36 | * @return ApiProblemInterface |
|
37 | */ |
|
38 | public function withInvalidParameters(array $invalidParameters): ApiProblemInterface |
|
39 | { |
|
40 | $clone = clone $this; |
|
41 | $clone->invalidParameters = $invalidParameters; |
|
42 | ||
43 | return $clone; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @return array |
|
48 | */ |
|
49 | public function getInvalidParameters(): array |
|
50 | { |
|
51 | return $this->invalidParameters; |
|
52 | } |
|
53 | } |
|
54 |