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
02:31
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
final class FilterObject
9
{
10
    private $fieldName;
11
12
    private $operatorName;
13
14
    private function __construct(string $filter)
15
    {
16
        $explodedFilter = explode('|', $filter);
17
        if (!isset($explodedFilter[1])) {
18
            $explodedFilter[1] = 'eq';
19
        }
20
21
        $fieldName = $explodedFilter[0];
22
        $parser = new StringParser();
23
        $this->fieldName = $parser->camelize($fieldName);
24
25
        $this->operatorName = $explodedFilter[1];
26
    }
27
28
    public static function fromRawFilter(string $filter) : FilterObject
29
    {
30
        return new self($filter);
31
    }
32
33
    public function getFieldName() : string
34
    {
35
        return $this->fieldName;
36
    }
37
38
    public function getOperatorName() : string
39
    {
40
        return $this->operatorName;
41
    }
42
43
    public function isListType() : bool
44
    {
45
        return $this->getOperatorName() == 'list'
46
            || $this->getOperatorName() == 'nlist';
47
    }
48
49
    public function getOperatorMeta() : string
50
    {
51
        return Dictionary::getOperators()[$this->getOperatorName()]['meta'];
52
    }
53
54
    public function haveOperatorSubstitutionPattern() : bool
55
    {
56
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
57
58
        return isset($operator['substitution_pattern']);
59
    }
60
61
    public function getOperatorsSubstitutionPattern() : string
62
    {
63
        $operator = Dictionary::getOperators()[$this->getOperatorName()];
64
65
        return $operator['substitution_pattern'];
66
    }
67
}
68