Total Complexity | 12 |
Total Lines | 70 |
Duplicated Lines | 0 % |
Coverage | 87.1% |
Changes | 0 |
1 | <?php |
||
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) |
|
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) |
|
75 | 1 | } |
|
76 | } |
||
77 |