NestedMeta   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 87.1%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 70
ccs 27
cts 31
cp 0.871
rs 10
c 0
b 0
f 0
wmc 12

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setRelation() 0 3 1
A replaceQuery() 0 3 1
A setQuery() 0 3 1
A relation() 0 4 1
A getQuery() 0 3 1
A getRelation() 0 3 2
A orWhere() 0 4 1
A where() 0 20 4
1
<?php
2
3
namespace Sanderdekroon\Parlant\Builder;
4
5
class NestedMeta
6
{
7
8
    protected $query = [];
9
    protected $relation;
10
11 1
    public function where($column, $operator = null, $value = null, $type = null, $relation = null, $level = 2)
12
    {
13 1
        if (func_num_args() == 2 || is_null($value)) {
14 1
            $value = $operator;
15 1
            $operator = '=';
16
        }
17
18 1
        $this->setQuery(compact(
19 1
            'column',
20 1
            'value',
21 1
            'operator',
22 1
            'type',
23 1
            'level'
24
        ));
25
26 1
        if (!empty($relation)) {
27
            $this->setRelation($relation);
28
        }
29
30 1
        return $this;
31
    }
32
33
34 1
    public function orWhere($column, $operator = null, $value = null, $type = null)
35
    {
36 1
        $this->setRelation('OR');
37 1
        return $this->where($column, $operator, $value, $type);
38
    }
39
40
41
    public function relation($relation)
42
    {
43
        $this->setRelation($relation);
44
        return $this;
45
    }
46
47
48 1
    protected function setQuery($query)
49
    {
50 1
        $this->query[] = $query;
51 1
    }
52
53
54 1
    public function getQuery()
55
    {
56 1
        return $this->query;
57
    }
58
59
60 1
    protected function setRelation($relation)
61
    {
62 1
        $this->relation = $relation;
63 1
    }
64
65
66 1
    public function getRelation()
67
    {
68 1
        return empty($this->relation) ? 'AND' : $this->relation;
69
    }
70
71
72 1
    public function replaceQuery($query)
73
    {
74 1
        $this->query = $query;
75 1
    }
76
}
77