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:19
created

WhereCondition::getCondition()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 16
nc 4
nop 0
dl 0
loc 21
ccs 16
cts 16
cp 1
crap 4
rs 9.0534
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
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 5
    public function setEntityAlias(string $entityAlias)
25
    {
26 5
        $this->entityAlias = $entityAlias;
27 5
    }
28
29 7
    public function setOperator(Operator $operator)
30
    {
31 7
        $this->operator = $operator;
32 7
    }
33
34 7
    public function setSalt(Salt $salt)
35
    {
36 7
        $this->salt = $salt;
37 7
    }
38
39 7
    public function setFiltering(FilteringObject $filtering)
40
    {
41 7
        $this->filtering = $filtering;
42 7
    }
43
44 3
    public function setValue(string $value)
45
    {
46 3
        $this->value = $value;
47 3
    }
48
49 7
    public function setFieldName(string $fieldName)
50
    {
51 7
        $this->fieldName = $fieldName;
52 7
    }
53
54 6
    private function isListOperator()
55
    {
56 6
        return $this->filtering->isListOperator();
57
    }
58
59 5
    public function getCondition()
60
    {
61 5
        if ($this->filtering->hasOperator()) {
62 4
            if ($this->isListOperator()) {
63 1
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
64 1
                    $this->operator->getMeta() . ' ' .
65 1
                    $this->getListFieldName();
66 3
            } else if ($this->filtering->isFieldEqualsOperator()) {
67 1
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
68 1
                    $this->operator->getMeta() . ' ' .
69 1
                    $this->entityAlias . '.' . $this->value;
70
            } else {
71 2
                return $this->entityAlias . '.' . $this->fieldName . ' ' .
72 2
                    $this->operator->getMeta() . ' ' .
73 2
                    $this->getFieldName();
74
            }
75
        }
76
77 1
        return $this->entityAlias . '.' . $this->fieldName . ' ' .
78 1
            $this->operator->getMeta() . ' ' .
79 1
            $this->getFieldName();
80
    }
81
82 2
    public function setRelationEntityAlias(string $relationEntityAlias)
83
    {
84 2
        $this->relationEntityAlias = $relationEntityAlias;
85 2
    }
86
87 2
    public function getEmbeddedCondition()
88
    {
89 2
        $fieldName = $this->isListOperator()
90 1
            ? $this->getListFieldName()
91 2
            : $this->getFieldName();
92
93 2
        return $this->relationEntityAlias . '.' . $this->fieldName .
94 2
            ' ' .  $this->operator->getMeta() .
95 2
            ' ' . $fieldName;
96
    }
97
98 6
    private function getFieldName()
99
    {
100 6
        return ':field_' . $this->fieldName . $this->salt->getSalt();
101
    }
102
103 2
    private function getListFieldName()
104
    {
105 2
        return '(' . $this->getFieldName() . ')';
106
    }
107
}
108