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

BetweenFilter::withPropertyConstraint()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 3
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
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