Passed
Pull Request — master (#18)
by Timon
02:57
created

Count::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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\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 Count extends AbstractQuery
13
{
14
    /**
15
     * @var QueryInterface
16
     */
17
    private $query;
18
19
    /**
20
     * @param RethinkInterface $rethink
21
     * @param MessageInterface $message
22
     * @param QueryInterface $query
23
     */
24 6
    public function __construct(RethinkInterface $rethink, MessageInterface $message, QueryInterface $query)
25
    {
26 6
        parent::__construct($rethink, $message);
27
28 6
        $this->query = $query;
29 6
        $this->rethink = $rethink;
30 6
        $this->message = $message;
31 6
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 6
    public function toArray(): array
37
    {
38
        return [
39 6
            TermType::COUNT,
40
            [
41 6
                $this->query->toArray(),
42
            ],
43
        ];
44
    }
45
}
46