Completed
Push — master ( 0942e9...be83ab )
by Sergey
49:43 queued 34:47
created

RangeOrExistFilter::query()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
namespace Isswp101\Persimmon\QueryBuilder\Filters;
4
5
class RangeOrExistFilter extends Filter
6
{
7
    protected $field;
8
9
    public function __construct($field, $values = null)
10
    {
11
        parent::__construct($values);
12
13
        $this->field = $field;
14
    }
15
16
    public function query($range)
17
    {
18
        if ($range === null) {
19
            $query = [
20
                'exists' => [
21
                    'field' => $this->field
22
                ]
23
            ];
24
        } else {
25
            $query = [
26
                'range' => [
27
                    $this->field => $range
28
                ]
29
            ];
30
        }
31
        return $query;
32
    }
33
}
34