Group   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 14
c 1
b 0
f 0
dl 0
loc 35
rs 10

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\Query\AbstractQuery;
7
use TBolier\RethinkQL\Query\Operation\OperationTrait;
8
use TBolier\RethinkQL\Query\QueryInterface;
9
use TBolier\RethinkQL\Query\Transformation\TransformationTrait;
10
use TBolier\RethinkQL\RethinkInterface;
11
use TBolier\RethinkQL\Types\Term\TermType;
12
13
class Group extends AbstractQuery
14
{
15
    use TransformationTrait;
16
    use OperationTrait;
17
    use AggregationTrait;
18
19
    /**
20
     * @var string
21
     */
22
    private $key;
23
24
    /**
25
     * @var QueryInterface
26
     */
27
    private $query;
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
    public function toArray(): array
42
    {
43
        return [
44
            TermType::GROUP,
45
            [
46
                $this->query->toArray(),
47
                $this->key,
48
            ],
49
        ];
50
    }
51
}
52