Passed
Pull Request — master (#68)
by Jérémy
03:08
created

Between::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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