@@ -75,7 +75,7 @@ |
||
| 75 | 75 | */ |
| 76 | 76 | public function toJsonSelector(string $expression): JsonSelector |
| 77 | 77 | { |
| 78 | - if (! $this->isJsonSelector($expression)) { |
|
| 78 | + if ( ! $this->isJsonSelector($expression)) { |
|
| 79 | 79 | throw new Exception('JSON expression must contain at least 2 values, the table column and at least 1 node.', 1); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -38,12 +38,12 @@ |
||
| 38 | 38 | protected function normaliseNodes($nodes): string |
| 39 | 39 | { |
| 40 | 40 | // If its not an array, cast. |
| 41 | - if (!is_array($nodes)) { |
|
| 41 | + if ( ! is_array($nodes)) { |
|
| 42 | 42 | $nodes = [$nodes]; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Remove all none string. |
| 46 | - $nodes = array_filter($nodes, function ($node): bool { |
|
| 46 | + $nodes = array_filter($nodes, function($node): bool { |
|
| 47 | 47 | return is_string($node); |
| 48 | 48 | }); |
| 49 | 49 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $start = microtime(true); |
| 233 | 233 | $sqlStatement = empty($bindings) ? $sql : $this->interpolateQuery($sql, $bindings); |
| 234 | 234 | |
| 235 | - if (!is_string($sqlStatement)) { |
|
| 235 | + if ( ! is_string($sqlStatement)) { |
|
| 236 | 236 | throw new Exception('Could not interpolate query', 1); |
| 237 | 237 | } |
| 238 | 238 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | public function get() |
| 250 | 250 | { |
| 251 | 251 | $eventResult = $this->fireEvents('before-select'); |
| 252 | - if (!is_null($eventResult)) { |
|
| 252 | + if ( ! is_null($eventResult)) { |
|
| 253 | 253 | return $eventResult; |
| 254 | 254 | } |
| 255 | 255 | $executionTime = 0; |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $this->sqlStatement = null; |
| 275 | 275 | |
| 276 | 276 | // Ensure we have an array of results. |
| 277 | - if (!is_array($result) && null !== $result) { |
|
| 277 | + if ( ! is_array($result) && null !== $result) { |
|
| 278 | 278 | $result = [$result]; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | protected function useHydrator(): bool |
| 309 | 309 | { |
| 310 | - return !in_array($this->getFetchMode(), [\ARRAY_A, \ARRAY_N, \OBJECT, \OBJECT_K]); |
|
| 310 | + return ! in_array($this->getFetchMode(), [\ARRAY_A, \ARRAY_N, \OBJECT, \OBJECT_K]); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | ->select([$this->raw(sprintf('%s(%s) AS field', strtoupper($type), $field))]) |
| 409 | 409 | ->first(); |
| 410 | 410 | |
| 411 | - return true === isset($count->field) ? (float)$count->field : 0; |
|
| 411 | + return true === isset($count->field) ? (float) $count->field : 0; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function count($field = '*'): int |
| 426 | 426 | { |
| 427 | - return (int)$this->aggregate('count', $field); |
|
| 427 | + return (int) $this->aggregate('count', $field); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -502,8 +502,8 @@ discard block |
||
| 502 | 502 | public function getQuery(string $type = 'select', $dataToBePassed = []) |
| 503 | 503 | { |
| 504 | 504 | $allowedTypes = ['select', 'insert', 'insertignore', 'replace', 'delete', 'update', 'criteriaonly']; |
| 505 | - if (!in_array(strtolower($type), $allowedTypes)) { |
|
| 506 | - throw new Exception($type . ' is not a known type.', 2); |
|
| 505 | + if ( ! in_array(strtolower($type), $allowedTypes)) { |
|
| 506 | + throw new Exception($type.' is not a known type.', 2); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | $queryArr = $this->adapterInstance->$type($this->statements, $dataToBePassed); |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | public function subQuery(QueryBuilderHandler $queryBuilder, ?string $alias = null) |
| 524 | 524 | { |
| 525 | - $sql = '(' . $queryBuilder->getQuery()->getRawSql() . ')'; |
|
| 525 | + $sql = '('.$queryBuilder->getQuery()->getRawSql().')'; |
|
| 526 | 526 | if (is_string($alias) && 0 !== mb_strlen($alias)) { |
| 527 | - $sql = $sql . ' as ' . $alias; |
|
| 527 | + $sql = $sql.' as '.$alias; |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | return $queryBuilder->raw($sql); |
@@ -541,12 +541,12 @@ discard block |
||
| 541 | 541 | private function doInsert(array $data, string $type) |
| 542 | 542 | { |
| 543 | 543 | $eventResult = $this->fireEvents('before-insert'); |
| 544 | - if (!is_null($eventResult)) { |
|
| 544 | + if ( ! is_null($eventResult)) { |
|
| 545 | 545 | return $eventResult; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | // If first value is not an array () not a batch insert) |
| 549 | - if (!is_array(current($data))) { |
|
| 549 | + if ( ! is_array(current($data))) { |
|
| 550 | 550 | $queryObject = $this->getQuery($type, $data); |
| 551 | 551 | |
| 552 | 552 | list($preparedQuery, $executionTime) = $this->statement($queryObject->getSql(), $queryObject->getBindings()); |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | public function update(array $data): ?int |
| 617 | 617 | { |
| 618 | 618 | $eventResult = $this->fireEvents('before-update'); |
| 619 | - if (!is_null($eventResult)) { |
|
| 619 | + if ( ! is_null($eventResult)) { |
|
| 620 | 620 | return $eventResult; |
| 621 | 621 | } |
| 622 | 622 | $queryObject = $this->getQuery('update', $data); |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | public function delete() |
| 670 | 670 | { |
| 671 | 671 | $eventResult = $this->fireEvents('before-delete'); |
| 672 | - if (!is_null($eventResult)) { |
|
| 672 | + if ( ! is_null($eventResult)) { |
|
| 673 | 673 | return $eventResult; |
| 674 | 674 | } |
| 675 | 675 | |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | public function table(...$tables) |
| 693 | 693 | { |
| 694 | - $instance = $this->constructCurrentBuilderClass($this->connection); |
|
| 694 | + $instance = $this->constructCurrentBuilderClass($this->connection); |
|
| 695 | 695 | $this->setFetchMode($this->getFetchMode(), $this->hydratorConstructorArgs); |
| 696 | 696 | $tables = $this->addTablePrefix($tables, false); |
| 697 | 697 | $instance->addStatement('tables', $tables); |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | */ |
| 720 | 720 | public function select($fields): self |
| 721 | 721 | { |
| 722 | - if (!is_array($fields)) { |
|
| 722 | + if ( ! is_array($fields)) { |
|
| 723 | 723 | $fields = func_get_args(); |
| 724 | 724 | } |
| 725 | 725 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | */ |
| 781 | 781 | public function orderBy($fields, string $defaultDirection = 'ASC'): self |
| 782 | 782 | { |
| 783 | - if (!is_array($fields)) { |
|
| 783 | + if ( ! is_array($fields)) { |
|
| 784 | 784 | $fields = [$fields]; |
| 785 | 785 | } |
| 786 | 786 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | $field = $this->jsonHandler->extractAndUnquoteFromJsonSelector($field); |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - if (!$field instanceof Raw) { |
|
| 799 | + if ( ! $field instanceof Raw) { |
|
| 800 | 800 | $field = $this->addTablePrefix($field); |
| 801 | 801 | } |
| 802 | 802 | $this->statements['orderBys'][] = compact('field', 'type'); |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | throw new Exception('Key used for whereNull condition must be a string or raw exrpession.', 1); |
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - return $this->{$operator . 'Where'}($this->raw("{$key} IS{$prefix} NULL")); |
|
| 1151 | + return $this->{$operator.'Where'}($this->raw("{$key} IS{$prefix} NULL")); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | |
@@ -1245,8 +1245,8 @@ discard block |
||
| 1245 | 1245 | $value = $this->jsonHandler->extractAndUnquoteFromJsonSelector($value); |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | - if (!$key instanceof Closure) { |
|
| 1249 | - $key = function ($joinBuilder) use ($key, $operator, $value) { |
|
| 1248 | + if ( ! $key instanceof Closure) { |
|
| 1249 | + $key = function($joinBuilder) use ($key, $operator, $value) { |
|
| 1250 | 1250 | $joinBuilder->on($key, $operator, $value); |
| 1251 | 1251 | }; |
| 1252 | 1252 | } |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | */ |
| 1340 | 1340 | public function joinUsing(string $table, string $key, string $type = 'INNER'): self |
| 1341 | 1341 | { |
| 1342 | - if (!array_key_exists('tables', $this->statements) || count($this->statements['tables']) !== 1) { |
|
| 1342 | + if ( ! array_key_exists('tables', $this->statements) || count($this->statements['tables']) !== 1) { |
|
| 1343 | 1343 | throw new Exception("JoinUsing can only be used with a single table set as the base of the query", 1); |
| 1344 | 1344 | } |
| 1345 | 1345 | $baseTable = end($this->statements['tables']); |
@@ -1430,11 +1430,11 @@ discard block |
||
| 1430 | 1430 | */ |
| 1431 | 1431 | protected function addStatement($key, $value) |
| 1432 | 1432 | { |
| 1433 | - if (!is_array($value)) { |
|
| 1433 | + if ( ! is_array($value)) { |
|
| 1434 | 1434 | $value = [$value]; |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | - if (!array_key_exists($key, $this->statements)) { |
|
| 1437 | + if ( ! array_key_exists($key, $this->statements)) { |
|
| 1438 | 1438 | $this->statements[$key] = $value; |
| 1439 | 1439 | } else { |
| 1440 | 1440 | $this->statements[$key] = array_merge($this->statements[$key], $value); |
@@ -26,70 +26,70 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | // Generated code start... |
| 29 | -if (!interface_exists(Pixie\HasConnection::class)) { |
|
| 30 | - require_once __DIR__ . '/HasConnection.php'; |
|
| 29 | +if ( ! interface_exists(Pixie\HasConnection::class)) { |
|
| 30 | + require_once __DIR__.'/HasConnection.php'; |
|
| 31 | 31 | } |
| 32 | -if (!trait_exists(Pixie\QueryBuilder\TablePrefixer::class)) { |
|
| 33 | - require_once __DIR__ . '/QueryBuilder/TablePrefixer.php'; |
|
| 32 | +if ( ! trait_exists(Pixie\QueryBuilder\TablePrefixer::class)) { |
|
| 33 | + require_once __DIR__.'/QueryBuilder/TablePrefixer.php'; |
|
| 34 | 34 | } |
| 35 | -if (!class_exists(Pixie\Binding::class)) { |
|
| 36 | - require_once __DIR__ . '/Binding.php'; |
|
| 35 | +if ( ! class_exists(Pixie\Binding::class)) { |
|
| 36 | + require_once __DIR__.'/Binding.php'; |
|
| 37 | 37 | } |
| 38 | -if (!class_exists(Pixie\QueryBuilder\QueryBuilderHandler::class)) { |
|
| 39 | - require_once __DIR__ . '/QueryBuilder/QueryBuilderHandler.php'; |
|
| 38 | +if ( ! class_exists(Pixie\QueryBuilder\QueryBuilderHandler::class)) { |
|
| 39 | + require_once __DIR__.'/QueryBuilder/QueryBuilderHandler.php'; |
|
| 40 | 40 | } |
| 41 | -if (!class_exists(Pixie\QueryBuilder\Transaction::class)) { |
|
| 42 | - require_once __DIR__ . '/QueryBuilder/Transaction.php'; |
|
| 41 | +if ( ! class_exists(Pixie\QueryBuilder\Transaction::class)) { |
|
| 42 | + require_once __DIR__.'/QueryBuilder/Transaction.php'; |
|
| 43 | 43 | } |
| 44 | -if (!class_exists(Pixie\QueryBuilder\Raw::class)) { |
|
| 45 | - require_once __DIR__ . '/QueryBuilder/Raw.php'; |
|
| 44 | +if ( ! class_exists(Pixie\QueryBuilder\Raw::class)) { |
|
| 45 | + require_once __DIR__.'/QueryBuilder/Raw.php'; |
|
| 46 | 46 | } |
| 47 | -if (!class_exists(Pixie\JSON\JsonHandler::class)) { |
|
| 48 | - require_once __DIR__ . '/JSON/JsonHandler.php'; |
|
| 47 | +if ( ! class_exists(Pixie\JSON\JsonHandler::class)) { |
|
| 48 | + require_once __DIR__.'/JSON/JsonHandler.php'; |
|
| 49 | 49 | } |
| 50 | -if (!class_exists(Pixie\EventHandler::class)) { |
|
| 51 | - require_once __DIR__ . '/EventHandler.php'; |
|
| 50 | +if ( ! class_exists(Pixie\EventHandler::class)) { |
|
| 51 | + require_once __DIR__.'/EventHandler.php'; |
|
| 52 | 52 | } |
| 53 | -if (!class_exists(Pixie\QueryBuilder\QueryObject::class)) { |
|
| 54 | - require_once __DIR__ . '/QueryBuilder/QueryObject.php'; |
|
| 53 | +if ( ! class_exists(Pixie\QueryBuilder\QueryObject::class)) { |
|
| 54 | + require_once __DIR__.'/QueryBuilder/QueryObject.php'; |
|
| 55 | 55 | } |
| 56 | -if (!class_exists(Pixie\QueryBuilder\NestedCriteria::class)) { |
|
| 57 | - require_once __DIR__ . '/QueryBuilder/NestedCriteria.php'; |
|
| 56 | +if ( ! class_exists(Pixie\QueryBuilder\NestedCriteria::class)) { |
|
| 57 | + require_once __DIR__.'/QueryBuilder/NestedCriteria.php'; |
|
| 58 | 58 | } |
| 59 | -if (!class_exists(Pixie\QueryBuilder\JoinBuilder::class)) { |
|
| 60 | - require_once __DIR__ . '/QueryBuilder/JoinBuilder.php'; |
|
| 59 | +if ( ! class_exists(Pixie\QueryBuilder\JoinBuilder::class)) { |
|
| 60 | + require_once __DIR__.'/QueryBuilder/JoinBuilder.php'; |
|
| 61 | 61 | } |
| 62 | -if (!class_exists(Pixie\Event::class)) { |
|
| 63 | - require_once __DIR__ . '/Event.php'; |
|
| 62 | +if ( ! class_exists(Pixie\Event::class)) { |
|
| 63 | + require_once __DIR__.'/Event.php'; |
|
| 64 | 64 | } |
| 65 | -if (!class_exists(Pixie\JSON\JsonSelectorHandler::class)) { |
|
| 66 | - require_once __DIR__ . '/JSON/JsonSelectorHandler.php'; |
|
| 65 | +if ( ! class_exists(Pixie\JSON\JsonSelectorHandler::class)) { |
|
| 66 | + require_once __DIR__.'/JSON/JsonSelectorHandler.php'; |
|
| 67 | 67 | } |
| 68 | -if (!class_exists(Pixie\JSON\JsonSelector::class)) { |
|
| 69 | - require_once __DIR__ . '/JSON/JsonSelector.php'; |
|
| 68 | +if ( ! class_exists(Pixie\JSON\JsonSelector::class)) { |
|
| 69 | + require_once __DIR__.'/JSON/JsonSelector.php'; |
|
| 70 | 70 | } |
| 71 | -if (!class_exists(Pixie\Connection::class)) { |
|
| 72 | - require_once __DIR__ . '/Connection.php'; |
|
| 71 | +if ( ! class_exists(Pixie\Connection::class)) { |
|
| 72 | + require_once __DIR__.'/Connection.php'; |
|
| 73 | 73 | } |
| 74 | -if (!class_exists(Pixie\QueryBuilder\JsonQueryBuilder::class)) { |
|
| 75 | - require_once __DIR__ . '/QueryBuilder/JsonQueryBuilder.php'; |
|
| 74 | +if ( ! class_exists(Pixie\QueryBuilder\JsonQueryBuilder::class)) { |
|
| 75 | + require_once __DIR__.'/QueryBuilder/JsonQueryBuilder.php'; |
|
| 76 | 76 | } |
| 77 | -if (!class_exists(Pixie\Hydration\Hydrator::class)) { |
|
| 78 | - require_once __DIR__ . '/Hydration/Hydrator.php'; |
|
| 77 | +if ( ! class_exists(Pixie\Hydration\Hydrator::class)) { |
|
| 78 | + require_once __DIR__.'/Hydration/Hydrator.php'; |
|
| 79 | 79 | } |
| 80 | -if (!class_exists(Pixie\QueryBuilder\WPDBAdapter::class)) { |
|
| 81 | - require_once __DIR__ . '/QueryBuilder/WPDBAdapter.php'; |
|
| 80 | +if ( ! class_exists(Pixie\QueryBuilder\WPDBAdapter::class)) { |
|
| 81 | + require_once __DIR__.'/QueryBuilder/WPDBAdapter.php'; |
|
| 82 | 82 | } |
| 83 | -if (!class_exists(Pixie\Exception::class)) { |
|
| 84 | - require_once __DIR__ . '/Exception.php'; |
|
| 83 | +if ( ! class_exists(Pixie\Exception::class)) { |
|
| 84 | + require_once __DIR__.'/Exception.php'; |
|
| 85 | 85 | } |
| 86 | -if (!class_exists(Pixie\QueryBuilder\TransactionHaltException::class)) { |
|
| 87 | - require_once __DIR__ . '/QueryBuilder/TransactionHaltException.php'; |
|
| 86 | +if ( ! class_exists(Pixie\QueryBuilder\TransactionHaltException::class)) { |
|
| 87 | + require_once __DIR__.'/QueryBuilder/TransactionHaltException.php'; |
|
| 88 | 88 | } |
| 89 | -if (!class_exists(Pixie\AliasFacade::class)) { |
|
| 90 | - require_once __DIR__ . '/AliasFacade.php'; |
|
| 89 | +if ( ! class_exists(Pixie\AliasFacade::class)) { |
|
| 90 | + require_once __DIR__.'/AliasFacade.php'; |
|
| 91 | 91 | } |
| 92 | -if (!class_exists(Pixie\JSON\JsonExpressionFactory::class)) { |
|
| 93 | - require_once __DIR__ . '/JSON/JsonExpressionFactory.php'; |
|
| 92 | +if ( ! class_exists(Pixie\JSON\JsonExpressionFactory::class)) { |
|
| 93 | + require_once __DIR__.'/JSON/JsonExpressionFactory.php'; |
|
| 94 | 94 | } |
| 95 | 95 | // CREATED ON Fri 15th April 2022 |