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

Table::between()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 11
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query;
5
6
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait;
7
use TBolier\RethinkQL\Query\Operation\Between;
8
use TBolier\RethinkQL\Query\Operation\Get;
9
use TBolier\RethinkQL\Query\Operation\IndexCreate;
10
use TBolier\RethinkQL\Query\Operation\IndexDrop;
11
use TBolier\RethinkQL\Query\Operation\IndexList;
12
use TBolier\RethinkQL\Query\Operation\IndexRename;
13
use TBolier\RethinkQL\Query\Operation\OperationTrait;
14
use TBolier\RethinkQL\Query\Transformation\TransformationTrait;
15
use TBolier\RethinkQL\RethinkInterface;
16
use TBolier\RethinkQL\Types\Term\TermType;
17
18
class Table extends AbstractQuery
19
{
20
    use AggregationTrait;
21
    use OperationTrait;
22
    use TransformationTrait;
23
24
    /**
25 11
     * @var array
26
     */
27 11
    private $query;
28
29 11
    public function __construct(string $name, RethinkInterface $rethink)
30 11
    {
31
        parent::__construct($rethink);
32 11
33 11
        $this->rethink = $rethink;
34
35 11
36
        $this->query = [
37
            TermType::TABLE,
38 11
            [
39
                $name,
40
            ],
41
        ];
42
    }
43 2
44
    public function get($key): AbstractQuery
45 2
    {
46
        return new Get($this->rethink, $this, $key);
47
    }
48
49
    public function indexCreate(string $name): AbstractQuery
50
    {
51 11
        return new IndexCreate($this->rethink, $this, $name);
52
    }
53 11
54
    public function indexDrop(string $name): AbstractQuery
55
    {
56
        return new IndexDrop($this->rethink, $this, $name);
57
    }
58
59
    public function indexList(): AbstractQuery
60
    {
61
        return new IndexList($this->rethink, $this);
62
    }
63
64
    public function indexRename(string $oldValue, string $newValue): AbstractQuery
65
    {
66
        return new IndexRename($this->rethink, $this, $oldValue, $newValue);
67
    }
68
69
    public function between(
70
        $min,
71
        $max,
72
        $options = null
73
    ): AbstractQuery {
74
        return new Between(
75
            $this->rethink,
76
            $this,
77
            $min,
78
            $max,
79
            $options
80
        );
81
    }
82
83
    public function toArray(): array
84
    {
85
        return $this->query;
86
    }
87
}
88