Changes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A toArray() 0 14 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query\Operation;
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 Changes extends AbstractQuery
12
{
13
    /**
14
     * @var array
15
     */
16
    private $options;
17
18
    /**
19
     * @var QueryInterface
20
     */
21
    private $query;
22
23
    public function __construct(
24
        RethinkInterface $rethink,
25
        QueryInterface $query,
26
        ?array $options
27
    ) {
28
        parent::__construct($rethink);
29
30
        $this->query = $query;
31
        $this->rethink = $rethink;
32
        $this->options = $options;
33
    }
34
35
    public function toArray(): array
36
    {
37
        $query = [
38
            TermType::CHANGES,
39
            [
40
                $this->query->toArray(),
41
            ],
42
        ];
43
44
        if (!empty($this->options)) {
45
            $query[] = $this->options;
46
        }
47
48
        return $query;
49
    }
50
}
51