Test Failed
Push — master ( ffc71e...1a0a2f )
by Koen
03:32
created

Index   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Http\Controllers\Api\User;
6
7
use App\Http\Resources\Api\UserResource;
8
use App\Models\User;
9
use Illuminate\Database\Eloquent\Builder;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Builder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Illuminate\Http\Request;
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use KoenHoeijmakers\LaravelFilterable\Contracts\Filtering;
0 ignored issues
show
Bug introduced by
The type KoenHoeijmakers\LaravelF...ble\Contracts\Filtering was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
final class Index
14
{
15
    /**
16
     * @var \KoenHoeijmakers\LaravelFilterable\Filtering
0 ignored issues
show
Bug introduced by
The type KoenHoeijmakers\LaravelFilterable\Filtering was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
     */
18
    protected $filtering;
19
20
    /**
21
     * Index constructor.
22
     *
23
     * @param  \KoenHoeijmakers\LaravelFilterable\Contracts\Filtering $filtering
24
     */
25
    public function __construct(Filtering $filtering)
26
    {
27
        $this->filtering = $filtering;
28
    }
29
30
    /**
31
     * @param  \Illuminate\Http\Request $request
32
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Resource...ymousResourceCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
     */
34
    public function __invoke(Request $request)
35
    {
36
        $builder = User::query();
37
38
        $this->filtering->builder($builder)
39
            ->filterFor('name', function (Builder $builder, string $value) {
40
                $builder->where('name', 'like', '%' . $value . '%');
41
            })
42
            ->filterFor('email', function (Builder $builder, string $value) {
43
                $builder->where('email', 'like', '%' . $value . '%');
44
            })
45
            ->sortFor('name')
46
            ->sortFor('email')
47
            ->filter();
48
49
        return UserResource::collection($builder->paginate($request->input('perPage')));
50
    }
51
}
52