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 (#46)
by Simone
02:15
created

WhereCondition::isListOperator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Objects;
4
5
use Mado\QueryBundle\Objects\Operator;
6
use Mado\QueryBundle\Objects\Salt;
7
8
final class WhereCondition
9
{
10
    private $entityAlias;
11
12
    private $operator;
13
14
    private $salt;
15
16
    private $filtering;
17
18
    private $value;
19
20
    private $fieldName;
21
22
    private $relationEntityAlias;
23
24
    public function setEntityAlias(string $entityAlias)
25
    {
26
        $this->entityAlias = $entityAlias;
27
    }
28
29
    public function setOperator(Operator $operator)
30
    {
31
        $this->operator = $operator;
32
    }
33
34
    public function setSalt(Salt $salt)
35
    {
36
        $this->salt = $salt;
37
    }
38
39
    public function setFiltering(FilteringObject $filtering)
40
    {
41
        $this->filtering = $filtering;
42
    }
43
44
    public function setValue(string $value)
45
    {
46
        $this->value = $value;
47
    }
48
49
    public function setFieldName(string $fieldName)
50
    {
51
        $this->fieldName = $fieldName;
52
    }
53
54
    private function isListOperator()
55
    {
56
        return $this->filtering->isListOperator();
57
    }
58
59
    private function renderListCondition()
60
    {
61
        return $this->entityAlias . '.' . $this->fieldName . ' ' .
62
            $this->operator->getMeta() . ' ' .
63
            '(:field_' . $this->fieldName . $this->salt->getSalt() . ')';
64
    }
65
66
    public function getCondition()
67
    {
68
        if ($this->filtering->hasOperator()) {
69
            if ($this->isListOperator()) {
70
                return $this->renderListCondition();
71
            } else if ($this->filtering->isFieldEqualsOperator()) {
72
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
73
                    $this->operator->getMeta() . ' ' .
74
                    $this->entityAlias . '.' . $this->value;
75 View Code Duplication
            } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
77
                    $this->operator->getMeta() . ' ' .
78
                    ':field_' . $this->fieldName . $this->salt->getSalt();
79
            }
80 View Code Duplication
        } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
            return $this->entityAlias . '.' . $this->fieldName . ' ' .
82
                $this->operator->getMeta() . ' ' .
83
                ':field_' . $this->fieldName . $this->salt->getSalt();
84
        }
85
    }
86
87
    public function setRelationEntityAlias(string $relationEntityAlias)
88
    {
89
        $this->relationEntityAlias = $relationEntityAlias;
90
    }
91
92
    public function getEmbeddedCondition()
93
    {
94
        if ($this->isListOperator()) {
95
            return $this->renderListCondition();
96 View Code Duplication
        } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
            return $this->relationEntityAlias . '.' . $this->fieldName . ' ' .
98
                $this->operator->getMeta() . ' ' .
99
                ':field_' . $this->fieldName . $this->salt->getSalt();
100
        }
101
    }
102
103
    public function getFieldName()
104
    {
105
        return 'field_' . $this->fieldName . $this->salt->getSalt();
106
    }
107
}
108