ApplyBetween::isSatisfiedBy()   A
last analyzed

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
declare(strict_types=1);
4
5
namespace Noitran\RQL\Processors\Eloquent;
6
7
use Illuminate\Database\Eloquent\Builder;
8
use Noitran\RQL\Contracts\Expression\ExprInterface;
9
use Noitran\RQL\Contracts\Processor\ProcessorInterface;
10
use Noitran\RQL\Contracts\Processor\SpecInterface;
11
use Noitran\RQL\Expressions\BetweenExpr;
12
13
/**
14
 * Class ApplyBetween.
15
 */
16
class ApplyBetween implements SpecInterface
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function isSatisfiedBy(ProcessorInterface $processor, ExprInterface $exprClass): bool
22
    {
23
        if (! $exprClass instanceof BetweenExpr) {
24
            return false;
25
        }
26
27
        return true;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function apply(ProcessorInterface $processor, ExprInterface $exprClass): Builder
34
    {
35
        /* @var EloquentProcessor $processor */
36
        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...
37
            $exprClass->getColumn(),
38
            $exprClass->getValue()
39
        );
40
    }
41
}
42