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

WhereCondition::setRelationEntityAlias()   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 1
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
    public function getCondition()
60
    {
61
        if ($this->filtering->hasOperator()) {
62
            if ($this->isListOperator()) {
63
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
64
                    $this->operator->getMeta() . ' ' .
65
                    $this->getListFieldName();
66
            } else if ($this->filtering->isFieldEqualsOperator()) {
67
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
68
                    $this->operator->getMeta() . ' ' .
69
                    $this->entityAlias . '.' . $this->value;
70
            } else {
71
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
72
                    $this->operator->getMeta() . ' ' .
73
                    $this->getFieldName();
74
            }
75
        }
76
77
        return $this->entityAlias . '.' . $this->fieldName . ' ' .
78
            $this->operator->getMeta() . ' ' .
79
            $this->getFieldName();
80
    }
81
82
    public function setRelationEntityAlias(string $relationEntityAlias)
83
    {
84
        $this->relationEntityAlias = $relationEntityAlias;
85
    }
86
87
    public function getEmbeddedCondition()
88
    {
89
        $fieldName = $this->isListOperator()
90
            ? $this->getListFieldName()
91
            : $this->getFieldName();
92
93
        return $this->relationEntityAlias . '.' . $this->fieldName .
94
            ' ' .  $this->operator->getMeta() .
95
            ' ' . $fieldName;
96
    }
97
98
    private function getFieldName()
99
    {
100
        return ':field_' . $this->fieldName . $this->salt->getSalt();
101
    }
102
103
    private function getListFieldName()
104
    {
105
        return '(' . $this->getFieldName() . ')';
106
    }
107
}
108