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
03:38
created

FilterObject::getFieldName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
    const FIELD = 0;
12
13
    const OPERATOR = 1;
14
15
    private $rawFilter;
16
17
    private $fieldName;
18
19
    private $operatorName;
20
21
    private function __construct(string $rawFilter)
22
    {
23
        $this->setRawFilter($rawFilter);
24
25
        $explodedRawFilter = explode('|', $rawFilter);
26
        if (!isset($explodedRawFilter[self::OPERATOR])) {
27
            $explodedRawFilter[self::OPERATOR] = Dictionary::DEFAULT_OPERATOR;
28
        }
29
30
        $fieldName = $explodedRawFilter[self::FIELD];
31
        $parser = new StringParser();
32
        $this->fieldName = $parser->camelize($fieldName);
33
34
        $this->operatorName = $explodedRawFilter[self::OPERATOR];
35
    }
36
37
    public static function fromRawFilter(string $filter) : FilterObject
38
    {
39
        return new self($filter);
40
    }
41
42
    public function getFieldName() : string
43
    {
44
        return $this->fieldName;
45
    }
46
47
    public function getOperatorName() : string
48
    {
49
        return $this->operatorName;
50
    }
51
52
    public function isListType() : bool
53
    {
54
        return $this->getOperatorName() == 'list'
55
            || $this->getOperatorName() == 'nlist';
56
    }
57
58
    public function isFieldEqualityType()
59
    {
60
        return $this->getOperatorName() == 'field_eq';
61
    }
62
63
    public function getOperatorMeta() : string
64
    {
65
        return Dictionary::getOperators()[$this->getOperatorName()]['meta'];
66
    }
67
68
    public function haveOperatorSubstitutionPattern() : bool
69
    {
70
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
71
72
        return isset($operator['substitution_pattern']);
73
    }
74
75
    public function getOperatorsSubstitutionPattern() : string
76
    {
77
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
78
79
        return $operator['substitution_pattern'];
80
    }
81
82
    public function setRawFilter(string $rawFilter)
83
    {
84
        $this->rawFilter = $rawFilter;
85
    }
86
87
    public function getRawFilter() : string
88
    {
89
        return $this->rawFilter;
90
    }
91
92
    public function getOperator()
93
    {
94
        return $this->operatorName;
95
    }
96
}
97