IndexRename   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 16
c 1
b 0
f 0
dl 0
loc 45
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 13 1
A __construct() 0 13 1
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