Passed
Push — master ( 43fcfe...3bc5dd )
by Marc
06:52
created

OperationTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 8
dl 0
loc 29
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 3 1
A update() 0 3 1
A getAll() 0 3 1
A filter() 0 7 2
A insert() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\Query\Operation;
5
6
use TBolier\RethinkQL\Query\Row;
7
use TBolier\RethinkQL\Query\QueryInterface;
8
9
trait OperationTrait
10
{
11
    public function delete(): QueryInterface
12
    {
13
        return new Delete($this->rethink, /** @scrutinizer ignore-type */ $this);
14
    }
15
16
    public function filter($value)
17
    {
18
        if ($value instanceof Row) {
19
            return new FilterByRow($this->rethink, /** @scrutinizer ignore-type */ $this, $value);
20
        }
21
22
        return new Filter($this->rethink, /** @scrutinizer ignore-type */ $this, $value);
23
    }
24
25
    public function getAll(...$keys): GetAll
26
    {
27
        return new GetAll($this->rethink, /** @scrutinizer ignore-type */ $this, $keys);
28
    }
29
30
    public function update(array $elements): QueryInterface
31
    {
32
        return new Update($this->rethink, /** @scrutinizer ignore-type */ $this, $elements);
33
    }
34
35
    public function insert(array $document): QueryInterface
36
    {
37
        return new Insert($this->rethink, /** @scrutinizer ignore-type */ $this, $document);
38
    }
39
}
40