Update   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
c 1
b 0
f 0
dl 0
loc 36
rs 10
ccs 7
cts 7
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A toArray() 0 12 1
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 Update extends AbstractQuery
12
{
13
    /**
14
     * @var array
15
     */
16
    private $elements;
17
18
    /**
19
     * @var QueryInterface
20
     */
21
    private $query;
22
23
    public function __construct(
24
        RethinkInterface $rethink,
25
        QueryInterface $query,
26
        array $elements
27
    ) {
28
        parent::__construct($rethink);
29
30 1
        $this->query = $query;
31
        $this->elements = $elements;
32
        $this->rethink = $rethink;
33
    }
34
35
    public function toArray(): array
36 1
    {
37
        $jsonElements = json_encode($this->elements);
38 1
39 1
        return [
40 1
            TermType::UPDATE,
41 1
            [
42 1
                $this->query->toArray(),
43
                [
44
                    TermType::JSON,
45
                    [
46
                        $jsonElements
47 1
                    ],
48
                ],
49 1
            ],
50 1
        ];
51 1
    }
52
}
53