@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * @return int |
12 | 12 | */ |
13 | - public function getId (); |
|
13 | + public function getId(); |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param DB $db |
23 | 23 | */ |
24 | - protected function __construct (DB $db) { |
|
24 | + protected function __construct(DB $db) { |
|
25 | 25 | $this->db = $db; |
26 | 26 | } |
27 | 27 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param array $args |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function __invoke (array $args = null) { |
|
34 | + public function __invoke(array $args = null) { |
|
35 | 35 | $this->execute($args); |
36 | 36 | return $this; |
37 | 37 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function __toString () { |
|
44 | + public function __toString() { |
|
45 | 45 | return $this->queryString; |
46 | 46 | } |
47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return bool |
55 | 55 | * @throws ArgumentCountError |
56 | 56 | */ |
57 | - public function execute ($args = null) { |
|
57 | + public function execute($args = null) { |
|
58 | 58 | $this->db->getLogger()->__invoke($this->queryString); |
59 | 59 | if ($result = !parent::execute($args)) { |
60 | 60 | $info = $this->errorInfo(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return int |
73 | 73 | */ |
74 | - public function getId (): int { |
|
74 | + public function getId(): int { |
|
75 | 75 | return (int)$this->db->lastInsertId(); |
76 | 76 | } |
77 | 77 | } |
@@ -31,8 +31,7 @@ |
||
31 | 31 | public static function fromInterface (DB $db, string $interface) { |
32 | 32 | try { |
33 | 33 | $ref = new ReflectionClass($interface); |
34 | - } |
|
35 | - catch (ReflectionException $exception) { |
|
34 | + } catch (ReflectionException $exception) { |
|
36 | 35 | throw new LogicException('Unexpected ReflectionException', 0, $exception); |
37 | 36 | } |
38 | 37 | $doc = $ref->getDocComment(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $interface |
32 | 32 | * @return Junction |
33 | 33 | */ |
34 | - public static function fromInterface (DB $db, string $interface) { |
|
34 | + public static function fromInterface(DB $db, string $interface) { |
|
35 | 35 | try { |
36 | 36 | $ref = new ReflectionClass($interface); |
37 | 37 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $table |
55 | 55 | * @param string[] $classes |
56 | 56 | */ |
57 | - public function __construct (DB $db, string $table, array $classes) { |
|
57 | + public function __construct(DB $db, string $table, array $classes) { |
|
58 | 58 | parent::__construct($db, $table, array_keys($classes)); |
59 | 59 | $this->classes = $classes; |
60 | 60 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param array $match Keyed by junction column. |
69 | 69 | * @return Select|EntityInterface[] |
70 | 70 | */ |
71 | - public function find (string $key, array $match = []) { |
|
71 | + public function find(string $key, array $match = []) { |
|
72 | 72 | $record = $this->db->getRecord($this->classes[$key]); |
73 | 73 | $select = $record->loadAll(); |
74 | 74 | $select->join($this, $this[$key]->isEqual($record['id'])); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param int[] $ids Keyed by column. |
85 | 85 | * @return int Rows affected. |
86 | 86 | */ |
87 | - public function link (array $ids): int { |
|
87 | + public function link(array $ids): int { |
|
88 | 88 | $statement = $this->cache(__FUNCTION__, function() { |
89 | 89 | $columns = implode(',', array_keys($this->columns)); |
90 | 90 | $slots = implode(',', SQL::slots(array_keys($this->columns))); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param array $ids Keyed by Column |
109 | 109 | * @return int Rows affected |
110 | 110 | */ |
111 | - public function unlink (array $ids): int { |
|
111 | + public function unlink(array $ids): int { |
|
112 | 112 | return $this->delete($ids); |
113 | 113 | } |
114 | 114 | } |
115 | 115 | \ No newline at end of file |
@@ -10,5 +10,5 @@ |
||
10 | 10 | /** |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public function __toString (); |
|
13 | + public function __toString(); |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -117,8 +117,7 @@ discard block |
||
117 | 117 | if ($table instanceof Select) { |
118 | 118 | $this->table = $table->toSubquery(); |
119 | 119 | $this->alias = uniqid('_') . "_{$table->alias}"; |
120 | - } |
|
121 | - else { |
|
120 | + } else { |
|
122 | 121 | $this->table = (string)$table; |
123 | 122 | $this->alias = uniqid('_') . "__{$table}"; |
124 | 123 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | public function group (string $column) { |
229 | 228 | if (!strlen($this->_group)) { |
230 | 229 | $this->_group = " GROUP BY {$column}"; |
231 | - } |
|
232 | - else { |
|
230 | + } else { |
|
233 | 231 | $this->_group .= ", {$column}"; |
234 | 232 | } |
235 | 233 | return $this; |
@@ -244,8 +242,7 @@ discard block |
||
244 | 242 | public function having (string $condition) { |
245 | 243 | if (!strlen($this->_having)) { |
246 | 244 | $this->_having = " HAVING {$condition}"; |
247 | - } |
|
248 | - else { |
|
245 | + } else { |
|
249 | 246 | $this->_having .= " AND {$condition}"; |
250 | 247 | } |
251 | 248 | return $this; |
@@ -264,8 +261,7 @@ discard block |
||
264 | 261 | $select->_limit = ''; |
265 | 262 | if ($all) { |
266 | 263 | $this->_import .= " INTERSECT ALL {$select->toSql()}"; |
267 | - } |
|
268 | - else { |
|
264 | + } else { |
|
269 | 265 | $this->_import .= " INTERSECT {$select->toSql()}"; |
270 | 266 | } |
271 | 267 | return $this; |
@@ -315,8 +311,7 @@ discard block |
||
315 | 311 | public function limit (int $limit, int $offset = 0) { |
316 | 312 | if ($limit == 0) { |
317 | 313 | $this->_limit = ''; |
318 | - } |
|
319 | - else { |
|
314 | + } else { |
|
320 | 315 | $this->_limit = " LIMIT {$limit}"; |
321 | 316 | if ($offset > 1) { |
322 | 317 | $this->_limit .= " OFFSET {$offset}"; |
@@ -389,8 +384,7 @@ discard block |
||
389 | 384 | $name = $match['name'] ?? null; |
390 | 385 | if (is_int($alias)) { |
391 | 386 | $alias = $name; |
392 | - } |
|
393 | - elseif ($alias !== $name) { |
|
387 | + } elseif ($alias !== $name) { |
|
394 | 388 | $expr .= " AS {$alias}"; |
395 | 389 | } |
396 | 390 | if (isset($alias)) { |
@@ -450,8 +444,7 @@ discard block |
||
450 | 444 | $select->_limit = ''; |
451 | 445 | if ($all) { |
452 | 446 | $this->_import .= " UNION ALL {$select->toSql()}"; |
453 | - } |
|
454 | - else { |
|
447 | + } else { |
|
455 | 448 | $this->_import .= " UNION {$select->toSql()}"; |
456 | 449 | } |
457 | 450 | return $this; |
@@ -466,8 +459,7 @@ discard block |
||
466 | 459 | public function where (string $condition) { |
467 | 460 | if (!strlen($this->_where)) { |
468 | 461 | $this->_where = " WHERE {$condition}"; |
469 | - } |
|
470 | - else { |
|
462 | + } else { |
|
471 | 463 | $this->_where .= " AND {$condition}"; |
472 | 464 | } |
473 | 465 | return $this; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string|Select $table |
117 | 117 | * @param string[] $columns |
118 | 118 | */ |
119 | - public function __construct (DB $db, $table, array $columns) { |
|
119 | + public function __construct(DB $db, $table, array $columns) { |
|
120 | 120 | parent::__construct($db); |
121 | 121 | if ($table instanceof Select) { |
122 | 122 | $this->table = $table->toSubquery(); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param array $args |
137 | 137 | * @return Statement |
138 | 138 | */ |
139 | - public function __invoke (array $args = []) { |
|
139 | + public function __invoke(array $args = []) { |
|
140 | 140 | return $this->execute($args); |
141 | 141 | } |
142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - final public function __toString () { |
|
148 | + final public function __toString() { |
|
149 | 149 | return $this->alias; |
150 | 150 | } |
151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param array $args Execution arguments. |
156 | 156 | * @return int |
157 | 157 | */ |
158 | - public function count (array $args = []): int { |
|
158 | + public function count(array $args = []): int { |
|
159 | 159 | $clone = clone $this; |
160 | 160 | $clone->_columns = 'COUNT(*)'; |
161 | 161 | $clone->_order = ''; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param array $args |
169 | 169 | * @return Statement |
170 | 170 | */ |
171 | - public function execute (array $args = []) { |
|
171 | + public function execute(array $args = []) { |
|
172 | 172 | if (empty($args)) { |
173 | 173 | return $this->db->query($this->toSql()); |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param array $args Execution arguments. |
184 | 184 | * @return array |
185 | 185 | */ |
186 | - public function getAll (array $args = []): array { |
|
186 | + public function getAll(array $args = []): array { |
|
187 | 187 | return iterator_to_array($this->fetcher->__invoke($this->execute($args))); |
188 | 188 | } |
189 | 189 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param array $args Execution arguments. |
197 | 197 | * @return Generator |
198 | 198 | */ |
199 | - public function getEach (array $args = []) { |
|
199 | + public function getEach(array $args = []) { |
|
200 | 200 | yield from $this->fetcher->__invoke($this->execute($args)); |
201 | 201 | } |
202 | 202 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param array $args |
209 | 209 | * @return mixed |
210 | 210 | */ |
211 | - public function getFirst (array $args = []) { |
|
211 | + public function getFirst(array $args = []) { |
|
212 | 212 | return $this->getEach($args)->current(); |
213 | 213 | } |
214 | 214 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return Generator |
221 | 221 | */ |
222 | - public function getIterator () { |
|
222 | + public function getIterator() { |
|
223 | 223 | yield from $this->getEach(); |
224 | 224 | } |
225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return mixed |
231 | 231 | */ |
232 | - public function getResult (array $args = []) { |
|
232 | + public function getResult(array $args = []) { |
|
233 | 233 | return $this->execute($args)->fetchColumn(); |
234 | 234 | } |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param string $column |
240 | 240 | * @return $this |
241 | 241 | */ |
242 | - public function group (string $column) { |
|
242 | + public function group(string $column) { |
|
243 | 243 | if (!strlen($this->_group)) { |
244 | 244 | $this->_group = " GROUP BY {$column}"; |
245 | 245 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @param string $condition |
256 | 256 | * @return $this |
257 | 257 | */ |
258 | - public function having (string $condition) { |
|
258 | + public function having(string $condition) { |
|
259 | 259 | if (!strlen($this->_having)) { |
260 | 260 | $this->_having = " HAVING {$condition}"; |
261 | 261 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param bool $all |
273 | 273 | * @return $this |
274 | 274 | */ |
275 | - public function intersect (Select $select, $all = false) { |
|
275 | + public function intersect(Select $select, $all = false) { |
|
276 | 276 | $select = clone $select; |
277 | 277 | $select->_order = ''; |
278 | 278 | $select->_limit = ''; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return Predicate |
292 | 292 | */ |
293 | - public function isEmpty () { |
|
293 | + public function isEmpty() { |
|
294 | 294 | return Predicate::factory($this->db, "NOT EXISTS ({$this->toSql()})"); |
295 | 295 | } |
296 | 296 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return Predicate |
301 | 301 | */ |
302 | - public function isNotEmpty () { |
|
302 | + public function isNotEmpty() { |
|
303 | 303 | return Predicate::factory($this->db, "EXISTS ({$this->toSql()})"); |
304 | 304 | } |
305 | 305 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param string $type |
312 | 312 | * @return $this |
313 | 313 | */ |
314 | - public function join ($table, string $condition, string $type = 'INNER') { |
|
314 | + public function join($table, string $condition, string $type = 'INNER') { |
|
315 | 315 | if ($table instanceof Select) { |
316 | 316 | $table = $table->toSubquery(); |
317 | 317 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param int $offset |
327 | 327 | * @return $this |
328 | 328 | */ |
329 | - public function limit (int $limit, int $offset = 0) { |
|
329 | + public function limit(int $limit, int $offset = 0) { |
|
330 | 330 | if ($limit == 0) { |
331 | 331 | $this->_limit = ''; |
332 | 332 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param int|string $ref Ordinal or reference name. |
346 | 346 | * @return null|Column |
347 | 347 | */ |
348 | - public function offsetGet ($ref) { |
|
348 | + public function offsetGet($ref) { |
|
349 | 349 | if (is_int($ref)) { |
350 | 350 | return current(array_slice($this->refs, $ref, 1)) ?: null; |
351 | 351 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param string $order |
359 | 359 | * @return $this |
360 | 360 | */ |
361 | - public function order (string $order) { |
|
361 | + public function order(string $order) { |
|
362 | 362 | if (strlen($order)) { |
363 | 363 | $order = " ORDER BY {$order}"; |
364 | 364 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * @return Statement |
371 | 371 | */ |
372 | - public function prepare () { |
|
372 | + public function prepare() { |
|
373 | 373 | return $this->db->prepare($this->toSql()); |
374 | 374 | } |
375 | 375 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param string $alias |
378 | 378 | * @return $this |
379 | 379 | */ |
380 | - public function setAlias (string $alias) { |
|
380 | + public function setAlias(string $alias) { |
|
381 | 381 | $this->alias = $alias; |
382 | 382 | foreach ($this->refs as $k => $column) { |
383 | 383 | $this->refs[$k] = $column->setQualifier($alias); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @param string[] $expressions Keyed by alias if applicable. |
396 | 396 | * @return $this |
397 | 397 | */ |
398 | - public function setColumns (array $expressions) { |
|
398 | + public function setColumns(array $expressions) { |
|
399 | 399 | $this->refs = []; |
400 | 400 | $_columns = []; |
401 | 401 | foreach ($expressions as $alias => $expr) { |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @param Closure $fetcher |
421 | 421 | * @return $this |
422 | 422 | */ |
423 | - public function setFetcher (Closure $fetcher) { |
|
423 | + public function setFetcher(Closure $fetcher) { |
|
424 | 424 | $this->fetcher = $fetcher; |
425 | 425 | return $this; |
426 | 426 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - public function toSql (): string { |
|
433 | + public function toSql(): string { |
|
434 | 434 | $sql = "SELECT {$this->_columns} FROM {$this->table}"; |
435 | 435 | $sql .= $this->_join; |
436 | 436 | $sql .= $this->_where; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * |
448 | 448 | * @return string |
449 | 449 | */ |
450 | - public function toSubquery (): string { |
|
450 | + public function toSubquery(): string { |
|
451 | 451 | return "({$this->toSql()}) AS {$this->alias}"; |
452 | 452 | } |
453 | 453 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @param bool $all |
459 | 459 | * @return $this |
460 | 460 | */ |
461 | - public function union (Select $select, $all = false) { |
|
461 | + public function union(Select $select, $all = false) { |
|
462 | 462 | $select = clone $select; |
463 | 463 | $select->_order = ''; |
464 | 464 | $select->_limit = ''; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param string $condition |
478 | 478 | * @return $this |
479 | 479 | */ |
480 | - public function where (string $condition) { |
|
480 | + public function where(string $condition) { |
|
481 | 481 | if (!strlen($this->_where)) { |
482 | 482 | $this->_where = " WHERE {$condition}"; |
483 | 483 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function getAttributes (): array { |
|
33 | + public function getAttributes(): array { |
|
34 | 34 | return $this->attributes ?? []; |
35 | 35 | } |
36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param mixed $attr |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | - public function offsetExists ($attr): bool { |
|
41 | + public function offsetExists($attr): bool { |
|
42 | 42 | return isset($this->attributes) and array_key_exists($attr, $this->attributes); |
43 | 43 | } |
44 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param mixed $attr |
47 | 47 | * @return null|mixed |
48 | 48 | */ |
49 | - public function offsetGet ($attr) { |
|
49 | + public function offsetGet($attr) { |
|
50 | 50 | return $this->attributes[$attr] ?? null; |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param mixed $attr |
55 | 55 | * @param mixed $value |
56 | 56 | */ |
57 | - public function offsetSet ($attr, $value): void { |
|
57 | + public function offsetSet($attr, $value): void { |
|
58 | 58 | if (isset($attr)) { |
59 | 59 | $this->attributes[$attr] = $value; |
60 | 60 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @param mixed $attr |
68 | 68 | */ |
69 | - public function offsetUnset ($attr): void { |
|
69 | + public function offsetUnset($attr): void { |
|
70 | 70 | unset($this->attributes[$attr]); |
71 | 71 | } |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param array $attributes |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function setAttributes (array $attributes) { |
|
77 | + public function setAttributes(array $attributes) { |
|
78 | 78 | $this->attributes = $attributes; |
79 | 79 | return $this; |
80 | 80 | } |
@@ -57,8 +57,7 @@ |
||
57 | 57 | public function offsetSet ($attr, $value): void { |
58 | 58 | if (isset($attr)) { |
59 | 59 | $this->attributes[$attr] = $value; |
60 | - } |
|
61 | - else { |
|
60 | + } else { |
|
62 | 61 | $this->attributes[] = $value; |
63 | 62 | } |
64 | 63 | } |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - abstract public function __toString (); |
|
19 | + abstract public function __toString(); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param int|string $column |
23 | 23 | * @return null|Column |
24 | 24 | */ |
25 | - abstract public function offsetGet ($column); |
|
25 | + abstract public function offsetGet($column); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var DB |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param DB $db |
34 | 34 | */ |
35 | - public function __construct (DB $db) { |
|
35 | + public function __construct(DB $db) { |
|
36 | 36 | $this->db = $db; |
37 | 37 | } |
38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param int|string $column |
41 | 41 | * @return bool |
42 | 42 | */ |
43 | - public function offsetExists ($column): bool { |
|
43 | + public function offsetExists($column): bool { |
|
44 | 44 | return $this->offsetGet($column) !== null; |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param void $value |
52 | 52 | * @throws Exception |
53 | 53 | */ |
54 | - final public function offsetSet ($offset, $value): void { |
|
54 | + final public function offsetSet($offset, $value): void { |
|
55 | 55 | throw new Exception('Tables are immutable.'); |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param void $name |
62 | 62 | * @throws Exception |
63 | 63 | */ |
64 | - final public function offsetUnset ($name): void { |
|
64 | + final public function offsetUnset($name): void { |
|
65 | 65 | $this->offsetSet($name, null); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -64,8 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | if ($arg === null or is_bool($arg)) { |
66 | 66 | $arg = ['' => 'NULL', 1 => 'TRUE', 0 => 'FALSE'][$arg]; |
67 | - } |
|
68 | - else { |
|
67 | + } else { |
|
69 | 68 | $arg = $this->db->quote($arg); |
70 | 69 | } |
71 | 70 | if ($this->db->isMySQL()) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param null|scalar|Select $arg |
26 | 26 | * @return Predicate |
27 | 27 | */ |
28 | - public function is ($arg): Predicate { |
|
28 | + public function is($arg): Predicate { |
|
29 | 29 | if ($arg instanceof Select) { |
30 | 30 | if ($this->db->isSQLite()) { |
31 | 31 | return Select::factory($this->db, $arg, [$arg[0]]) |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param number $max |
54 | 54 | * @return Predicate |
55 | 55 | */ |
56 | - public function isBetween ($min, $max) { |
|
56 | + public function isBetween($min, $max) { |
|
57 | 57 | $min = $this->db->quote($min); |
58 | 58 | $max = $this->db->quote($max); |
59 | 59 | return Predicate::factory($this->db, "{$this} BETWEEN {$min} AND {$max}"); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param scalar|array|Select $arg |
66 | 66 | * @return Predicate |
67 | 67 | */ |
68 | - public function isEqual ($arg) { |
|
68 | + public function isEqual($arg) { |
|
69 | 69 | return $this->db->match($this, $arg); |
70 | 70 | } |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return Predicate |
76 | 76 | */ |
77 | - public function isFalse () { |
|
77 | + public function isFalse() { |
|
78 | 78 | return Predicate::factory($this->db, "{$this} IS FALSE"); |
79 | 79 | } |
80 | 80 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $multi `ALL|ANY` |
91 | 91 | * @return Predicate |
92 | 92 | */ |
93 | - public function isGreater ($arg, string $multi = 'ALL') { |
|
93 | + public function isGreater($arg, string $multi = 'ALL') { |
|
94 | 94 | if ($arg instanceof Select) { |
95 | 95 | if ($this->db->isSQLite()) { |
96 | 96 | $sub = Select::factory($this->db, $arg, [$arg[0]]); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $multi `ALL|ANY` |
117 | 117 | * @return Predicate |
118 | 118 | */ |
119 | - public function isGreaterOrEqual ($arg, string $multi = 'ALL') { |
|
119 | + public function isGreaterOrEqual($arg, string $multi = 'ALL') { |
|
120 | 120 | if ($arg instanceof Select) { |
121 | 121 | if ($this->db->isSQLite()) { |
122 | 122 | $sub = Select::factory($this->db, $arg, [$arg[0]]); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $multi `ALL|ANY` |
143 | 143 | * @return Predicate |
144 | 144 | */ |
145 | - public function isLess ($arg, string $multi = 'ALL') { |
|
145 | + public function isLess($arg, string $multi = 'ALL') { |
|
146 | 146 | if ($arg instanceof Select) { |
147 | 147 | if ($this->db->isSQLite()) { |
148 | 148 | $sub = Select::factory($this->db, $arg, [$arg[0]]); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param string $multi `ALL|ANY` |
169 | 169 | * @return Predicate |
170 | 170 | */ |
171 | - public function isLessOrEqual ($arg, string $multi = 'ALL') { |
|
171 | + public function isLessOrEqual($arg, string $multi = 'ALL') { |
|
172 | 172 | if ($arg instanceof Select) { |
173 | 173 | if ($this->db->isSQLite()) { |
174 | 174 | $sub = Select::factory($this->db, $arg, [$arg[0]]); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param string $pattern |
189 | 189 | * @return Predicate |
190 | 190 | */ |
191 | - public function isLike (string $pattern) { |
|
191 | + public function isLike(string $pattern) { |
|
192 | 192 | $pattern = $this->db->quote($pattern); |
193 | 193 | return Predicate::factory($this->db, "{$this} LIKE {$pattern}"); |
194 | 194 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param null|scalar|Select $arg |
200 | 200 | * @return Predicate |
201 | 201 | */ |
202 | - public function isNot ($arg) { |
|
202 | + public function isNot($arg) { |
|
203 | 203 | return $this->is($arg)->not(); |
204 | 204 | } |
205 | 205 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param number $max |
211 | 211 | * @return Predicate |
212 | 212 | */ |
213 | - public function isNotBetween ($min, $max) { |
|
213 | + public function isNotBetween($min, $max) { |
|
214 | 214 | $min = $this->db->quote($min); |
215 | 215 | $max = $this->db->quote($max); |
216 | 216 | return Predicate::factory($this->db, "{$this} NOT BETWEEN {$min} AND {$max}"); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param scalar|array|Select $arg |
223 | 223 | * @return Predicate |
224 | 224 | */ |
225 | - public function isNotEqual ($arg) { |
|
225 | + public function isNotEqual($arg) { |
|
226 | 226 | if ($arg instanceof Select) { |
227 | 227 | return Predicate::factory($this->db, "{$this} NOT IN ({$arg->toSql()})"); |
228 | 228 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param string $pattern |
239 | 239 | * @return Predicate |
240 | 240 | */ |
241 | - public function isNotLike (string $pattern) { |
|
241 | + public function isNotLike(string $pattern) { |
|
242 | 242 | $pattern = $this->db->quote($pattern); |
243 | 243 | return Predicate::factory($this->db, "{$this} NOT LIKE {$pattern}"); |
244 | 244 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return Predicate |
250 | 250 | */ |
251 | - public function isNotNull () { |
|
251 | + public function isNotNull() { |
|
252 | 252 | return Predicate::factory($this->db, "{$this} IS NOT NULL"); |
253 | 253 | } |
254 | 254 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $pattern |
259 | 259 | * @return Predicate |
260 | 260 | */ |
261 | - public function isNotRegExp (string $pattern) { |
|
261 | + public function isNotRegExp(string $pattern) { |
|
262 | 262 | $pattern = $this->db->quote($pattern); |
263 | 263 | return Predicate::factory($this->db, "{$this} NOT REGEXP {$pattern}"); |
264 | 264 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return Predicate |
270 | 270 | */ |
271 | - public function isNull () { |
|
271 | + public function isNull() { |
|
272 | 272 | return Predicate::factory($this->db, "{$this} IS NULL"); |
273 | 273 | } |
274 | 274 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $pattern |
279 | 279 | * @return Predicate |
280 | 280 | */ |
281 | - public function isRegExp (string $pattern) { |
|
281 | + public function isRegExp(string $pattern) { |
|
282 | 282 | $pattern = $this->db->quote($pattern); |
283 | 283 | return Predicate::factory($this->db, "{$this} REGEXP {$pattern}"); |
284 | 284 | } |
@@ -85,8 +85,10 @@ |
||
85 | 85 | * @param string|ValueInterface $else |
86 | 86 | * @return $this |
87 | 87 | */ |
88 | - public function else ($else) { |
|
88 | + public function else { |
|
89 | + ($else) { |
|
89 | 90 | $this->else = isset($else) ? $this->db->quote($else) : null; |
91 | + } |
|
90 | 92 | return $this; |
91 | 93 | } |
92 | 94 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param null|string $subject |
60 | 60 | * @param array $values `[when => then]` for the subject. |
61 | 61 | */ |
62 | - public function __construct (DB $db, string $subject = null, array $values = []) { |
|
62 | + public function __construct(DB $db, string $subject = null, array $values = []) { |
|
63 | 63 | parent::__construct($db, ''); |
64 | 64 | $this->subject = $subject; |
65 | 65 | $this->whenValues($values); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function __toString (): string { |
|
71 | + public function __toString(): string { |
|
72 | 72 | $sql = 'CASE'; |
73 | 73 | if (isset($this->subject)) { |
74 | 74 | $sql .= " {$this->subject}"; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param string|ValueInterface $then |
100 | 100 | * @return $this |
101 | 101 | */ |
102 | - public function when ($expression, $then) { |
|
102 | + public function when($expression, $then) { |
|
103 | 103 | $this->values[$this->db->quote($expression)] = $this->db->quote($then); |
104 | 104 | return $this; |
105 | 105 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param array $values `[when => then]` |
114 | 114 | * @return $this |
115 | 115 | */ |
116 | - public function whenValues (array $values) { |
|
116 | + public function whenValues(array $values) { |
|
117 | 117 | foreach ($values as $when => $then) { |
118 | 118 | $this->when($when, $then); |
119 | 119 | } |