Passed
Pull Request — master (#18)
by Marc
03:37
created

Get::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Query\Operation;
5
6
use TBolier\RethinkQL\Query\MessageInterface;
7
use TBolier\RethinkQL\Query\QueryInterface;
8
use TBolier\RethinkQL\RethinkInterface;
9
use TBolier\RethinkQL\Types\Term\TermType;
10
11
class Get extends AbstractOperation
12
{
13
    /**
14
     * @var string
15
     */
16
    private $predicate;
17
    /**
18
     * @var QueryInterface
19
     */
20
    private $query;
21
22
    /**
23
     * @param RethinkInterface $rethink
24
     * @param MessageInterface $message
25
     * @param QueryInterface $query
26
     * @param string $documents
27
     */
28 2
    public function __construct(
29
        RethinkInterface $rethink,
30
        MessageInterface $message,
31
        QueryInterface $query,
32
        string $documents
33
    ) {
34 2
        parent::__construct($rethink, $message);
35
36 2
        $this->query = $query;
37 2
        $this->predicate = $documents;
38 2
        $this->rethink = $rethink;
39 2
        $this->message = $message;
40 2
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 2
    public function toArray(): array
46
    {
47
        return [
48 2
            TermType::GET,
49
            [
50 2
                $this->query->toArray(),
51
                [
52
                    TermType::DATUM,
53 2
                    $this->predicate,
54
                ],
55
            ],
56
        ];
57
    }
58
}
59