@@ -376,7 +376,7 @@ |
||
| 376 | 376 | |
| 377 | 377 | return (string) preg_replace_callback( |
| 378 | 378 | '/\?/', |
| 379 | - function () use ($driver, &$params) { |
|
| 379 | + function() use ($driver, &$params) { |
|
| 380 | 380 | $param = array_shift($params); |
| 381 | 381 | |
| 382 | 382 | $value = is_object($param) ? get_class($param) : $param; |
@@ -475,12 +475,12 @@ |
||
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - /** |
|
| 479 | - * Change the query parameters placeholder with the value |
|
| 480 | - * @param string $query |
|
| 481 | - * @param array<int, mixed> $params |
|
| 482 | - * @return string |
|
| 483 | - */ |
|
| 478 | + /** |
|
| 479 | + * Change the query parameters placeholder with the value |
|
| 480 | + * @param string $query |
|
| 481 | + * @param array<int, mixed> $params |
|
| 482 | + * @return string |
|
| 483 | + */ |
|
| 484 | 484 | protected function replaceParameters(string $query, array $params): string |
| 485 | 485 | { |
| 486 | 486 | $driver = $this->driver; |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | * Class Connection |
| 62 | 62 | * @package Platine\Database |
| 63 | 63 | */ |
| 64 | -class Connection |
|
| 65 | -{ |
|
| 64 | +class Connection { |
|
| 66 | 65 | /** |
| 67 | 66 | * The PDO instance |
| 68 | 67 | * @var PDO |
@@ -368,8 +367,7 @@ discard block |
||
| 368 | 367 | * @return mixed |
| 369 | 368 | * @throws QueryException |
| 370 | 369 | */ |
| 371 | - public function column(string $sql, array $params = []) |
|
| 372 | - { |
|
| 370 | + public function column(string $sql, array $params = []) { |
|
| 373 | 371 | $prepared = $this->prepare($sql, $params); |
| 374 | 372 | $this->execute($prepared); |
| 375 | 373 | |
@@ -421,8 +419,7 @@ discard block |
||
| 421 | 419 | /** |
| 422 | 420 | * {@inheritdoc} |
| 423 | 421 | */ |
| 424 | - public function __sleep() |
|
| 425 | - { |
|
| 422 | + public function __sleep() { |
|
| 426 | 423 | return [ |
| 427 | 424 | 'dsn', |
| 428 | 425 | 'driver', |
@@ -436,8 +433,7 @@ discard block |
||
| 436 | 433 | /** |
| 437 | 434 | * {@inheritdoc} |
| 438 | 435 | */ |
| 439 | - public function __wakeup() |
|
| 440 | - { |
|
| 436 | + public function __wakeup() { |
|
| 441 | 437 | $this->createPDO(); |
| 442 | 438 | } |
| 443 | 439 | |
@@ -628,7 +624,8 @@ discard block |
||
| 628 | 624 | $sqlLog |
| 629 | 625 | ); |
| 630 | 626 | |
| 631 | - if ($executionTime >= 1) { // TODO use configuration |
|
| 627 | + if ($executionTime >= 1) { |
|
| 628 | +// TODO use configuration |
|
| 632 | 629 | $this->logger->warning( |
| 633 | 630 | 'Query: [{query}] cost too much time: [{time}]', |
| 634 | 631 | $sqlLog |
@@ -50,16 +50,14 @@ discard block |
||
| 50 | 50 | * Class DeleteStatement |
| 51 | 51 | * @package Platine\Database\Query |
| 52 | 52 | */ |
| 53 | -class DeleteStatement extends BaseStatement |
|
| 54 | -{ |
|
| 53 | +class DeleteStatement extends BaseStatement { |
|
| 55 | 54 | |
| 56 | 55 | /** |
| 57 | 56 | * DeleteStatement constructor. |
| 58 | 57 | * @param string|array<string> $from |
| 59 | 58 | * @param QueryStatement|null $queryStatement |
| 60 | 59 | */ |
| 61 | - public function __construct($from, QueryStatement $queryStatement = null) |
|
| 62 | - { |
|
| 60 | + public function __construct($from, QueryStatement $queryStatement = null) { |
|
| 63 | 61 | parent::__construct($queryStatement); |
| 64 | 62 | |
| 65 | 63 | if (!is_array($from)) { |
@@ -73,8 +71,7 @@ discard block |
||
| 73 | 71 | * @param string|array<string> $tables |
| 74 | 72 | * @return mixed |
| 75 | 73 | */ |
| 76 | - public function delete($tables = []) |
|
| 77 | - { |
|
| 74 | + public function delete($tables = []) { |
|
| 78 | 75 | if (!is_array($tables)) { |
| 79 | 76 | /** @var array<string> $tables */ |
| 80 | 77 | $tables = [$tables]; |
@@ -292,7 +292,7 @@ |
||
| 292 | 292 | bool $isColumn = false |
| 293 | 293 | ): WhereStatement { |
| 294 | 294 | if ($isColumn && is_string($value)) { |
| 295 | - $value = function (Expression $expr) use ($value) { |
|
| 295 | + $value = function(Expression $expr) use ($value) { |
|
| 296 | 296 | return $expr->column($value); |
| 297 | 297 | }; |
| 298 | 298 | } |
@@ -52,8 +52,7 @@ discard block |
||
| 52 | 52 | * Class Where |
| 53 | 53 | * @package Platine\Database\Query |
| 54 | 54 | */ |
| 55 | -class Where |
|
| 56 | -{ |
|
| 55 | +class Where { |
|
| 57 | 56 | /** |
| 58 | 57 | * @var string|Expression |
| 59 | 58 | */ |
@@ -270,8 +269,7 @@ discard block |
||
| 270 | 269 | /** |
| 271 | 270 | * @inheritDoc |
| 272 | 271 | */ |
| 273 | - public function __clone() |
|
| 274 | - { |
|
| 272 | + public function __clone() { |
|
| 275 | 273 | if ($this->column instanceof Expression) { |
| 276 | 274 | $this->column = clone $this->column; |
| 277 | 275 | } |
@@ -125,11 +125,11 @@ |
||
| 125 | 125 | |
| 126 | 126 | foreach ($columns as $key => $val) { |
| 127 | 127 | if (is_numeric($key)) { |
| 128 | - $values[$val] = function (Expression $expr) use ($sign, $val, $value) { |
|
| 128 | + $values[$val] = function(Expression $expr) use ($sign, $val, $value) { |
|
| 129 | 129 | $expr->column($val)->op($sign)->value($value); |
| 130 | 130 | }; |
| 131 | 131 | } else { |
| 132 | - $values[$key] = function (Expression $expr) use ($sign, $key, $val) { |
|
| 132 | + $values[$key] = function(Expression $expr) use ($sign, $key, $val) { |
|
| 133 | 133 | $expr->column($key)->op($sign)->value($val); |
| 134 | 134 | }; |
| 135 | 135 | } |
@@ -52,8 +52,7 @@ discard block |
||
| 52 | 52 | * Class Update |
| 53 | 53 | * @package Platine\Database\Query |
| 54 | 54 | */ |
| 55 | -class Update extends UpdateStatement |
|
| 56 | -{ |
|
| 55 | +class Update extends UpdateStatement { |
|
| 57 | 56 | /** |
| 58 | 57 | * @var Connection |
| 59 | 58 | */ |
@@ -65,8 +64,7 @@ discard block |
||
| 65 | 64 | * @param string|array<int, string> $table |
| 66 | 65 | * @param QueryStatement|null $queryStatement |
| 67 | 66 | */ |
| 68 | - public function __construct(Connection $connection, $table, QueryStatement $queryStatement = null) |
|
| 69 | - { |
|
| 67 | + public function __construct(Connection $connection, $table, QueryStatement $queryStatement = null) { |
|
| 70 | 68 | parent::__construct($table, $queryStatement); |
| 71 | 69 | |
| 72 | 70 | $this->connection = $connection; |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | !empty($config['connections']) |
| 79 | 79 | && is_array($config['connections']) |
| 80 | 80 | ) { |
| 81 | - /** @var array<string, array<string, mixed>> $connections */ |
|
| 81 | + /** @var array<string, array<string, mixed>> $connections */ |
|
| 82 | 82 | $connections = $config['connections']; |
| 83 | 83 | |
| 84 | 84 | foreach ($connections as $name => $connection) { |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | * Class Pool |
| 54 | 54 | * @package Platine\Database |
| 55 | 55 | */ |
| 56 | -class Pool |
|
| 57 | -{ |
|
| 56 | +class Pool { |
|
| 58 | 57 | /** |
| 59 | 58 | * The default connection name |
| 60 | 59 | * @var string |
@@ -71,8 +70,7 @@ discard block |
||
| 71 | 70 | * Class constructor |
| 72 | 71 | * @param array<string, mixed> $config |
| 73 | 72 | */ |
| 74 | - public function __construct(array $config = []) |
|
| 75 | - { |
|
| 73 | + public function __construct(array $config = []) { |
|
| 76 | 74 | if (!empty($config)) { |
| 77 | 75 | if ( |
| 78 | 76 | !empty($config['connections']) |
@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class ConnectionNotFoundException |
| 39 | 39 | * @package Platine\Database\Exception |
| 40 | 40 | */ |
| 41 | -class ConnectionNotFoundException extends Exception |
|
| 42 | -{ |
|
| 41 | +class ConnectionNotFoundException extends Exception { |
|
| 43 | 42 | } |
@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class ConnectionAlreadyExistsException |
| 39 | 39 | * @package Platine\Database\Exception |
| 40 | 40 | */ |
| 41 | -class ConnectionAlreadyExistsException extends Exception |
|
| 42 | -{ |
|
| 41 | +class ConnectionAlreadyExistsException extends Exception { |
|
| 43 | 42 | } |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | return $this->appname; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Return the host |
|
| 203 | - * @return string |
|
| 204 | - */ |
|
| 201 | + /** |
|
| 202 | + * Return the host |
|
| 203 | + * @return string |
|
| 204 | + */ |
|
| 205 | 205 | public function getHostname(): string |
| 206 | 206 | { |
| 207 | 207 | return $this->hostname; |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | public function getDriverClassName(): string |
| 400 | 400 | { |
| 401 | 401 | $maps = [ |
| 402 | - 'mysql' => MySQL::class, |
|
| 403 | - 'pgsql' => PostgreSQL::class, |
|
| 404 | - 'sqlsrv' => SQLServer::class, |
|
| 405 | - 'oci' => Oracle::class, |
|
| 406 | - 'oracle' => Oracle::class, |
|
| 407 | - 'sqlite' => SQLite::class, |
|
| 402 | + 'mysql' => MySQL::class, |
|
| 403 | + 'pgsql' => PostgreSQL::class, |
|
| 404 | + 'sqlsrv' => SQLServer::class, |
|
| 405 | + 'oci' => Oracle::class, |
|
| 406 | + 'oracle' => Oracle::class, |
|
| 407 | + 'sqlite' => SQLite::class, |
|
| 408 | 408 | ]; |
| 409 | 409 | |
| 410 | 410 | return isset($maps[$this->driver]) |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | * Class Configuration |
| 60 | 60 | * @package Platine\Database |
| 61 | 61 | */ |
| 62 | -class Configuration extends AbstractConfiguration |
|
| 63 | -{ |
|
| 62 | +class Configuration extends AbstractConfiguration { |
|
| 64 | 63 | /** |
| 65 | 64 | * The connection driver to use |
| 66 | 65 | * @var string |
@@ -350,8 +349,7 @@ discard block |
||
| 350 | 349 | * |
| 351 | 350 | * @return mixed |
| 352 | 351 | */ |
| 353 | - public function getAttribute(string $name, $default = null) |
|
| 354 | - { |
|
| 352 | + public function getAttribute(string $name, $default = null) { |
|
| 355 | 353 | return $this->hasAttribute($name) |
| 356 | 354 | ? $this->attributes[$name] |
| 357 | 355 | : $default; |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | * Class ResultSet |
| 55 | 55 | * @package Platine\Database |
| 56 | 56 | */ |
| 57 | -class ResultSet |
|
| 58 | -{ |
|
| 57 | +class ResultSet { |
|
| 59 | 58 | /** |
| 60 | 59 | * The PDOStatement instance |
| 61 | 60 | * @var PDOStatement |
@@ -66,8 +65,7 @@ discard block |
||
| 66 | 65 | * Class constructor |
| 67 | 66 | * @param PDOStatement $statement |
| 68 | 67 | */ |
| 69 | - public function __construct(PDOStatement $statement) |
|
| 70 | - { |
|
| 68 | + public function __construct(PDOStatement $statement) { |
|
| 71 | 69 | $this->statement = $statement; |
| 72 | 70 | } |
| 73 | 71 | |
@@ -75,8 +73,7 @@ discard block |
||
| 75 | 73 | * Destructor of the class |
| 76 | 74 | * |
| 77 | 75 | */ |
| 78 | - public function __destruct() |
|
| 79 | - { |
|
| 76 | + public function __destruct() { |
|
| 80 | 77 | $this->statement->closeCursor(); |
| 81 | 78 | } |
| 82 | 79 | |
@@ -95,8 +92,7 @@ discard block |
||
| 95 | 92 | * @param int $fetchStyle the PDO fetch style |
| 96 | 93 | * @return array<int, mixed>|false |
| 97 | 94 | */ |
| 98 | - public function all(callable $callable = null, int $fetchStyle = 0) |
|
| 99 | - { |
|
| 95 | + public function all(callable $callable = null, int $fetchStyle = 0) { |
|
| 100 | 96 | if ($callable === null) { |
| 101 | 97 | return $this->statement->fetchAll($fetchStyle); |
| 102 | 98 | } |
@@ -109,8 +105,7 @@ discard block |
||
| 109 | 105 | * @param callable $callable |
| 110 | 106 | * @return array<int, mixed>|false |
| 111 | 107 | */ |
| 112 | - public function allGroup(bool $uniq = false, callable $callable = null) |
|
| 113 | - { |
|
| 108 | + public function allGroup(bool $uniq = false, callable $callable = null) { |
|
| 114 | 109 | $fetchStyle = PDO::FETCH_GROUP | ($uniq ? PDO::FETCH_UNIQUE : 0); |
| 115 | 110 | |
| 116 | 111 | if ($callable === null) { |
@@ -124,8 +119,7 @@ discard block |
||
| 124 | 119 | * @param callable $callable |
| 125 | 120 | * @return mixed |
| 126 | 121 | */ |
| 127 | - public function get(callable $callable = null) |
|
| 128 | - { |
|
| 122 | + public function get(callable $callable = null) { |
|
| 129 | 123 | $result = $this->statement->fetch(); |
| 130 | 124 | $this->statement->closeCursor(); |
| 131 | 125 | if ($callable !== null) { |
@@ -140,8 +134,7 @@ discard block |
||
| 140 | 134 | * |
| 141 | 135 | * @return mixed |
| 142 | 136 | */ |
| 143 | - public function next() |
|
| 144 | - { |
|
| 137 | + public function next() { |
|
| 145 | 138 | return $this->statement->fetch(); |
| 146 | 139 | } |
| 147 | 140 | |
@@ -149,8 +142,7 @@ discard block |
||
| 149 | 142 | * Close the cursor |
| 150 | 143 | * @return mixed |
| 151 | 144 | */ |
| 152 | - public function flush() |
|
| 153 | - { |
|
| 145 | + public function flush() { |
|
| 154 | 146 | return $this->statement->closeCursor(); |
| 155 | 147 | } |
| 156 | 148 | |
@@ -160,8 +152,7 @@ discard block |
||
| 160 | 152 | * |
| 161 | 153 | * @return mixed |
| 162 | 154 | */ |
| 163 | - public function column(int $col = 0) |
|
| 164 | - { |
|
| 155 | + public function column(int $col = 0) { |
|
| 165 | 156 | return $this->statement->fetchColumn($col); |
| 166 | 157 | } |
| 167 | 158 | |