WhereFilter::filter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
crap 2
1
<?php
2
3
namespace San4io\EloquentFilter\Filters;
4
5
use Illuminate\Database\Eloquent\Builder;
6
7
class WhereFilter extends AbstractFilter
8
{
9
    /**
10
     * @param string $key
11
     * @param array|int $value
12
     * @return Builder
13
     */
14 4
    public function filter(string $key, $value): Builder
15
    {
16 4
        if (is_array($value)) {
17 1
            return $this->model->whereIn($key, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->model->whereIn($key, $value) could return the type Illuminate\Database\Query\Builder which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Builder. Consider adding an additional type-check to rule them out.
Loading history...
18
        }
19
20 3
        return $this->model->where($key, $value);
21
    }
22
}