@@ -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; |
@@ -421,12 +421,12 @@ |
||
421 | 421 | $this->createPDO(); |
422 | 422 | } |
423 | 423 | |
424 | - /** |
|
425 | - * Change the query parameters placeholder with the value |
|
426 | - * @param string $query |
|
427 | - * @param array<int, mixed> $params |
|
428 | - * @return string |
|
429 | - */ |
|
424 | + /** |
|
425 | + * Change the query parameters placeholder with the value |
|
426 | + * @param string $query |
|
427 | + * @param array<int, mixed> $params |
|
428 | + * @return string |
|
429 | + */ |
|
430 | 430 | protected function replaceParameters(string $query, array $params): string |
431 | 431 | { |
432 | 432 | $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 | /** |
68 | 67 | * The PDO instance |
@@ -347,8 +346,7 @@ discard block |
||
347 | 346 | * @return mixed |
348 | 347 | * @throws QueryException |
349 | 348 | */ |
350 | - public function column(string $sql, array $params = []) |
|
351 | - { |
|
349 | + public function column(string $sql, array $params = []) { |
|
352 | 350 | $prepared = $this->prepare($sql, $params); |
353 | 351 | $this->execute($prepared); |
354 | 352 | |
@@ -401,8 +399,7 @@ discard block |
||
401 | 399 | /** |
402 | 400 | * {@inheritdoc} |
403 | 401 | */ |
404 | - public function __sleep() |
|
405 | - { |
|
402 | + public function __sleep() { |
|
406 | 403 | return [ |
407 | 404 | 'dsn', |
408 | 405 | 'driver', |
@@ -416,8 +413,7 @@ discard block |
||
416 | 413 | /** |
417 | 414 | * {@inheritdoc} |
418 | 415 | */ |
419 | - public function __wakeup() |
|
420 | - { |
|
416 | + public function __wakeup() { |
|
421 | 417 | $this->createPDO(); |
422 | 418 | } |
423 | 419 |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class ForeignKey |
51 | 51 | * @package Platine\Database\Schema |
52 | 52 | */ |
53 | -class ForeignKey |
|
54 | -{ |
|
53 | +class ForeignKey { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * The referenced table |
@@ -81,8 +80,7 @@ discard block |
||
81 | 80 | * Class constructor |
82 | 81 | * @param array<int, string> $columns |
83 | 82 | */ |
84 | - public function __construct(array $columns) |
|
85 | - { |
|
83 | + public function __construct(array $columns) { |
|
86 | 84 | $this->columns = $columns; |
87 | 85 | } |
88 | 86 |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class Having |
53 | 53 | * @package Platine\Database\Query |
54 | 54 | */ |
55 | -class Having |
|
56 | -{ |
|
55 | +class Having { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * @var string|Expression |
@@ -75,8 +74,7 @@ discard block |
||
75 | 74 | * Having constructor. |
76 | 75 | * @param QueryStatement $queryStatement |
77 | 76 | */ |
78 | - public function __construct(QueryStatement $queryStatement) |
|
79 | - { |
|
77 | + public function __construct(QueryStatement $queryStatement) { |
|
80 | 78 | $this->queryStatement = $queryStatement; |
81 | 79 | } |
82 | 80 | |
@@ -227,8 +225,7 @@ discard block |
||
227 | 225 | /** |
228 | 226 | * @inheritDoc |
229 | 227 | */ |
230 | - public function __clone() |
|
231 | - { |
|
228 | + public function __clone() { |
|
232 | 229 | if ($this->aggregate instanceof Expression) { |
233 | 230 | $this->aggregate = clone $this->aggregate; |
234 | 231 | } |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * Class Delete |
54 | 54 | * @package Platine\Database\Query |
55 | 55 | */ |
56 | -class Delete extends DeleteStatement |
|
57 | -{ |
|
56 | +class Delete extends DeleteStatement { |
|
58 | 57 | |
59 | 58 | /** |
60 | 59 | * @var Connection |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | * @param string|array<string> $from |
68 | 67 | * @param QueryStatement|null $queryStatement |
69 | 68 | */ |
70 | - public function __construct(Connection $connection, $from, QueryStatement $queryStatement = null) |
|
71 | - { |
|
69 | + public function __construct(Connection $connection, $from, QueryStatement $queryStatement = null) { |
|
72 | 70 | parent::__construct($from, $queryStatement); |
73 | 71 | |
74 | 72 | $this->connection = $connection; |
@@ -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 | /** |
59 | 58 | * @var Connection |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | * @param string|array<int, string> $table |
67 | 66 | * @param QueryStatement|null $queryStatement |
68 | 67 | */ |
69 | - public function __construct(Connection $connection, $table, QueryStatement $queryStatement = null) |
|
70 | - { |
|
68 | + public function __construct(Connection $connection, $table, QueryStatement $queryStatement = null) { |
|
71 | 69 | parent::__construct($table, $queryStatement); |
72 | 70 | |
73 | 71 | $this->connection = $connection; |
@@ -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 | } |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class InsertStatement |
51 | 51 | * @package Platine\Database\Query |
52 | 52 | */ |
53 | -class InsertStatement |
|
54 | -{ |
|
53 | +class InsertStatement { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * The Query statement instance |
@@ -63,8 +62,7 @@ discard block |
||
63 | 62 | * InsertStatement constructor. |
64 | 63 | * @param QueryStatement|null $queryStatement |
65 | 64 | */ |
66 | - public function __construct(QueryStatement $queryStatement = null) |
|
67 | - { |
|
65 | + public function __construct(QueryStatement $queryStatement = null) { |
|
68 | 66 | if ($queryStatement === null) { |
69 | 67 | $queryStatement = new QueryStatement(); |
70 | 68 | } |
@@ -99,16 +97,14 @@ discard block |
||
99 | 97 | * @param string $table |
100 | 98 | * @return mixed |
101 | 99 | */ |
102 | - public function into(string $table) |
|
103 | - { |
|
100 | + public function into(string $table) { |
|
104 | 101 | $this->queryStatement->addTables([$table]); |
105 | 102 | } |
106 | 103 | |
107 | 104 | /** |
108 | 105 | * @inheritDoc |
109 | 106 | */ |
110 | - public function __clone() |
|
111 | - { |
|
107 | + public function __clone() { |
|
112 | 108 | $this->queryStatement = clone $this->queryStatement; |
113 | 109 | } |
114 | 110 | } |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @package Platine\Database\Query |
55 | 55 | */ |
56 | -class QueryStatement |
|
57 | -{ |
|
56 | +class QueryStatement { |
|
58 | 57 | |
59 | 58 | /** |
60 | 59 | * The where SQL parts |
@@ -349,8 +348,7 @@ discard block |
||
349 | 348 | * @param bool $not |
350 | 349 | * @return mixed |
351 | 350 | */ |
352 | - public function addHavingIn($aggregate, $value, string $separator, bool $not) |
|
353 | - { |
|
351 | + public function addHavingIn($aggregate, $value, string $separator, bool $not) { |
|
354 | 352 | $aggregate = $this->closureToExpression($aggregate); |
355 | 353 | |
356 | 354 | if ($value instanceof Closure) { |
@@ -618,8 +616,7 @@ discard block |
||
618 | 616 | * |
619 | 617 | * @return mixed|Expression |
620 | 618 | */ |
621 | - protected function closureToExpression($value) |
|
622 | - { |
|
619 | + protected function closureToExpression($value) { |
|
623 | 620 | if ($value instanceof Closure) { |
624 | 621 | return Expression::fromClosure($value); |
625 | 622 | } |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class UpdateStatement |
51 | 51 | * @package Platine\Database\Query |
52 | 52 | */ |
53 | -class UpdateStatement extends BaseStatement |
|
54 | -{ |
|
53 | +class UpdateStatement extends BaseStatement { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * The Query statement instance |
@@ -64,8 +63,7 @@ discard block |
||
64 | 63 | * @param string|array<int, string> $table |
65 | 64 | * @param QueryStatement|null $queryStatement |
66 | 65 | */ |
67 | - public function __construct($table, QueryStatement $queryStatement = null) |
|
68 | - { |
|
66 | + public function __construct($table, QueryStatement $queryStatement = null) { |
|
69 | 67 | parent::__construct($queryStatement); |
70 | 68 | |
71 | 69 | if (!is_array($table)) { |
@@ -80,8 +78,7 @@ discard block |
||
80 | 78 | * |
81 | 79 | * @return void |
82 | 80 | */ |
83 | - public function set(array $columns) |
|
84 | - { |
|
81 | + public function set(array $columns) { |
|
85 | 82 | $this->queryStatement->addUpdateColumns($columns); |
86 | 83 | } |
87 | 84 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class SelectStatement |
53 | 53 | * @package Platine\Database\Query |
54 | 54 | */ |
55 | -class SelectStatement extends BaseStatement |
|
56 | -{ |
|
55 | +class SelectStatement extends BaseStatement { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * @var HavingStatement |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | * @param string|array<int, string> $tables |
66 | 65 | * @param QueryStatement|null $queryStatement |
67 | 66 | */ |
68 | - public function __construct($tables, QueryStatement $queryStatement = null) |
|
69 | - { |
|
67 | + public function __construct($tables, QueryStatement $queryStatement = null) { |
|
70 | 68 | parent::__construct($queryStatement); |
71 | 69 | |
72 | 70 | if (!is_array($tables)) { |
@@ -179,8 +177,7 @@ discard block |
||
179 | 177 | * @param string|Expression|Closure|string[]|Expression[]|Closure[] $columns |
180 | 178 | * @return mixed |
181 | 179 | */ |
182 | - public function select($columns = []) |
|
183 | - { |
|
180 | + public function select($columns = []) { |
|
184 | 181 | $expr = new ColumnExpression($this->queryStatement); |
185 | 182 | |
186 | 183 | if ($columns instanceof Closure) { |
@@ -197,8 +194,7 @@ discard block |
||
197 | 194 | * @param string|Expression|Closure $name |
198 | 195 | * @return mixed |
199 | 196 | */ |
200 | - public function column($name) |
|
201 | - { |
|
197 | + public function column($name) { |
|
202 | 198 | (new ColumnExpression($this->queryStatement))->column($name); |
203 | 199 | } |
204 | 200 | |
@@ -207,8 +203,7 @@ discard block |
||
207 | 203 | * @param bool $distinct |
208 | 204 | * @return mixed |
209 | 205 | */ |
210 | - public function count($column = '*', bool $distinct = false) |
|
211 | - { |
|
206 | + public function count($column = '*', bool $distinct = false) { |
|
212 | 207 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
213 | 208 | } |
214 | 209 | |
@@ -217,8 +212,7 @@ discard block |
||
217 | 212 | * @param bool $distinct |
218 | 213 | * @return mixed |
219 | 214 | */ |
220 | - public function avg($column, bool $distinct = false) |
|
221 | - { |
|
215 | + public function avg($column, bool $distinct = false) { |
|
222 | 216 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
223 | 217 | } |
224 | 218 | |
@@ -227,8 +221,7 @@ discard block |
||
227 | 221 | * @param bool $distinct |
228 | 222 | * @return mixed |
229 | 223 | */ |
230 | - public function sum($column, bool $distinct = false) |
|
231 | - { |
|
224 | + public function sum($column, bool $distinct = false) { |
|
232 | 225 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
233 | 226 | } |
234 | 227 | |
@@ -237,8 +230,7 @@ discard block |
||
237 | 230 | * @param bool $distinct |
238 | 231 | * @return mixed |
239 | 232 | */ |
240 | - public function min($column, bool $distinct = false) |
|
241 | - { |
|
233 | + public function min($column, bool $distinct = false) { |
|
242 | 234 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
243 | 235 | } |
244 | 236 | |
@@ -247,16 +239,14 @@ discard block |
||
247 | 239 | * @param bool $distinct |
248 | 240 | * @return mixed |
249 | 241 | */ |
250 | - public function max($column, bool $distinct = false) |
|
251 | - { |
|
242 | + public function max($column, bool $distinct = false) { |
|
252 | 243 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
253 | 244 | } |
254 | 245 | |
255 | 246 | /** |
256 | 247 | * @inheritDoc |
257 | 248 | */ |
258 | - public function __clone() |
|
259 | - { |
|
249 | + public function __clone() { |
|
260 | 250 | parent::__clone(); |
261 | 251 | $this->havingStatement = new HavingStatement($this->queryStatement); |
262 | 252 | } |