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

WhereCondition   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 96
ccs 47
cts 47
cp 1
rs 10
c 0
b 0
f 0
wmc 16

12 Methods

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