Passed
Push — feature/optimize ( 219eef...0e0305 )
by Fu
03:34
created

ParserSearchWhereTrait::parserSearchOrWhere()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Modules\Core\Traits\Criteria;
5
6
7
trait ParserSearchWhereTrait
8
{
9
    use ParserSearchAndClosureTrait;
10
    use ParserSearchAndRelationClosureTrait;
11
    use ParserSearchOrClosureTrait;
12
    use ParserSearchOrRelationClosureTrait;
13
14
    protected function parserSearchWhere($value, $relation, $field, $condition)
15
    {
16
17
        if ($this->isFirstField || $this->modelForceAndWhere) {
18
            $this->parserSearchAndWhere($value, $relation, $field, $condition);
19
        } else {
20
            $this->parserSearchOrWhere($value, $relation, $field, $condition);
21
        }
22
    }
23
24
    protected function parserSearchOrWhere($value, $relation, $field, $condition)
25
    {
26
        if (!is_null($value)) {
27
            if (!is_null($relation)) {
28
                $this->parserSearchOrRelationClosure($value, $relation, $field, $condition);
29
            } else {
30
                $this->parserSearchOrClosure($value, $field, $condition);
31
            }
32
        }
33
    }
34
35
    protected function parserSearchAndWhere($value, $relation, $field, $condition)
36
    {
37
        if (!is_null($value)) {
38
            if (!is_null($relation)) {
39
                $this->parserSearchAndRelationClosure($value, $relation, $field, $condition);
40
            } else {
41
                $this->parserSearchAndClosure($value, $field, $condition);
42
            }
43
            $this->isFirstField = false;
0 ignored issues
show
Bug Best Practice introduced by
The property isFirstField does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
        }
45
    }
46
}