Get::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 3
crap 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\Manipulation\ManipulationTrait;
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
    use ManipulationTrait;
15
    use OperationTrait;
16
17
    /**
18
     * @var string|int
19
     */
20
    private $key;
21
22
    /**
23
     * @var QueryInterface
24
     */
25
    private $query;
26
27
    public function __construct(
28
        RethinkInterface $rethink,
29 2
        QueryInterface $query,
30
        $key
31
    ) {
32
        parent::__construct($rethink);
33
34
        $this->query = $query;
35 2
        $this->key = $key;
36
        $this->rethink = $rethink;
37 2
    }
38 2
39 2
    public function toArray(): array
40 2
    {
41 2
        return [
42
            TermType::GET,
43
            [
44
                $this->query->toArray(),
45
                [
46 2
                    TermType::DATUM,
47
                    $this->key,
48
                ],
49 2
            ],
50
        ];
51 2
    }
52
}
53