FilterScope   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 10 2
1
<?php
2
3
namespace Goopil\RestFilter\Scopes;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Builder;
7
8
/**
9
 * Class FilterScope.
10
 */
11
class FilterScope extends BaseScope
12
{
13
    /**
14
     * @param Builder $builder
15
     * @param Model   $model
16
     *
17
     * @return Builder
18
     */
19
    public function apply(Builder $builder, Model $model)
20
    {
21
        $filter = $this->hasArray($this->request->get(config('queryScope.filter.param', 'filter'), null));
22
23
        if (count($filter) > 0) {
24
            $builder = $builder->select($filter);
0 ignored issues
show
Bug introduced by
The method select() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean createSelectWithConstraint()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
25
        }
26
27
        return $builder;
28
    }
29
}
30