Passed
Pull Request — master (#34)
by Marc
05:44
created

Get   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 44
c 0
b 0
f 0
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A toArray() 0 9 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 Get extends AbstractQuery
13
{
14
    /**
15
     * @var string|int
16
     */
17
    private $key;
18
19
    /**
20
     * @var QueryInterface
21
     */
22
    private $query;
23
24
    /**
25
     * @param RethinkInterface $rethink
26
     * @param MessageInterface $message
27
     * @param QueryInterface $query
28
     * @param string|int $key
29 2
     */
30
    public function __construct(
31
        RethinkInterface $rethink,
32
        MessageInterface $message,
33
        QueryInterface $query,
34
        $key
35 2
    ) {
36
        parent::__construct($rethink, $message);
37 2
38 2
        $this->query = $query;
39 2
        $this->key = $key;
40 2
        $this->rethink = $rethink;
41 2
        $this->message = $message;
42
    }
43
44
    /**
45
     * @inheritdoc
46 2
     */
47
    public function toArray(): array
48
    {
49 2
        return [
50
            TermType::GET,
51 2
            [
52
                $this->query->toArray(),
53
                [
54 2
                    TermType::DATUM,
55
                    $this->key,
56
                ],
57
            ],
58
        ];
59
    }
60
}
61