ApplyBetween   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

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