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 (#38)
by Simone
04:01
created

FilteringObject   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 69
rs 10
c 0
b 0
f 0
ccs 27
cts 27
cp 1
wmc 12

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperator() 0 7 2
A getOperatorSign() 0 3 1
A hasOperator() 0 3 1
A fromFilter() 0 12 2
A __construct() 0 3 1
A getFieldName() 0 3 1
A is() 0 4 2
A isFieldEqualsOperator() 0 3 1
A isListOperator() 0 3 1
1
<?php
2
3
namespace Mado\QueryBundle\Objects;
4
5
use Mado\QueryBundle\Queries\QueryBuilderFactory;
6
use Mado\QueryBundle\Vocabulary\Operators;
7
8
class FilteringObject
9
{
10
    const INDEX_FIELD_NAME = 0;
11
12
    const INDEX_OPERATOR_NAME = 1;
13
14
    const KEY_FIELD_NAME = 'field_name';
15
16
    const KEY_OPERATOR = 'operator';
17
18
    private $properties;
19
20 8
    private function __construct(array $properties)
21
    {
22 8
        $this->properties = $properties;
23 8
    }
24
25 8
    public static function fromFilter(string $filter)
26
    {
27 8
        $filterAsArray = explode('|', $filter);
28
29 8
        $properties = [];
30 8
        $properties[FilteringObject::KEY_FIELD_NAME] = $filterAsArray[FilteringObject::INDEX_FIELD_NAME];
31
32 8
        if (isset($filterAsArray[FilteringObject::INDEX_OPERATOR_NAME])) {
33 4
            $properties[FilteringObject::KEY_OPERATOR] = $filterAsArray[FilteringObject::INDEX_OPERATOR_NAME];
34
        }
35
36 8
        return new self($properties);
37
    }
38
39 1
    public function getFieldName()
40
    {
41 1
        return $this->properties[FilteringObject::KEY_FIELD_NAME];
42
    }
43
44 4
    public function getOperator()
45
    {
46 4
        if (!isset($this->properties[FilteringObject::KEY_OPERATOR])) {
47 1
            return Operators::getDefaultOperator();
48
        }
49
50 3
        return $this->properties[FilteringObject::KEY_OPERATOR];
51
    }
52
53 5
    public function hasOperator()
54
    {
55 5
        return isset($this->properties[FilteringObject::KEY_OPERATOR]);
56
    }
57
58 1
    public function getOperatorSign()
59
    {
60 1
        return $this->getOperator()['meta'];
61
    }
62
63 1
    public function isListOperator() : bool
64
    {
65 1
        return $this->is('list');
66
    }
67
68 1
    public function isFieldEqualsOperator() : bool
69
    {
70 1
        return $this->is('field_eq');
71
    }
72
73 2
    private function is(string $operator) : bool
74
    {
75 2
        return $this->hasOperator() &&
76 2
            $operator == $this->getOperator();
77
    }
78
}
79