Passed
Branch master (7cc1cf)
by Timon
22:42 queued 20:08
created

Get::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 4
crap 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\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
    /**
19
     * @var QueryInterface
20
     */
21
    private $query;
22
23
    /**
24
     * @param RethinkInterface $rethink
25
     * @param MessageInterface $message
26
     * @param QueryInterface $query
27
     * @param string $documents
28
     */
29 2
    public function __construct(
30
        RethinkInterface $rethink,
31
        MessageInterface $message,
32
        QueryInterface $query,
33
        string $documents
34
    ) {
35 2
        parent::__construct($rethink, $message);
36
37 2
        $this->query = $query;
38 2
        $this->predicate = $documents;
39 2
        $this->rethink = $rethink;
40 2
        $this->message = $message;
41 2
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 2
    public function toArray(): array
47
    {
48
        return [
49 2
            TermType::GET,
50
            [
51 2
                $this->query->toArray(),
52
                [
53
                    TermType::DATUM,
54 2
                    $this->predicate,
55
                ],
56
            ],
57
        ];
58
    }
59
}
60