1 | <?php |
||
2 | |||
3 | namespace VGirol\JsonApi\Resources; |
||
4 | |||
5 | use VGirol\JsonApiConstant\Members; |
||
6 | |||
7 | class ErrorResourceCollection extends BaseResourceCollection |
||
8 | { |
||
9 | public function __construct($resource) |
||
10 | { |
||
11 | parent::__construct($resource); |
||
12 | |||
13 | $this->wrap(Members::ERRORS); |
||
14 | } |
||
15 | |||
16 | public function getStatusCode() |
||
17 | { |
||
18 | $max = $this->collection->map(function ($item, $key) { |
||
0 ignored issues
–
show
|
|||
19 | return $item->getStatusCode(); |
||
20 | })->max(); |
||
21 | |||
22 | $statusCode = $max; |
||
23 | if ($this->count() > 1) { |
||
24 | if ($max >= 400 && $max < 500) { |
||
25 | $statusCode = 400; |
||
26 | } elseif ($max >= 500) { |
||
27 | $statusCode = 500; |
||
28 | } |
||
29 | } |
||
30 | |||
31 | return $statusCode; |
||
32 | } |
||
33 | } |
||
34 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.