Completed
Push — master ( edd149...e1a63f )
by Sander
02:39
created

NestedMeta::orWhere()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sanderdekroon\Parlant\Builder;
4
5
class NestedMeta
6
{
7
8
    protected $query = [];
9
    protected $relation;
10
11
    public function where($column, $operator = null, $value = null, $type = null, $relation = null, $level = 2)
12
    {
13
        if (func_num_args() == 2 || is_null($value)) {
14
            $value = $operator;
15
            $operator = '=';
16
        }
17
18
        $this->setQuery(compact(
19
            'column',
20
            'value',
21
            'operator',
22
            'type',
23
            'level'
24
        ));
25
26
        if (!empty($relation)) {
27
            $this->setRelation($relation);
28
        }
29
30
        return $this;
31
    }
32
33
34
    public function orWhere(...$arguments)
35
    {
36
        $this->setRelation('OR');
37
        return $this->where(...$arguments);
0 ignored issues
show
Bug introduced by
$arguments is expanded, but the parameter $column of Sanderdekroon\Parlant\Builder\NestedMeta::where() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return $this->where(/** @scrutinizer ignore-type */ ...$arguments);
Loading history...
38
    }
39
40
41
    public function relation($relation)
42
    {
43
        $this->setRelation($relation);
44
        return $this;
45
    }
46
47
48
    protected function setQuery($query)
49
    {
50
        $this->query[] = $query;
51
    }
52
53
54
    public function getQuery()
55
    {
56
        return $this->query;
57
    }
58
59
60
    protected function setRelation($relation)
61
    {
62
        $this->relation = $relation;
63
    }
64
65
66
    public function getRelation()
67
    {
68
        return empty($this->relation) ? 'AND' : $this->relation;
69
    }
70
71
72
    public function replaceQuery($query)
73
    {
74
        $this->query = $query;
75
    }
76
}
77