Passed
Pull Request — master (#28)
by Zing
05:34
created

FiltersBetween   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A withPropertyConstraint() 0 7 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder\Filters;
6
7
use Illuminate\Database\Eloquent\Builder;
8
use Zing\QueryBuilder\Exceptions\ParameterException;
9
10
class FiltersBetween extends FiltersExact
11
{
12 5
    protected function withPropertyConstraint(Builder $query, $value, $property): Builder
13
    {
14 5
        if (! is_array($value) || count($value) !== 2) {
15 1
            throw ParameterException::tooFewElementsForBetweenExpression();
16
        }
17
18 4
        return $query->whereBetween($property, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query->whereBetween($property, $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...
19
    }
20
}
21