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

RangeOrExistFilter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A query() 0 17 2
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