Passed
Push — master ( 9c833b...4586fd )
by Zing
09:40 queued 04:04
created

BetweenFilter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
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 BetweenFilter extends ExactFilter
11
{
12
    /**
13
     * @param mixed $value
14
     * @param \Illuminate\Database\Query\Expression|string $property
15
     */
16 8
    protected function withPropertyConstraint(Builder $query, $value, $property): Builder
17
    {
18 8
        if (! is_array($value) || count($value) !== 2) {
19 1
            throw ParameterException::tooFewElementsForBetweenExpression();
20
        }
21
22 7
        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...
23
    }
24
}
25