IndexRename::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 1
nc 1
nop 4
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 IndexRename extends AbstractQuery
12
{
13
    /**
14
     * @var string
15
     */
16
    private $oldValue;
17
18
    /**
19
     * @var string
20
     */
21
    private $newValue;
22
23
    /**
24
     * @var QueryInterface
25
     */
26
    private $query;
27
28
    public function __construct(
29
        RethinkInterface $rethink,
30
        QueryInterface $query,
31
        string $oldValue,
32
        string $newValue
33
    ) {
34
        parent::__construct($rethink);
35
36
        $this->query = $query;
37
        $this->rethink = $rethink;
38
39
        $this->oldValue = $oldValue;
40
        $this->newValue = $newValue;
41
    }
42
43
    public function toArray(): array
44
    {
45
        return [
46
            TermType::INDEX_RENAME,
47
            [
48
                $this->query->toArray(),
49
                [
50
                    TermType::DATUM,
51
                    $this->oldValue,
52
                ],
53
                [
54
                    TermType::DATUM,
55
                    $this->newValue,
56
                ],
57
            ],
58
        ];
59
    }
60
}
61