Passed
Pull Request — master (#18)
by Timon
08:58
created

Get   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A toArray() 0 13 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
     * @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