1 | <?php |
||
2 | declare(strict_types = 1); |
||
3 | |||
4 | namespace TBolier\RethinkQL\Query; |
||
5 | |||
6 | use TBolier\RethinkQL\Message\MessageInterface; |
||
7 | use TBolier\RethinkQL\Query\Operation\AbstractOperation; |
||
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\RethinkInterface; |
||
14 | use TBolier\RethinkQL\Types\Term\TermType; |
||
15 | |||
16 | class Table extends AbstractOperation implements TableInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | private $query; |
||
22 | |||
23 | /** |
||
24 | * @param string $name |
||
25 | 11 | * @param RethinkInterface $rethink |
|
26 | * @param MessageInterface $message |
||
27 | 11 | */ |
|
28 | public function __construct(string $name, RethinkInterface $rethink, MessageInterface $message) |
||
29 | 11 | { |
|
30 | 11 | parent::__construct($rethink, $message); |
|
31 | |||
32 | 11 | $this->rethink = $rethink; |
|
33 | 11 | $this->message = $message; |
|
34 | |||
35 | 11 | $this->query = [ |
|
36 | TermType::TABLE, |
||
37 | [ |
||
38 | 11 | $name, |
|
39 | ], |
||
40 | ]; |
||
41 | } |
||
42 | |||
43 | 2 | /** |
|
44 | * @inheritdoc |
||
45 | 2 | */ |
|
46 | public function get($key): AbstractQuery |
||
47 | { |
||
48 | return new Get($this->rethink, $this->message, $this, $key); |
||
49 | } |
||
50 | |||
51 | 11 | /** |
|
52 | * @inheritdoc |
||
53 | 11 | */ |
|
54 | public function indexCreate(string $name): AbstractQuery |
||
55 | { |
||
56 | return new IndexCreate($this->rethink, $this->message, $this, $name); |
||
57 | |||
58 | } |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | public function indexDrop(string $name): AbstractQuery |
||
64 | { |
||
65 | return new IndexDrop($this->rethink, $this->message, $this, $name); |
||
66 | |||
67 | } |
||
0 ignored issues
–
show
|
|||
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | */ |
||
72 | public function indexList(): AbstractQuery |
||
73 | { |
||
74 | return new IndexList($this->rethink, $this->message, $this); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @inheritdoc |
||
79 | */ |
||
80 | public function indexRename(string $oldValue, string $newValue): AbstractQuery |
||
81 | { |
||
82 | return new IndexRename($this->rethink, $this->message, $this, $oldValue, $newValue); |
||
83 | |||
84 | } |
||
0 ignored issues
–
show
|
|||
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | */ |
||
89 | public function toArray(): array |
||
90 | { |
||
91 | return $this->query; |
||
92 | } |
||
93 | } |
||
94 |