Issues (115)

src/Resources/ErrorResourceCollection.php (1 issue)

Severity
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
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
        $max = $this->collection->map(function ($item, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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