Passed
Push — master ( 112cee...b68050 )
by Michel
03:20
created

Group   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A toArray() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Query\Aggregation;
5
6
use TBolier\RethinkQL\Message\MessageInterface;
7
use TBolier\RethinkQL\Query\QueryInterface;
8
use TBolier\RethinkQL\Query\Transformation\AbstractTransformationCompound;
9
use TBolier\RethinkQL\RethinkInterface;
10
use TBolier\RethinkQL\Types\Term\TermType;
11
12
class Group extends AbstractTransformationCompound
13
{
14
    /**
15
     * @var string
16
     */
17
    private $key;
18
19
    /**
20
     * @var QueryInterface
21
     */
22
    private $query;
23
24
    /**
25
     * @param RethinkInterface $rethink
26
     * @param QueryInterface $query
27
     * @param string $key
28
     */
29
    public function __construct(
30
        RethinkInterface $rethink,
31
        QueryInterface $query,
32
        string $key
33
    ) {
34
        parent::__construct($rethink);
35
36
        $this->query = $query;
37
        $this->key = $key;
38
        $this->rethink = $rethink;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function toArray(): array
45
    {
46
        return [
47
            TermType::GROUP,
48
            [
49
                $this->query->toArray(),
50
                $this->key,
51
            ],
52
        ];
53
    }
54
}
55