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 — master (#75)
by Simone
122:05 queued 118:57
created

FilterObject   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 82
rs 10
c 0
b 0
f 0
wmc 14

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldName() 0 3 1
A getOperator() 0 3 1
A isFieldEqualityType() 0 3 1
A getRawFilter() 0 3 1
A isListType() 0 4 2
A getOperatorMeta() 0 3 1
A __construct() 0 14 2
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.1 */
9
final class FilterObject
10
{
11
    private $rawFilter;
12
13
    private $fieldName;
14
15
    private $operatorName;
16
17
    private function __construct(string $rawFilter)
18
    {
19
        $this->setRawFilter($rawFilter);
20
21
        $explodedFilter = explode('|', $rawFilter);
22
        if (!isset($explodedFilter[1])) {
23
            $explodedFilter[1] = 'eq';
24
        }
25
26
        $fieldName = $explodedFilter[0];
27
        $parser = new StringParser();
28
        $this->fieldName = $parser->camelize($fieldName);
29
30
        $this->operatorName = $explodedFilter[1];
31
    }
32
33
    public static function fromRawFilter(string $filter) : FilterObject
34
    {
35
        return new self($filter);
36
    }
37
38
    public function getFieldName() : string
39
    {
40
        return $this->fieldName;
41
    }
42
43
    public function getOperatorName() : string
44
    {
45
        return $this->operatorName;
46
    }
47
48
    public function isListType() : bool
49
    {
50
        return $this->getOperatorName() == 'list'
51
            || $this->getOperatorName() == 'nlist';
52
    }
53
54
    public function isFieldEqualityType()
55
    {
56
        return $this->getOperatorName() == 'field_eq';
57
    }
58
59
    public function getOperatorMeta() : string
60
    {
61
        return Dictionary::getOperators()[$this->getOperatorName()]['meta'];
62
    }
63
64
    public function haveOperatorSubstitutionPattern() : bool
65
    {
66
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
67
68
        return isset($operator['substitution_pattern']);
69
    }
70
71
    public function getOperatorsSubstitutionPattern() : string
72
    {
73
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
74
75
        return $operator['substitution_pattern'];
76
    }
77
78
    public function setRawFilter(string $rawFilter)
79
    {
80
        $this->rawFilter = $rawFilter;
81
    }
82
83
    public function getRawFilter() : string
84
    {
85
        return $this->rawFilter;
86
    }
87
88
    public function getOperator()
89
    {
90
        return $this->operatorName;
91
    }
92
}
93