Passed
Push — master ( 0b9717...65bc60 )
by noitran
05:28
created

ApplyBetween::supports()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Noitran\RQL\Processors\Eloquent;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Noitran\RQL\Contracts\Expression\ExprInterface;
7
use Noitran\RQL\Contracts\Processor\SpecInterface;
8
use Noitran\RQL\Contracts\Processor\ProcessorInterface;
9
use Noitran\RQL\Expressions\BetweenExpr;
10
11
/**
12
 * Class ApplyBetween
13
 */
14
class ApplyBetween implements SpecInterface
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public function isSatisfiedBy(ProcessorInterface $processor, ExprInterface $exprClass): bool
20
    {
21
        if (! $exprClass instanceof BetweenExpr) {
22
            return false;
23
        }
24
25
        return true;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function apply(ProcessorInterface $processor, ExprInterface $exprClass): Builder
32
    {
33
        /** @var EloquentProcessor $processor */
34
        return $processor->getBuilder()->whereBetween(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $processor->getBu...$exprClass->getValue()) 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...
35
            $exprClass->getColumn(),
36
            $exprClass->getValue()
37
        );
38
    }
39
}
40