Passed
Pull Request — master (#18)
by Timon
08:58
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\RethinkInterface;
9
use TBolier\RethinkQL\Types\Term\TermType;
10
11
class Count extends AbstractOperation
12
{
13
    /**
14
     * @var AbstractQuery
15
     */
16
    private $query;
17
18
    /**
19
     * @param RethinkInterface $rethink
20
     * @param MessageInterface $message
21
     * @param AbstractQuery $query
22
     */
23 5
    public function __construct(RethinkInterface $rethink, MessageInterface $message, AbstractQuery $query)
24
    {
25 5
        parent::__construct($rethink, $message);
26
27 5
        $this->query = $query;
28 5
        $this->rethink = $rethink;
29 5
        $this->message = $message;
30 5
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35 5
    public function toArray(): array
36
    {
37
        return [
38 5
            TermType::COUNT,
39
            [
40 5
                $this->query->toArray(),
41
            ],
42
        ];
43
    }
44
}
45