GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — 2.4 (#173)
by Alessandro
06:43
created

FilterObject   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 19
eloc 37
dl 0
loc 112
ccs 46
cts 46
cp 1
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldName() 0 3 1
A getOperator() 0 3 1
A isNullType() 0 3 2
A getPosition() 0 3 1
A isListContainsType() 0 3 1
A getRawFilter() 0 3 1
A isFieldEqualityType() 0 3 1
A isListType() 0 4 2
A getOperatorMeta() 0 3 1
A __construct() 0 21 3
A getOperatorName() 0 3 1
A getOperatorsSubstitutionPattern() 0 5 1
A haveOperatorSubstitutionPattern() 0 5 1
A fromRawFilter() 0 3 1
A setRawFilter() 0 3 1
1
<?php
2
3
namespace Mado\QueryBundle\Queries\Objects;
4
5
use Mado\QueryBundle\Services\StringParser;
6
use Mado\QueryBundle\Dictionary;
7
8
/** @since class available since release 2.2 */
9
final class FilterObject
10
{
11
    const FIELD = 0;
12
13
    const OPERATOR = 1;
14
15
    const POSITION = 2;
16
17
    private $rawFilter;
18
19
    private $fieldName;
20
21
    private $operatorName;
22
23
    private $position;
24
25 26
    private function __construct(string $rawFilter)
26
    {
27 26
        $this->setRawFilter($rawFilter);
28
29 26
        $explodedRawFilter = explode('|', $rawFilter);
30 26
        if (!isset($explodedRawFilter[self::OPERATOR])) {
31 1
            $explodedRawFilter[self::OPERATOR] = Dictionary::DEFAULT_OPERATOR;
32
        }
33
34 26
        $fieldName = $explodedRawFilter[self::FIELD];
35 26
        $parser = new StringParser();
36 26
        $this->fieldName = $parser->camelize($fieldName);
37
38 26
        $this->operatorName = $explodedRawFilter[self::OPERATOR];
39
40 26
        $position = 0;
41 26
        if (isset($explodedRawFilter[self::POSITION])) {
42 2
            $position = $explodedRawFilter[self::POSITION];
43
        }
44
45 26
        $this->position = $position;
46 26
    }
47
48 26
    public static function fromRawFilter(string $filter) : FilterObject
49
    {
50 26
        return new self($filter);
51
    }
52
53 24
    public function getFieldName() : string
54
    {
55 24
        return $this->fieldName;
56
    }
57
58 24
    public function getOperatorName() : string
59
    {
60 24
        return $this->operatorName;
61
    }
62
63 23
    public function isListType() : bool
64
    {
65 23
        return $this->getOperatorName() == 'list'
66 23
            || $this->getOperatorName() == 'nlist';
67
    }
68
69 11
    public function isFieldEqualityType() : bool
70
    {
71 11
        return $this->getOperatorName() == 'field_eq';
72
    }
73
74 24
    public function getOperatorMeta() : string
75
    {
76 24
        return Dictionary::getOperators()[$this->getOperatorName()]['meta'];
77
    }
78
79 24
    public function haveOperatorSubstitutionPattern() : bool
80
    {
81 24
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
82
83 24
        return isset($operator['substitution_pattern']);
84
    }
85
86 4
    public function getOperatorsSubstitutionPattern() : string
87
    {
88 4
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
89
90 4
        return $operator['substitution_pattern'];
91
    }
92
93 26
    public function setRawFilter(string $rawFilter)
94
    {
95 26
        $this->rawFilter = $rawFilter;
96 26
    }
97
98 24
    public function getRawFilter() : string
99
    {
100 24
        return $this->rawFilter;
101
    }
102
103 2
    public function getOperator()
104
    {
105 2
        return $this->operatorName;
106
    }
107
108 24
    public function isNullType() : bool
109
    {
110 24
        return $this->getOperatorName() === 'isnull' || $this->getOperatorName() === 'isnotnull';
111
    }
112
113 13
    public function isListContainsType() : bool
114
    {
115 13
        return $this->getOperatorName() === 'listcontains';
116
    }
117
118 11
    public function getPosition()
119
    {
120 11
        return $this->position;
121
    }
122
}
123