Test Failed
Pull Request — master (#75)
by Timon
02:19
created

Table::sync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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