@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | protected function verifyType(?string $type): void |
| 126 | 126 | { |
| 127 | 127 | $validTypes = [self::STRING, self::BOOL, self::FLOAT, self::INT, self::JSON, self::RAW]; |
| 128 | - if (null !== $type && !in_array($type, $validTypes, true)) { |
|
| 128 | + if (null !== $type && ! in_array($type, $validTypes, true)) { |
|
| 129 | 129 | throw new Exception("{$type} is not a valid type to use for Bindings.", 1); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function hasTypeDefined(): bool |
| 139 | 139 | { |
| 140 | - return !\in_array($this->type, [null, self::RAW], true); |
|
| 140 | + return ! \in_array($this->type, [null, self::RAW], true); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Preserve the first database connection with a static property |
| 67 | - if (!static::$storedConnection) { |
|
| 67 | + if ( ! static::$storedConnection) { |
|
| 68 | 68 | static::$storedConnection = $this; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function select(array $statements): array |
| 51 | 51 | { |
| 52 | - if (!array_key_exists('tables', $statements)) { |
|
| 52 | + if ( ! array_key_exists('tables', $statements)) { |
|
| 53 | 53 | throw new Exception('No table specified.', 3); |
| 54 | - } elseif (!array_key_exists('selects', $statements)) { |
|
| 54 | + } elseif ( ! array_key_exists('selects', $statements)) { |
|
| 55 | 55 | $statements['selects'][] = '*'; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | // Group bys |
| 66 | 66 | $groupBys = ''; |
| 67 | 67 | if (isset($statements['groupBys']) && $groupBys = $this->arrayStr($statements['groupBys'], ', ')) { |
| 68 | - $groupBys = 'GROUP BY ' . $groupBys; |
|
| 68 | + $groupBys = 'GROUP BY '.$groupBys; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Order bys |
@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | if ($field instanceof Closure) { |
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | - $orderBys .= $field . ' ' . $orderBy['type'] . ', '; |
|
| 79 | + $orderBys .= $field.' '.$orderBy['type'].', '; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if ($orderBys = trim($orderBys, ', ')) { |
| 83 | - $orderBys = 'ORDER BY ' . $orderBys; |
|
| 83 | + $orderBys = 'ORDER BY '.$orderBys; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Limit and offset |
| 88 | - $limit = isset($statements['limit']) ? 'LIMIT ' . (int) $statements['limit'] : ''; |
|
| 89 | - $offset = isset($statements['offset']) ? 'OFFSET ' . (int) $statements['offset'] : ''; |
|
| 88 | + $limit = isset($statements['limit']) ? 'LIMIT '.(int) $statements['limit'] : ''; |
|
| 89 | + $offset = isset($statements['offset']) ? 'OFFSET '.(int) $statements['offset'] : ''; |
|
| 90 | 90 | |
| 91 | 91 | // Having |
| 92 | 92 | list($havingCriteria, $havingBindings) = $this->buildCriteriaWithType($statements, 'havings', 'HAVING'); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | /** @var string[] */ |
| 98 | 98 | $sqlArray = [ |
| 99 | - 'SELECT' . (isset($statements['distinct']) ? ' DISTINCT' : ''), |
|
| 99 | + 'SELECT'.(isset($statements['distinct']) ? ' DISTINCT' : ''), |
|
| 100 | 100 | $selects, |
| 101 | 101 | 'FROM', |
| 102 | 102 | $tables, |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | public function criteriaOnly(array $statements, bool $bindValues = true): array |
| 131 | 131 | { |
| 132 | 132 | $sql = $bindings = []; |
| 133 | - if (!isset($statements['criteria'])) { |
|
| 133 | + if ( ! isset($statements['criteria'])) { |
|
| 134 | 134 | return compact('sql', 'bindings'); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | private function doInsert(array $statements, array $data, string $type): array |
| 154 | 154 | { |
| 155 | - if (!isset($statements['tables'])) { |
|
| 155 | + if ( ! isset($statements['tables'])) { |
|
| 156 | 156 | throw new Exception('No table specified', 3); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -173,20 +173,20 @@ discard block |
||
| 173 | 173 | if ($value instanceof Raw) { |
| 174 | 174 | $values[] = $this->parseRaw($value); |
| 175 | 175 | } elseif ($isBindings) { |
| 176 | - $values[] = $value->getType(); |
|
| 176 | + $values[] = $value->getType(); |
|
| 177 | 177 | $bindings[] = $value->getValue(); |
| 178 | 178 | } else { |
| 179 | - $values[] = $this->inferType($value); |
|
| 179 | + $values[] = $this->inferType($value); |
|
| 180 | 180 | $bindings[] = $value; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | $sqlArray = [ |
| 185 | - $type . ' INTO', |
|
| 185 | + $type.' INTO', |
|
| 186 | 186 | $this->wrapSanitizer($table), |
| 187 | - '(' . $this->arrayStr($keys, ',') . ')', |
|
| 187 | + '('.$this->arrayStr($keys, ',').')', |
|
| 188 | 188 | 'VALUES', |
| 189 | - '(' . $this->arrayStr($values, ',') . ')', |
|
| 189 | + '('.$this->arrayStr($values, ',').')', |
|
| 190 | 190 | ]; |
| 191 | 191 | |
| 192 | 192 | if (isset($statements['onduplicate'])) { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | throw new Exception('No data given.', 4); |
| 195 | 195 | } |
| 196 | 196 | list($updateStatement, $updateBindings) = $this->getUpdateStatement($statements['onduplicate']); |
| 197 | - $sqlArray[] = 'ON DUPLICATE KEY UPDATE ' . $updateStatement; |
|
| 197 | + $sqlArray[] = 'ON DUPLICATE KEY UPDATE '.$updateStatement; |
|
| 198 | 198 | $bindings = array_merge($bindings, $updateBindings); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if ($value instanceof Raw) { |
| 305 | - $statement .= $this->stringifyValue($this->wrapSanitizer($key)) . '=' . $value . ','; |
|
| 305 | + $statement .= $this->stringifyValue($this->wrapSanitizer($key)).'='.$value.','; |
|
| 306 | 306 | } elseif ($isBindings) { |
| 307 | - $statement .= $this->stringifyValue($this->wrapSanitizer($key)) . sprintf('=%s,', $value->getType()); |
|
| 307 | + $statement .= $this->stringifyValue($this->wrapSanitizer($key)).sprintf('=%s,', $value->getType()); |
|
| 308 | 308 | $bindings[] = $value->getValue(); |
| 309 | 309 | } else { |
| 310 | - $statement .= $this->stringifyValue($this->wrapSanitizer($key)) . sprintf('=%s,', $this->inferType($value)); |
|
| 310 | + $statement .= $this->stringifyValue($this->wrapSanitizer($key)).sprintf('=%s,', $this->inferType($value)); |
|
| 311 | 311 | $bindings[] = $value; |
| 312 | 312 | } |
| 313 | 313 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function update($statements, array $data) |
| 331 | 331 | { |
| 332 | - if (!isset($statements['tables'])) { |
|
| 332 | + if ( ! isset($statements['tables'])) { |
|
| 333 | 333 | throw new Exception('No table specified', 3); |
| 334 | 334 | } elseif (count($data) < 1) { |
| 335 | 335 | throw new Exception('No data given.', 4); |
@@ -344,12 +344,12 @@ discard block |
||
| 344 | 344 | list($whereCriteria, $whereBindings) = $this->buildCriteriaWithType($statements, 'wheres', 'WHERE'); |
| 345 | 345 | |
| 346 | 346 | // Limit |
| 347 | - $limit = isset($statements['limit']) ? 'LIMIT ' . $statements['limit'] : ''; |
|
| 347 | + $limit = isset($statements['limit']) ? 'LIMIT '.$statements['limit'] : ''; |
|
| 348 | 348 | |
| 349 | 349 | $sqlArray = [ |
| 350 | 350 | 'UPDATE', |
| 351 | 351 | $this->wrapSanitizer($table), |
| 352 | - 'SET ' . $updateStatement, |
|
| 352 | + 'SET '.$updateStatement, |
|
| 353 | 353 | $whereCriteria, |
| 354 | 354 | $limit, |
| 355 | 355 | ]; |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function delete($statements) |
| 374 | 374 | { |
| 375 | - if (!isset($statements['tables'])) { |
|
| 375 | + if ( ! isset($statements['tables'])) { |
|
| 376 | 376 | throw new Exception('No table specified', 3); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | list($whereCriteria, $whereBindings) = $this->buildCriteriaWithType($statements, 'wheres', 'WHERE'); |
| 388 | 388 | |
| 389 | 389 | // Limit |
| 390 | - $limit = isset($statements['limit']) ? 'LIMIT ' . $statements['limit'] : ''; |
|
| 390 | + $limit = isset($statements['limit']) ? 'LIMIT '.$statements['limit'] : ''; |
|
| 391 | 391 | |
| 392 | 392 | $sqlArray = ['DELETE FROM', $table, $whereCriteria]; |
| 393 | 393 | $sql = $this->concatenateQuery($sqlArray); |
@@ -409,11 +409,11 @@ discard block |
||
| 409 | 409 | { |
| 410 | 410 | $str = ''; |
| 411 | 411 | foreach ($pieces as $key => $piece) { |
| 412 | - if (!is_int($key)) { |
|
| 413 | - $piece = $key . ' AS ' . $piece; |
|
| 412 | + if ( ! is_int($key)) { |
|
| 413 | + $piece = $key.' AS '.$piece; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - $str .= $piece . $glue; |
|
| 416 | + $str .= $piece.$glue; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | return trim($str, $glue); |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | { |
| 431 | 431 | $str = ''; |
| 432 | 432 | foreach ($pieces as $piece) { |
| 433 | - $str = trim($str) . ' ' . trim($piece); |
|
| 433 | + $str = trim($str).' '.trim($piece); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | return trim($str); |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | public function getType($value): string |
| 446 | 446 | { |
| 447 | 447 | return $value instanceof Binding && $value->getType() !== null |
| 448 | - ? $value->getType() : $this->inferType($value) ; |
|
| 448 | + ? $value->getType() : $this->inferType($value); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | |
| 490 | 490 | $bindings = array_map([$this, 'getValue'], $bindings); |
| 491 | - $query = $this->connection->getDbInstance()->prepare($query, $bindings) ; |
|
| 491 | + $query = $this->connection->getDbInstance()->prepare($query, $bindings); |
|
| 492 | 492 | return is_string($query) ? $query : ''; |
| 493 | 493 | } |
| 494 | 494 | |
@@ -529,10 +529,10 @@ discard block |
||
| 529 | 529 | // Merge the bindings we get from nestedCriteria object |
| 530 | 530 | $bindings = array_merge($bindings, $queryObject->getBindings()); |
| 531 | 531 | // Append the sql we get from the nestedCriteria object |
| 532 | - $criteria .= $statement['joiner'] . ' (' . $queryObject->getSql() . ') '; |
|
| 532 | + $criteria .= $statement['joiner'].' ('.$queryObject->getSql().') '; |
|
| 533 | 533 | } elseif (is_array($value)) { |
| 534 | 534 | // where_in or between like query |
| 535 | - $criteria .= $statement['joiner'] . ' ' . $key . ' ' . $statement['operator']; |
|
| 535 | + $criteria .= $statement['joiner'].' '.$key.' '.$statement['operator']; |
|
| 536 | 536 | |
| 537 | 537 | switch ($statement['operator']) { |
| 538 | 538 | case 'BETWEEN': |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | $valuePlaceholder = trim($valuePlaceholder, ', '); |
| 568 | - $criteria .= ' (' . $valuePlaceholder . ') '; |
|
| 568 | + $criteria .= ' ('.$valuePlaceholder.') '; |
|
| 569 | 569 | break; |
| 570 | 570 | } |
| 571 | 571 | } elseif ($value instanceof Raw) { |
@@ -573,20 +573,20 @@ discard block |
||
| 573 | 573 | $criteria .= "{$statement['joiner']} {$key} {$statement['operator']} $value "; |
| 574 | 574 | } else { |
| 575 | 575 | // Usual where like criteria |
| 576 | - if (!$bindValues) { |
|
| 576 | + if ( ! $bindValues) { |
|
| 577 | 577 | // Specially for joins |
| 578 | 578 | // We are not binding values, lets sanitize then |
| 579 | 579 | $value = $this->stringifyValue($this->wrapSanitizer($value)) ?? ''; |
| 580 | - $criteria .= $statement['joiner'] . ' ' . $key . ' ' . $statement['operator'] . ' ' . $value . ' '; |
|
| 580 | + $criteria .= $statement['joiner'].' '.$key.' '.$statement['operator'].' '.$value.' '; |
|
| 581 | 581 | } elseif ($statement['key'] instanceof Raw) { |
| 582 | - $criteria .= $statement['joiner'] . ' ' . $key . ' '; |
|
| 582 | + $criteria .= $statement['joiner'].' '.$key.' '; |
|
| 583 | 583 | $bindings = array_merge($bindings, $statement['key']->getBindings()); |
| 584 | 584 | } else { |
| 585 | 585 | // For wheres |
| 586 | 586 | $bindings[] = $this->getValue($value); |
| 587 | 587 | |
| 588 | - $criteria .= $statement['joiner'] . ' ' . $key . ' ' . $statement['operator'] . ' ' |
|
| 589 | - . $this->getType($value) . ' '; |
|
| 588 | + $criteria .= $statement['joiner'].' '.$key.' '.$statement['operator'].' ' |
|
| 589 | + . $this->getType($value).' '; |
|
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | } |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | foreach ($valueArr as $key => $subValue) { |
| 643 | 643 | // Don't wrap if we have *, which is not a usual field |
| 644 | - $valueArr[$key] = '*' == trim($subValue) ? $subValue : $this->sanitizer . $subValue . $this->sanitizer; |
|
| 644 | + $valueArr[$key] = '*' == trim($subValue) ? $subValue : $this->sanitizer.$subValue.$this->sanitizer; |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | // Join these back with "." and return |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | list($criteria, $bindings) = $this->buildCriteria($statements[$key], $bindValues); |
| 669 | 669 | |
| 670 | 670 | if ($criteria) { |
| 671 | - $criteria = $type . ' ' . $criteria; |
|
| 671 | + $criteria = $type.' '.$criteria; |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | { |
| 687 | 687 | $sql = ''; |
| 688 | 688 | |
| 689 | - if (!array_key_exists('joins', $statements) || !is_array($statements['joins'])) { |
|
| 689 | + if ( ! array_key_exists('joins', $statements) || ! is_array($statements['joins'])) { |
|
| 690 | 690 | return $sql; |
| 691 | 691 | } |
| 692 | 692 | |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | if (is_array($joinArr['table'])) { |
| 695 | 695 | $mainTable = $this->stringifyValue($this->wrapSanitizer($joinArr['table'][0])); |
| 696 | 696 | $aliasTable = $this->stringifyValue($this->wrapSanitizer($joinArr['table'][1])); |
| 697 | - $table = $mainTable . ' AS ' . $aliasTable; |
|
| 697 | + $table = $mainTable.' AS '.$aliasTable; |
|
| 698 | 698 | } else { |
| 699 | 699 | $table = $joinArr['table'] instanceof Raw |
| 700 | 700 | ? $this->parseRaw($joinArr['table']) |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function __construct(string $sql, array $bindings, wpdb $dbInstance) |
| 30 | 30 | { |
| 31 | - $this->sql = (string)$sql; |
|
| 31 | + $this->sql = (string) $sql; |
|
| 32 | 32 | $this->bindings = $bindings; |
| 33 | 33 | $this->dbInstance = $dbInstance; |
| 34 | 34 | } |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct($value, $bindings = []) |
| 22 | 22 | { |
| 23 | - $this->value = (string)$value; |
|
| 24 | - $this->bindings = (array)$bindings; |
|
| 23 | + $this->value = (string) $value; |
|
| 24 | + $this->bindings = (array) $bindings; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -49,6 +49,6 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __toString() |
| 51 | 51 | { |
| 52 | - return (string)$this->value; |
|
| 52 | + return (string) $this->value; |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // Fire before events for :any table |
| 87 | 87 | if ($action = $this->getEvent($event, $table)) { |
| 88 | 88 | // Make an event id, with event type and table |
| 89 | - $eventId = $event . $table; |
|
| 89 | + $eventId = $event.$table; |
|
| 90 | 90 | |
| 91 | 91 | // Fire event |
| 92 | 92 | $handlerParams = func_get_args(); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | // Add to fired list |
| 95 | 95 | $this->firedEvents[] = $eventId; |
| 96 | 96 | $result = call_user_func_array($action, $handlerParams); |
| 97 | - if (!is_null($result)) { |
|
| 97 | + if ( ! is_null($result)) { |
|
| 98 | 98 | return $result; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -195,6 +195,6 @@ |
||
| 195 | 195 | { |
| 196 | 196 | return $underscore |
| 197 | 197 | ? "set_{$property}" |
| 198 | - : 'set' . ucfirst($property); |
|
| 198 | + : 'set'.ucfirst($property); |
|
| 199 | 199 | } |
| 200 | 200 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $start = microtime(true); |
| 202 | 202 | $sqlStatement = empty($bindings) ? $sql : $this->interpolateQuery($sql, $bindings); |
| 203 | 203 | |
| 204 | - if (!is_string($sqlStatement)) { |
|
| 204 | + if ( ! is_string($sqlStatement)) { |
|
| 205 | 205 | throw new Exception('Could not interpolate query', 1); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | public function get() |
| 219 | 219 | { |
| 220 | 220 | $eventResult = $this->fireEvents('before-select'); |
| 221 | - if (!is_null($eventResult)) { |
|
| 221 | + if ( ! is_null($eventResult)) { |
|
| 222 | 222 | return $eventResult; |
| 223 | 223 | } |
| 224 | 224 | $executionTime = 0; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->sqlStatement = null; |
| 244 | 244 | |
| 245 | 245 | // Ensure we have an array of results. |
| 246 | - if (!is_array($result) && null !== $result) { |
|
| 246 | + if ( ! is_array($result) && null !== $result) { |
|
| 247 | 247 | $result = [$result]; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | protected function useHydrator(): bool |
| 278 | 278 | { |
| 279 | - return !in_array($this->getFetchMode(), [\ARRAY_A, \ARRAY_N, \OBJECT, \OBJECT_K]); |
|
| 279 | + return ! in_array($this->getFetchMode(), [\ARRAY_A, \ARRAY_N, \OBJECT, \OBJECT_K]); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | ->select([$this->raw(sprintf('%s(%s) AS field', strtoupper($type), $field))]) |
| 367 | 367 | ->first(); |
| 368 | 368 | |
| 369 | - return true === isset($count->field) ? (float)$count->field : 0; |
|
| 369 | + return true === isset($count->field) ? (float) $count->field : 0; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function count(string $field = '*'): int |
| 384 | 384 | { |
| 385 | - return (int)$this->aggregate('count', $field); |
|
| 385 | + return (int) $this->aggregate('count', $field); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -460,8 +460,8 @@ discard block |
||
| 460 | 460 | public function getQuery(string $type = 'select', $dataToBePassed = []) |
| 461 | 461 | { |
| 462 | 462 | $allowedTypes = ['select', 'insert', 'insertignore', 'replace', 'delete', 'update', 'criteriaonly']; |
| 463 | - if (!in_array(strtolower($type), $allowedTypes)) { |
|
| 464 | - throw new Exception($type . ' is not a known type.', 2); |
|
| 463 | + if ( ! in_array(strtolower($type), $allowedTypes)) { |
|
| 464 | + throw new Exception($type.' is not a known type.', 2); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $queryArr = $this->adapterInstance->$type($this->statements, $dataToBePassed); |
@@ -480,9 +480,9 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | public function subQuery(QueryBuilderHandler $queryBuilder, ?string $alias = null) |
| 482 | 482 | { |
| 483 | - $sql = '(' . $queryBuilder->getQuery()->getRawSql() . ')'; |
|
| 483 | + $sql = '('.$queryBuilder->getQuery()->getRawSql().')'; |
|
| 484 | 484 | if (is_string($alias) && 0 !== mb_strlen($alias)) { |
| 485 | - $sql = $sql . ' as ' . $alias; |
|
| 485 | + $sql = $sql.' as '.$alias; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | return $queryBuilder->raw($sql); |
@@ -499,12 +499,12 @@ discard block |
||
| 499 | 499 | private function doInsert(array $data, string $type) |
| 500 | 500 | { |
| 501 | 501 | $eventResult = $this->fireEvents('before-insert'); |
| 502 | - if (!is_null($eventResult)) { |
|
| 502 | + if ( ! is_null($eventResult)) { |
|
| 503 | 503 | return $eventResult; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | // If first value is not an array () not a batch insert) |
| 507 | - if (!is_array(current($data))) { |
|
| 507 | + if ( ! is_array(current($data))) { |
|
| 508 | 508 | $queryObject = $this->getQuery($type, $data); |
| 509 | 509 | |
| 510 | 510 | list($preparedQuery, $executionTime) = $this->statement($queryObject->getSql(), $queryObject->getBindings()); |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | public function update($data) |
| 575 | 575 | { |
| 576 | 576 | $eventResult = $this->fireEvents('before-update'); |
| 577 | - if (!is_null($eventResult)) { |
|
| 577 | + if ( ! is_null($eventResult)) { |
|
| 578 | 578 | return $eventResult; |
| 579 | 579 | } |
| 580 | 580 | $queryObject = $this->getQuery('update', $data); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | public function delete(): int |
| 621 | 621 | { |
| 622 | 622 | $eventResult = $this->fireEvents('before-delete'); |
| 623 | - if (!is_null($eventResult)) { |
|
| 623 | + if ( ! is_null($eventResult)) { |
|
| 624 | 624 | return $eventResult; |
| 625 | 625 | } |
| 626 | 626 | |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | */ |
| 643 | 643 | public function table(...$tables): QueryBuilderHandler |
| 644 | 644 | { |
| 645 | - $instance = $this->constructCurrentBuilderClass($this->connection); |
|
| 645 | + $instance = $this->constructCurrentBuilderClass($this->connection); |
|
| 646 | 646 | $this->setFetchMode($this->getFetchMode(), $this->hydratorConstructorArgs); |
| 647 | 647 | $tables = $this->addTablePrefix($tables, false); |
| 648 | 648 | $instance->addStatement('tables', $tables); |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | */ |
| 671 | 671 | public function select($fields): self |
| 672 | 672 | { |
| 673 | - if (!is_array($fields)) { |
|
| 673 | + if ( ! is_array($fields)) { |
|
| 674 | 674 | $fields = func_get_args(); |
| 675 | 675 | } |
| 676 | 676 | |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | */ |
| 764 | 764 | public function orderBy($fields, string $defaultDirection = 'ASC'): self |
| 765 | 765 | { |
| 766 | - if (!is_array($fields)) { |
|
| 766 | + if ( ! is_array($fields)) { |
|
| 767 | 767 | $fields = [$fields]; |
| 768 | 768 | } |
| 769 | 769 | |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | $field = $value; |
| 775 | 775 | $type = $defaultDirection; |
| 776 | 776 | } |
| 777 | - if (!$field instanceof Raw) { |
|
| 777 | + if ( ! $field instanceof Raw) { |
|
| 778 | 778 | $field = $this->addTablePrefix($field); |
| 779 | 779 | } |
| 780 | 780 | $this->statements['orderBys'][] = compact('field', 'type'); |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | throw new Exception('Key used for whereNull condition must be a string or raw exrpession.', 1); |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - return $this->{$operator . 'Where'}($this->raw("{$key} IS{$prefix} NULL")); |
|
| 1117 | + return $this->{$operator.'Where'}($this->raw("{$key} IS{$prefix} NULL")); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | /** |
@@ -1166,8 +1166,8 @@ discard block |
||
| 1166 | 1166 | */ |
| 1167 | 1167 | public function join($table, $key, ?string $operator = null, $value = null, $type = 'inner') |
| 1168 | 1168 | { |
| 1169 | - if (!$key instanceof Closure) { |
|
| 1170 | - $key = function ($joinBuilder) use ($key, $operator, $value) { |
|
| 1169 | + if ( ! $key instanceof Closure) { |
|
| 1170 | + $key = function($joinBuilder) use ($key, $operator, $value) { |
|
| 1171 | 1171 | $joinBuilder->on($key, $operator, $value); |
| 1172 | 1172 | }; |
| 1173 | 1173 | } |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | */ |
| 1323 | 1323 | public function joinUsing(string $table, string $key, string $type = 'INNER'): self |
| 1324 | 1324 | { |
| 1325 | - if (!array_key_exists('tables', $this->statements) || count($this->statements['tables']) !== 1) { |
|
| 1325 | + if ( ! array_key_exists('tables', $this->statements) || count($this->statements['tables']) !== 1) { |
|
| 1326 | 1326 | throw new Exception("JoinUsing can only be used with a single table set as the base of the query", 1); |
| 1327 | 1327 | } |
| 1328 | 1328 | $baseTable = end($this->statements['tables']); |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | |
| 1412 | 1412 | // If supplied value is not an array then make it one |
| 1413 | 1413 | $single = false; |
| 1414 | - if (!is_array($values)) { |
|
| 1414 | + if ( ! is_array($values)) { |
|
| 1415 | 1415 | $values = [$values]; |
| 1416 | 1416 | // We had single value, so should return a single value |
| 1417 | 1417 | $single = true; |
@@ -1429,20 +1429,20 @@ discard block |
||
| 1429 | 1429 | // If key is not integer, it is likely a alias mapping, |
| 1430 | 1430 | // so we need to change prefix target |
| 1431 | 1431 | $target = &$value; |
| 1432 | - if (!is_int($key)) { |
|
| 1432 | + if ( ! is_int($key)) { |
|
| 1433 | 1433 | $target = &$key; |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | // Do prefix if the target is an expression or function. |
| 1437 | 1437 | if ( |
| 1438 | - !$tableFieldMix |
|
| 1438 | + ! $tableFieldMix |
|
| 1439 | 1439 | || ( |
| 1440 | 1440 | is_string($target) // Must be a string |
| 1441 | 1441 | && (bool) preg_match('/^[A-Za-z0-9_.]+$/', $target) // Can only contain letters, numbers, underscore and full stops |
| 1442 | 1442 | && 1 === \substr_count($target, '.') // Contains a single full stop ONLY. |
| 1443 | 1443 | ) |
| 1444 | 1444 | ) { |
| 1445 | - $target = $this->tablePrefix . $target; |
|
| 1445 | + $target = $this->tablePrefix.$target; |
|
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | $return[$key] = $value; |
@@ -1460,11 +1460,11 @@ discard block |
||
| 1460 | 1460 | */ |
| 1461 | 1461 | protected function addStatement($key, $value) |
| 1462 | 1462 | { |
| 1463 | - if (!is_array($value)) { |
|
| 1463 | + if ( ! is_array($value)) { |
|
| 1464 | 1464 | $value = [$value]; |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | - if (!array_key_exists($key, $this->statements)) { |
|
| 1467 | + if ( ! array_key_exists($key, $this->statements)) { |
|
| 1468 | 1468 | $this->statements[$key] = $value; |
| 1469 | 1469 | } else { |
| 1470 | 1470 | $this->statements[$key] = array_merge($this->statements[$key], $value); |