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

Index::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
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