66
77class Condition
88{
9-
109 /**
11- * PDO Connection
10+ * PDO Connection.
1211 *
1312 * @var Connection
1413 */
@@ -20,21 +19,21 @@ class Condition
2019 protected $ quoter ;
2120
2221 /**
23- * PDO Connection
22+ * PDO Connection.
2423 *
2524 * @var QueryInterface
2625 */
2726 protected $ query ;
2827
2928 /**
30- * Where clause
29+ * Where clause.
3130 *
3231 * @var array
3332 */
3433 protected $ where = [];
3534
3635 /**
37- * Having clause
36+ * Having clause.
3837 *
3938 * @var array
4039 */
@@ -57,6 +56,7 @@ public function __construct(Connection $pdo, QueryInterface $query)
5756 * Get sql.
5857 *
5958 * @param array $sql
59+ *
6060 * @return array
6161 */
6262 public function getWhereSql (array $ sql ): array
@@ -70,6 +70,7 @@ public function getWhereSql(array $sql): array
7070 * @param array $sql
7171 * @param array $where
7272 * @param string $conditionType
73+ *
7374 * @return array
7475 */
7576 public function getConditionSql (array $ sql , array $ where , string $ conditionType ): array
@@ -82,7 +83,7 @@ public function getConditionSql(array $sql, array $where, string $conditionType)
8283 $ sql [] = $ item ->getValue ();
8384 continue ;
8485 }
85- list ( $ type , $ conditions) = $ item ;
86+ [ $ type , $ conditions] = $ item ;
8687 if (!$ index ) {
8788 $ whereType = $ conditionType ;
8889 } else {
@@ -92,9 +93,9 @@ public function getConditionSql(array $sql, array $where, string $conditionType)
9293 $ sql [] = $ whereType . ' ' . $ conditions [0 ]->getValue ();
9394 continue ;
9495 }
95- list ( $ leftField , $ operator , $ rightField) = $ conditions ;
96+ [ $ leftField , $ operator , $ rightField] = $ conditions ;
9697 $ leftField = $ this ->quoter ->quoteName ($ leftField );
97- list ( $ rightField , $ operator) = $ this ->getRightFieldValue ($ rightField , $ operator );
98+ [ $ rightField , $ operator] = $ this ->getRightFieldValue ($ rightField , $ operator );
9899
99100 $ sql [] = sprintf ('%s %s %s %s ' , $ whereType , $ leftField , $ operator , $ rightField );
100101 }
@@ -103,12 +104,13 @@ public function getConditionSql(array $sql, array $where, string $conditionType)
103104 }
104105
105106 /**
106- * Comparison Functions and Operators
107+ * Comparison Functions and Operators.
107108 *
108109 * https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html
109110 *
110111 * @param mixed $rightField
111112 * @param mixed $comparison
113+ *
112114 * @return array
113115 */
114116 protected function getRightFieldValue ($ rightField , $ comparison ): array
@@ -141,6 +143,7 @@ protected function getRightFieldValue($rightField, $comparison): array
141143 * Get sql.
142144 *
143145 * @param array $sql
146+ *
144147 * @return array
145148 */
146149 public function getHavingSql (array $ sql ): array
@@ -154,6 +157,7 @@ public function getHavingSql(array $sql): array
154157 * @param array ...$conditions (field, comparison, value)
155158 * or (field, comparison, new RawExp('table.field'))
156159 * or new RawExp('...')
160+ *
157161 * @return self
158162 */
159163 public function where ($ conditions ): self
@@ -171,9 +175,10 @@ public function where($conditions): self
171175 /**
172176 * Adds to a clause through a closure, enclosing within parentheses.
173177 *
174- * @param string $clause The clause to work with, typically 'where' or 'having'.
175- * @param string $andor Add the condition using this operator, typically 'AND' or 'OR'.
176- * @param callable $closure The closure that adds to the clause.
178+ * @param string $clause the clause to work with, typically 'where' or 'having'
179+ * @param string $andor add the condition using this operator, typically 'AND' or 'OR'
180+ * @param callable $closure the closure that adds to the clause
181+ *
177182 * @return void
178183 */
179184 protected function addClauseCondClosure ($ clause , $ andor , $ closure )
@@ -196,9 +201,9 @@ protected function addClauseCondClosure($clause, $andor, $closure)
196201 // append an opening parenthesis to the prior set of conditions,
197202 // with AND/OR as needed ...
198203 if ($ set ) {
199- $ set [] = new RawExp (strtoupper ($ andor ) . " ( " );
204+ $ set [] = new RawExp (strtoupper ($ andor ) . ' ( ' );
200205 } else {
201- $ set [] = new RawExp (" ( " );
206+ $ set [] = new RawExp (' ( ' );
202207 }
203208
204209 // append the new conditions to the set, with indenting
@@ -207,7 +212,7 @@ protected function addClauseCondClosure($clause, $andor, $closure)
207212 foreach ($ sql as $ cond ) {
208213 $ set [] = new RawExp ($ cond );
209214 }
210- $ set [] = new RawExp (" ) " );
215+ $ set [] = new RawExp (' ) ' );
211216
212217 // ... then put the full set of conditions back into $this->$clause
213218 $ this ->$ clause = $ set ;
@@ -221,6 +226,7 @@ protected function addClauseCondClosure($clause, $andor, $closure)
221226 * @param array ...$conditions (field, comparison, value)
222227 * or (field, comparison, new RawExp('table.field'))
223228 * or new RawExp('...')
229+ *
224230 * @return self
225231 */
226232 public function orWhere ($ conditions ): self
@@ -241,6 +247,7 @@ public function orWhere($conditions): self
241247 * @param array ...$conditions (field, comparison, value)
242248 * or (field, comparison, new RawExp('table.field'))
243249 * or new RawExp('...')
250+ *
244251 * @return self
245252 */
246253 public function having ($ conditions ): self
@@ -261,6 +268,7 @@ public function having($conditions): self
261268 * @param array ...$conditions (field, comparison, value)
262269 * or (field, comparison, new RawExp('table.field'))
263270 * or new RawExp('...')
271+ *
264272 * @return self
265273 */
266274 public function orHaving ($ conditions ): self
0 commit comments