Passed
Pull Request — master (#68)
by Jérémy
05:01 queued 02:09
created

Between   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 20
dl 0
loc 53
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A toArray() 0 15 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query\Operation;
5
6
use TBolier\RethinkQL\Query\AbstractQuery;
7
use TBolier\RethinkQL\Query\QueryInterface;
8
use TBolier\RethinkQL\RethinkInterface;
9
use TBolier\RethinkQL\Types\Term\TermType;
10
11
class Between extends AbstractQuery
12
{
13
    /**
14
     * @var QueryInterface
15
     */
16
    private $query;
17
18
    /**
19
     * @var string
20
     */
21
    private $min;
22
23
    /**
24
     * @var string
25
     */
26
    private $max;
27
28
    /**
29
     * @var string
30
     */
31
    private $options;
32
33
    public function __construct(
34
        RethinkInterface $rethink,
35
        QueryInterface $query,
36
        $min,
37
        $max,
38
        $options = null
39
    ) {
40
        parent::__construct($rethink);
41
42
        $this->rethink = $rethink;
43
        $this->query = $query;
44
        $this->min = $min;
45
        $this->max = $max;
46
        $this->options = $options;
47
    }
48
49
    public function toArray(): array
50
    {
51
        $args = [
52
            $this->query->toArray(),
53
            $this->min,
54
            $this->max,
55
        ];
56
57
        if ($this->options !== null) {
58
            $args = array_merge($args, [$this->options]);
59
        }
60
61
        return [
62
            TermType::BETWEEN,
63
            $args,
64
        ];
65
    }
66
}
67