Avg::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
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