Failed Conditions
Pull Request — master (#34)
by Marc
03:16
created

IndexRename   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 13 1
A __construct() 0 14 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query\Operation;
5
6
use TBolier\RethinkQL\Message\MessageInterface;
7
use TBolier\RethinkQL\Query\AbstractQuery;
8
use TBolier\RethinkQL\Query\QueryInterface;
9
use TBolier\RethinkQL\RethinkInterface;
10
use TBolier\RethinkQL\Types\Term\TermType;
11
12
class IndexRename extends AbstractQuery
13
{
14
    /**
15
     * @var string
16
     */
17
    private $oldValue;
18
19
    /**
20
     * @var string
21
     */
22
    private $newValue;
23
24
    /**
25
     * @var QueryInterface
26
     */
27
    private $query;
28
29
    /**
30
     * @param RethinkInterface $rethink
31
     * @param MessageInterface $message
32
     * @param QueryInterface $query
33
     * @param string $oldValue
34
     * @param string $newValue
35
     */
36
    public function __construct(
37
        RethinkInterface $rethink,
38
        MessageInterface $message,
39
        QueryInterface $query,
40
        string $oldValue,
41
        string $newValue
42
    ) {
43
        parent::__construct($rethink, $message);
44
45
        $this->query = $query;
46
        $this->rethink = $rethink;
47
        $this->message = $message;
48
        $this->oldValue = $oldValue;
49
        $this->newValue = $newValue;
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function toArray(): array
56
    {
57
        return [
58
            TermType::INDEX_RENAME,
59
            [
60
                $this->query->toArray(),
61
                [
62
                    TermType::DATUM,
63
                    $this->oldValue,
64
                ],
65
                [
66
                    TermType::DATUM,
67
                    $this->newValue,
68
                ],
69
            ],
70
        ];
71
    }
72
}
73