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

ApplyBetween   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 23
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 6 1
A isSatisfiedBy() 0 7 2
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