Avg   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 33
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\QueryInterface;
8
use TBolier\RethinkQL\RethinkInterface;
9
use TBolier\RethinkQL\Types\Term\TermType;
10
11
class Avg extends AbstractQuery
12
{
13
    use AggregationTrait;
14
15
    /**
16
     * @var string
17
     */
18
    private $key;
19
20
    /**
21
     * @var QueryInterface
22
     */
23
    private $query;
24
25
    public function __construct(
26
        RethinkInterface $rethink,
27
        QueryInterface $query,
28
        string $key
29
    ) {
30
        parent::__construct($rethink);
31
32
        $this->query = $query;
33
        $this->key = $key;
34
        $this->rethink = $rethink;
35
    }
36
37
    public function toArray(): array
38
    {
39
        return [
40
            TermType::AVG,
41
            [
42
                $this->query->toArray(),
43
                $this->key,
44
            ],
45
        ];
46
    }
47
}
48