Completed
Push — master ( 187043...48cde4 )
by
unknown
01:30
created

src/Exceptions/InvalidFieldQuery.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Spatie\QueryBuilder\Exceptions;
4
5
use Illuminate\Http\Response;
6
use Illuminate\Support\Collection;
7
8 View Code Duplication
class InvalidFieldQuery extends InvalidQuery
9
{
10
    /** @var \Illuminate\Support\Collection */
11
    public $unknownFields;
12
13
    /** @var \Illuminate\Support\Collection */
14
    public $allowedFields;
15
16
    public function __construct(Collection $unknownFields, Collection $allowedFields)
17
    {
18
        $this->unknownFields = $unknownFields;
19
        $this->allowedFields = $allowedFields;
20
21
        $unknownFields = $unknownFields->implode(', ');
22
        $allowedFields = $allowedFields->implode(', ');
23
        $message = "Requested field(s) `{$unknownFields}` are not allowed. Allowed field(s) are `{$allowedFields}`.";
24
25
        parent::__construct(Response::HTTP_BAD_REQUEST, $message);
26
    }
27
28
    public static function fieldsNotAllowed(Collection $unknownFields, Collection $allowedFields)
29
    {
30
        return new static(...func_get_args());
0 ignored issues
show
The call to InvalidFieldQuery::__construct() misses a required argument $allowedFields.

This check looks for function calls that miss required arguments.

Loading history...
31
    }
32
}
33