Completed
Push — master ( fa521d...b54f87 )
by Beniamin
03:19
created

QueryClauses   B

Complexity

Total Complexity 16

Size/Duplication

Total Lines 206
Duplicated Lines 0 %

Coupling/Cohesion

Components 7
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 0 Features 3
Metric Value
wmc 16
c 6
b 0
f 3
lcom 7
cbo 0
dl 0
loc 206
ccs 40
cts 40
cp 1
rs 8.3333

16 Methods

Rating   Name   Duplication   Size   Complexity  
A addSelect() 0 6 1
A andWhere() 0 6 1
A andHaving() 0 6 1
A addOrderBy() 0 6 1
A addSet() 0 6 1
A addGroupBy() 0 6 1
A setLimit() 0 6 1
A addQueryHint() 0 6 1
A getSelectClauses() 0 4 1
A getWhereClauses() 0 4 1
A getOrderByClauses() 0 4 1
A getSetClauses() 0 4 1
A getGroupByClauses() 0 4 1
A getHavingClauses() 0 4 1
A getLimitClause() 0 4 1
A getQueryHints() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\QueryBuilder;
13
14
/**
15
 * @author Beniamin Jonatan Šimko <[email protected]>
16
 */
17
class QueryClauses
18
{
19
    const QUERY_SELECT = 1;
20
    const QUERY_UPDATE = 2;
21
22
    /**
23
     * @var array $selectClauses
24
     */
25
    private $selectClauses = [];
26
27
    /**
28
     * @var array $whereClauses
29
     */
30
    private $whereClauses = [];
31
32
    /**
33
     * @var array $orderByClauses
34
     */
35
    private $orderByClauses = [];
36
37
    /**
38
     * @var array $setClauses
39
     */
40
    private $setClauses = [];
41
42
    /**
43
     * @var array $groupByClauses
44
     */
45
    private $groupByClauses = [];
46
47
    /**
48
     * @var array $havingClauses
49
     */
50
    private $havingClauses = [];
51
52
    /**
53
     * @var string $limitClause
54
     */
55
    private $limitClause;
56
57
    /**
58
     * @var array $queryHints
59
     */
60
    private $queryHints = [];
61
62
    /**
63
     * @param string $clause
64
     *
65
     * @return $this
66
     */
67 22
    public function addSelect($clause)
68
    {
69 22
        $this->selectClauses[] = $clause;
70
71 22
        return $this;
72
    }
73
74
    /**
75
     * @param string $clause
76
     *
77
     * @return $this
78
     */
79 7
    public function andWhere($clause)
80
    {
81 7
        $this->whereClauses[] = $clause;
82
83 7
        return $this;
84
    }
85
86
    /**
87
     * @param string $clause
88
     *
89
     * @return $this
90
     */
91 1
    public function andHaving($clause)
92
    {
93 1
        $this->havingClauses[] = $clause;
94
95 1
        return $this;
96
    }
97
98
    /**
99
     * @param string $clause
100
     *
101
     * @return $this
102
     */
103 2
    public function addOrderBy($clause)
104
    {
105 2
        $this->orderByClauses[] = $clause;
106
107 2
        return $this;
108
    }
109
110
    /**
111
     * @param string $clause
112
     *
113
     * @return $this
114
     */
115 4
    public function addSet($clause)
116
    {
117 4
        $this->setClauses[] = $clause;
118
119 4
        return $this;
120
    }
121
122
    /**
123
     * @param string $clause
124
     *
125
     * @return $this
126
     */
127 3
    public function addGroupBy($clause)
128
    {
129 3
        $this->groupByClauses[] = $clause;
130
131 3
        return $this;
132
    }
133
134
    /**
135
     * @param string $clause
136
     *
137
     * @return $this
138
     */
139 2
    public function setLimit($clause)
140
    {
141 2
        $this->limitClause = $clause;
142
143 2
        return $this;
144
    }
145
146
    /**
147
     * @param int    $hint
148
     * @param mixed $value
149
     *
150
     * @return $this
151
     */
152 1
    public function addQueryHint($hint, $value = null)
153
    {
154 1
        $this->queryHints[$hint] = $value;
155
156 1
        return $this;
157
    }
158
159
    /**
160
     * @return array
161
     */
162 26
    public function getSelectClauses()
163
    {
164 26
        return $this->selectClauses;
165
    }
166
167
    /**
168
     * @return array
169
     */
170 26
    public function getWhereClauses()
171
    {
172 26
        return $this->whereClauses;
173
    }
174
175
    /**
176
     * @return array
177
     */
178 26
    public function getOrderByClauses()
179
    {
180 26
        return $this->orderByClauses;
181
    }
182
183
    /**
184
     * @return array
185
     */
186 4
    public function getSetClauses()
187
    {
188 4
        return $this->setClauses;
189
    }
190
191
    /**
192
     * @return array
193
     */
194 22
    public function getGroupByClauses()
195
    {
196 22
        return $this->groupByClauses;
197
    }
198
199
    /**
200
     * @return array
201
     */
202 22
    public function getHavingClauses()
203
    {
204 22
        return $this->havingClauses;
205
    }
206
207
    /**
208
     * @return string
209
     */
210 26
    public function getLimitClause()
211
    {
212 26
        return $this->limitClause;
213
    }
214
215
    /**
216
     * @return array
217
     */
218 4
    public function getQueryHints()
219
    {
220 4
        return $this->queryHints;
221
    }
222
}