@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | $connection = $this->manager->getConnection(); |
231 | - $id = $connection->transaction(function (Connection $connection) use ($data, $mapper) { |
|
231 | + $id = $connection->transaction(function(Connection $connection) use ($data, $mapper) { |
|
232 | 232 | $columns = $data->getRawColumns(); |
233 | 233 | $pkGenerator = $mapper->getPrimaryKeyGenerator(); |
234 | 234 | if ($pkGenerator !== null) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $modified = $data->getModifiedColumns(); |
299 | 299 | if (!empty($modified)) { |
300 | 300 | $connection = $this->manager->getConnection(); |
301 | - $result = $connection->transaction(function (Connection $connection) use ($data, $mapper, $modified) { |
|
301 | + $result = $connection->transaction(function(Connection $connection) use ($data, $mapper, $modified) { |
|
302 | 302 | $columns = array_intersect_key($data->getRawColumns(), array_flip($modified)); |
303 | 303 | |
304 | 304 | $updatedAt = null; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | $connection = $this->manager->getConnection(); |
338 | - return $connection->transaction(function (Connection $connection) use ($data) { |
|
338 | + return $connection->transaction(function(Connection $connection) use ($data) { |
|
339 | 339 | $data->executePendingLinkage(); |
340 | 340 | |
341 | 341 | return true; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $eventsHandlers = $mapper->getEventHandlers(); |
353 | 353 | $connection = $this->manager->getConnection(); |
354 | 354 | |
355 | - $result = $connection->transaction(function () use ($data, $mapper, $force) { |
|
355 | + $result = $connection->transaction(function() use ($data, $mapper, $force) { |
|
356 | 356 | if ($data->isDeleted()) { |
357 | 357 | throw new EntityStateException('The record was deleted'); |
358 | 358 | } |
@@ -155,7 +155,7 @@ |
||
155 | 155 | |
156 | 156 | if ($this->offset >= 0 && $this->limit >= 0) { |
157 | 157 | $query->offset($this->offset) |
158 | - ->limit($this->limit); |
|
158 | + ->limit($this->limit); |
|
159 | 159 | |
160 | 160 | $this->offset = -1; |
161 | 161 | $this->limit = 0; |
@@ -65,8 +65,7 @@ discard block |
||
65 | 65 | * @template TEntity as Entity |
66 | 66 | * @implements RepositoryInterface<TEntity> |
67 | 67 | */ |
68 | -class Repository implements RepositoryInterface |
|
69 | -{ |
|
68 | +class Repository implements RepositoryInterface { |
|
70 | 69 | /** |
71 | 70 | * The entity class |
72 | 71 | * @var class-string<TEntity> |
@@ -126,8 +125,7 @@ discard block |
||
126 | 125 | * @param EntityManager<TEntity> $manager |
127 | 126 | * @param class-string<TEntity> $entityClass |
128 | 127 | */ |
129 | - public function __construct(EntityManager $manager, string $entityClass) |
|
130 | - { |
|
128 | + public function __construct(EntityManager $manager, string $entityClass) { |
|
131 | 129 | $this->manager = $manager; |
132 | 130 | $this->entityClass = $entityClass; |
133 | 131 | } |
@@ -315,8 +313,7 @@ discard block |
||
315 | 313 | /** |
316 | 314 | * {@inheritedoc} |
317 | 315 | */ |
318 | - public function insert(Entity $entity) |
|
319 | - { |
|
316 | + public function insert(Entity $entity) { |
|
320 | 317 | $data = Proxy::instance()->getEntityDataMapper($entity); |
321 | 318 | $mapper = $data->getEntityMapper(); |
322 | 319 | $eventsHandlers = $mapper->getEventHandlers(); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function delete(bool $force = false, array $tables = []): int |
202 | 202 | { |
203 | - return (int) $this->transaction(function (Connection $connection) use ($tables, $force) { |
|
203 | + return (int) $this->transaction(function(Connection $connection) use ($tables, $force) { |
|
204 | 204 | if (!$force && $this->mapper->hasSoftDelete()) { |
205 | 205 | return (new Update($connection, $this->mapper->getTable(), $this->queryStatement)) |
206 | 206 | ->set([ |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function update(array $columns = []): int |
220 | 220 | { |
221 | - return (int) $this->transaction(function (Connection $connection) use ($columns) { |
|
221 | + return (int) $this->transaction(function(Connection $connection) use ($columns) { |
|
222 | 222 | if ($this->mapper->hasTimestamp()) { |
223 | 223 | list(, $updatedAtColumn) = $this->mapper->getTimestampColumns(); |
224 | 224 | $columns[$updatedAtColumn] = date($this->manager->getDateFormat()); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function increment($column, $value = 1): int |
238 | 238 | { |
239 | - return (int) $this->transaction(function (Connection $connection) use ($column, $value) { |
|
239 | + return (int) $this->transaction(function(Connection $connection) use ($column, $value) { |
|
240 | 240 | if ($this->mapper->hasTimestamp()) { |
241 | 241 | list(, $updatedAtColumn) = $this->mapper->getTimestampColumns(); |
242 | 242 | $this->queryStatement->addUpdateColumns([ |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function decrement($column, $value = 1): int |
258 | 258 | { |
259 | - return (int) $this->transaction(function (Connection $connection) use ($column, $value) { |
|
259 | + return (int) $this->transaction(function(Connection $connection) use ($column, $value) { |
|
260 | 260 | if ($this->mapper->hasTimestamp()) { |
261 | 261 | list(, $updatedAtColumn) = $this->mapper->getTimestampColumns(); |
262 | 262 | $this->queryStatement->addUpdateColumns([ |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | public function get(array $columns = [], bool $primaryColumn = true): ?Entity |
149 | 149 | { |
150 | 150 | $result = $this->query($columns, $primaryColumn) |
151 | - ->fetchAssoc() |
|
152 | - ->get(); |
|
151 | + ->fetchAssoc() |
|
152 | + ->get(); |
|
153 | 153 | |
154 | 154 | if ($result === false) { |
155 | 155 | return null; |
@@ -298,11 +298,11 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | - * Find entities record using primary key values |
|
302 | - * @param mixed ...$ids |
|
303 | - * |
|
304 | - * @return TEntity[] |
|
305 | - */ |
|
301 | + * Find entities record using primary key values |
|
302 | + * @param mixed ...$ids |
|
303 | + * |
|
304 | + * @return TEntity[] |
|
305 | + */ |
|
306 | 306 | public function findAll(...$ids): array |
307 | 307 | { |
308 | 308 | if (is_array($ids[0])) { |
@@ -535,6 +535,6 @@ discard block |
||
535 | 535 | protected function transaction(Closure $callback) |
536 | 536 | { |
537 | 537 | return $this->manager->getConnection() |
538 | - ->transaction($callback); |
|
538 | + ->transaction($callback); |
|
539 | 539 | } |
540 | 540 | } |
@@ -65,8 +65,7 @@ discard block |
||
65 | 65 | * @package Platine\Orm\Query |
66 | 66 | * @template TEntity as Entity |
67 | 67 | */ |
68 | -class EntityQuery extends Query |
|
69 | -{ |
|
68 | +class EntityQuery extends Query { |
|
70 | 69 | /** |
71 | 70 | * |
72 | 71 | * @var EntityManager<TEntity> |
@@ -331,8 +330,7 @@ discard block |
||
331 | 330 | * @param string|Expression|Closure $column |
332 | 331 | * @return mixed |
333 | 332 | */ |
334 | - public function column($column) |
|
335 | - { |
|
333 | + public function column($column) { |
|
336 | 334 | (new ColumnExpression($this->queryStatement))->column($column); |
337 | 335 | |
338 | 336 | return $this->executeAggregate(); |
@@ -344,8 +342,7 @@ discard block |
||
344 | 342 | * @param bool $distinct |
345 | 343 | * @return mixed |
346 | 344 | */ |
347 | - public function count($column = '*', bool $distinct = false) |
|
348 | - { |
|
345 | + public function count($column = '*', bool $distinct = false) { |
|
349 | 346 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
350 | 347 | |
351 | 348 | return $this->executeAggregate(); |
@@ -357,8 +354,7 @@ discard block |
||
357 | 354 | * @param bool $distinct |
358 | 355 | * @return mixed |
359 | 356 | */ |
360 | - public function avg($column, bool $distinct = false) |
|
361 | - { |
|
357 | + public function avg($column, bool $distinct = false) { |
|
362 | 358 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
363 | 359 | |
364 | 360 | return $this->executeAggregate(); |
@@ -370,8 +366,7 @@ discard block |
||
370 | 366 | * @param bool $distinct |
371 | 367 | * @return mixed |
372 | 368 | */ |
373 | - public function sum($column, bool $distinct = false) |
|
374 | - { |
|
369 | + public function sum($column, bool $distinct = false) { |
|
375 | 370 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
376 | 371 | |
377 | 372 | return $this->executeAggregate(); |
@@ -383,8 +378,7 @@ discard block |
||
383 | 378 | * @param bool $distinct |
384 | 379 | * @return mixed |
385 | 380 | */ |
386 | - public function min($column, bool $distinct = false) |
|
387 | - { |
|
381 | + public function min($column, bool $distinct = false) { |
|
388 | 382 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
389 | 383 | |
390 | 384 | return $this->executeAggregate(); |
@@ -396,8 +390,7 @@ discard block |
||
396 | 390 | * @param bool $distinct |
397 | 391 | * @return mixed |
398 | 392 | */ |
399 | - public function max($column, bool $distinct = false) |
|
400 | - { |
|
393 | + public function max($column, bool $distinct = false) { |
|
401 | 394 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
402 | 395 | |
403 | 396 | return $this->executeAggregate(); |
@@ -406,8 +399,7 @@ discard block |
||
406 | 399 | /** |
407 | 400 | * Clone of object |
408 | 401 | */ |
409 | - public function __clone() |
|
410 | - { |
|
402 | + public function __clone() { |
|
411 | 403 | parent::__clone(); |
412 | 404 | $this->havingStatement = new HavingStatement($this->queryStatement); |
413 | 405 | } |
@@ -496,8 +488,7 @@ discard block |
||
496 | 488 | * Execute the aggregate |
497 | 489 | * @return mixed |
498 | 490 | */ |
499 | - protected function executeAggregate() |
|
500 | - { |
|
491 | + protected function executeAggregate() { |
|
501 | 492 | $this->queryStatement->addTables([$this->mapper->getTable()]); |
502 | 493 | |
503 | 494 | if ($this->mapper->hasSoftDelete()) { |
@@ -532,8 +523,7 @@ discard block |
||
532 | 523 | * |
533 | 524 | * @return mixed |
534 | 525 | */ |
535 | - protected function transaction(Closure $callback) |
|
536 | - { |
|
526 | + protected function transaction(Closure $callback) { |
|
537 | 527 | return $this->manager->getConnection() |
538 | 528 | ->transaction($callback); |
539 | 529 | } |
@@ -38,6 +38,5 @@ |
||
38 | 38 | * Class EntityStateException |
39 | 39 | * @package Platine\Orm\Exception |
40 | 40 | */ |
41 | -class EntityStateException extends RuntimeException |
|
42 | -{ |
|
41 | +class EntityStateException extends RuntimeException { |
|
43 | 42 | } |
@@ -38,6 +38,5 @@ |
||
38 | 38 | * Class RelationNotFoundException |
39 | 39 | * @package Platine\Orm\Exception |
40 | 40 | */ |
41 | -class RelationNotFoundException extends RuntimeException |
|
42 | -{ |
|
41 | +class RelationNotFoundException extends RuntimeException { |
|
43 | 42 | } |
@@ -38,6 +38,5 @@ |
||
38 | 38 | * Class PropertyNotFoundException |
39 | 39 | * @package Platine\Orm\Exception |
40 | 40 | */ |
41 | -class PropertyNotFoundException extends RuntimeException |
|
42 | -{ |
|
41 | +class PropertyNotFoundException extends RuntimeException { |
|
43 | 42 | } |
@@ -311,7 +311,7 @@ |
||
311 | 311 | */ |
312 | 312 | public function relation(string $name): RelationFactory |
313 | 313 | { |
314 | - return new RelationFactory($name, function ($name, Relation $relation) { |
|
314 | + return new RelationFactory($name, function($name, Relation $relation) { |
|
315 | 315 | return $this->relations[$name] = $relation; |
316 | 316 | }); |
317 | 317 | } |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | return $this; |
229 | 229 | } |
230 | 230 | |
231 | - /** |
|
232 | - * {@inheritedoc} |
|
233 | - * @return $this<TEntity> |
|
234 | - */ |
|
231 | + /** |
|
232 | + * {@inheritedoc} |
|
233 | + * @return $this<TEntity> |
|
234 | + */ |
|
235 | 235 | public function sequence(string $sequence): self |
236 | 236 | { |
237 | 237 | $this->sequence = $sequence; |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | return $this; |
262 | 262 | } |
263 | 263 | |
264 | - /** |
|
265 | - * {@inheritedoc} |
|
266 | - * @return $this<TEntity> |
|
267 | - */ |
|
264 | + /** |
|
265 | + * {@inheritedoc} |
|
266 | + * @return $this<TEntity> |
|
267 | + */ |
|
268 | 268 | public function guarded(array $columns): self |
269 | 269 | { |
270 | 270 | $this->guarded = $columns; |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @template TEntity as \Platine\Orm\Entity |
58 | 58 | * @implements EntityMapperInterface<TEntity> |
59 | 59 | */ |
60 | -class EntityMapper implements EntityMapperInterface |
|
61 | -{ |
|
60 | +class EntityMapper implements EntityMapperInterface { |
|
62 | 61 | /** |
63 | 62 | * The name of the entity |
64 | 63 | * @var string |
@@ -179,8 +178,7 @@ discard block |
||
179 | 178 | * Create new instance |
180 | 179 | * @param class-string<TEntity> $entityClass |
181 | 180 | */ |
182 | - public function __construct(string $entityClass) |
|
183 | - { |
|
181 | + public function __construct(string $entityClass) { |
|
184 | 182 | $this->entityClass = $entityClass; |
185 | 183 | } |
186 | 184 | |
@@ -452,15 +450,13 @@ discard block |
||
452 | 450 | $primaryKey = $this->getPrimaryKey(); |
453 | 451 | $prefix = $this->getName(); |
454 | 452 | |
455 | - $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey |
|
456 | - { |
|
453 | + $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey { |
|
457 | 454 | /** |
458 | 455 | * |
459 | 456 | * @param PrimaryKey<TEntity> $primaryKey |
460 | 457 | * @param string $prefix |
461 | 458 | */ |
462 | - public function __construct(PrimaryKey $primaryKey, string $prefix) |
|
463 | - { |
|
459 | + public function __construct(PrimaryKey $primaryKey, string $prefix) { |
|
464 | 460 | /** @var array<string, string> $columns */ |
465 | 461 | $columns = []; |
466 | 462 | |
@@ -479,8 +475,7 @@ discard block |
||
479 | 475 | * |
480 | 476 | * @return callable|null |
481 | 477 | */ |
482 | - public function getPrimaryKeyGenerator() |
|
483 | - { |
|
478 | + public function getPrimaryKeyGenerator() { |
|
484 | 479 | return $this->primaryKeyGenerator; |
485 | 480 | } |
486 | 481 |
@@ -259,7 +259,7 @@ |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | $primaryKey = $this->mapper->getPrimaryKey(); |
262 | - if ($name === (string)$primaryKey) { |
|
262 | + if ($name === (string) $primaryKey) { |
|
263 | 263 | return $this->columns[$name] = $value; |
264 | 264 | } |
265 | 265 |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | - /** |
|
322 | - * {@inheritedoc} |
|
323 | - */ |
|
321 | + /** |
|
322 | + * {@inheritedoc} |
|
323 | + */ |
|
324 | 324 | public function hasColumn(string $column): bool |
325 | 325 | { |
326 | 326 | return array_key_exists($column, $this->columns) |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | $this->rawColumns[$name] = $value; |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * {@inheritedoc} |
|
358 | - */ |
|
356 | + /** |
|
357 | + * {@inheritedoc} |
|
358 | + */ |
|
359 | 359 | public function getRelated(string $name, callable $callback = null) |
360 | 360 | { |
361 | 361 | if (array_key_exists($name, $this->relations)) { |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | * @template TEntity as Entity |
67 | 67 | * @implements DataMapperInterface<TEntity> |
68 | 68 | */ |
69 | -class DataMapper implements DataMapperInterface |
|
70 | -{ |
|
69 | +class DataMapper implements DataMapperInterface { |
|
71 | 70 | /** |
72 | 71 | * The raw columns data |
73 | 72 | * @var array<string, mixed> |
@@ -229,8 +228,7 @@ discard block |
||
229 | 228 | /** |
230 | 229 | * {@inheritedoc} |
231 | 230 | */ |
232 | - public function getColumn(string $name) |
|
233 | - { |
|
231 | + public function getColumn(string $name) { |
|
234 | 232 | if ($this->refresh) { |
235 | 233 | $this->hydrate(); |
236 | 234 | } |
@@ -355,8 +353,7 @@ discard block |
||
355 | 353 | /** |
356 | 354 | * {@inheritedoc} |
357 | 355 | */ |
358 | - public function getRelated(string $name, callable $callback = null) |
|
359 | - { |
|
356 | + public function getRelated(string $name, callable $callback = null) { |
|
360 | 357 | if (array_key_exists($name, $this->relations)) { |
361 | 358 | return $this->relations[$name]; |
362 | 359 | } |
@@ -615,8 +612,7 @@ discard block |
||
615 | 612 | * |
616 | 613 | * @return mixed |
617 | 614 | */ |
618 | - protected function castGet($value, string $type) |
|
619 | - { |
|
615 | + protected function castGet($value, string $type) { |
|
620 | 616 | $original = $type; |
621 | 617 | |
622 | 618 | if ($type[0] === '?') { |
@@ -668,8 +664,7 @@ discard block |
||
668 | 664 | * |
669 | 665 | * @return mixed |
670 | 666 | */ |
671 | - protected function castSet($value, string $type) |
|
672 | - { |
|
667 | + protected function castSet($value, string $type) { |
|
673 | 668 | $original = $type; |
674 | 669 | |
675 | 670 | if ($type[0] === '?') { |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class Junction |
51 | 51 | * @package Platine\Orm\Relation |
52 | 52 | */ |
53 | -class Junction |
|
54 | -{ |
|
53 | +class Junction { |
|
55 | 54 | /** |
56 | 55 | * |
57 | 56 | * @var array<string, string> |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | * @param string $table |
70 | 69 | * @param array<string, string> $columns |
71 | 70 | */ |
72 | - public function __construct(string $table, array $columns) |
|
73 | - { |
|
71 | + public function __construct(string $table, array $columns) { |
|
74 | 72 | $this->table = $table; |
75 | 73 | $this->columns = $columns; |
76 | 74 | } |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * Class Query |
58 | 58 | * @package Platine\Orm\Query |
59 | 59 | */ |
60 | -class Query extends BaseStatement |
|
61 | -{ |
|
60 | +class Query extends BaseStatement { |
|
62 | 61 | /** |
63 | 62 | * |
64 | 63 | * @var HavingStatement |
@@ -94,8 +93,7 @@ discard block |
||
94 | 93 | * |
95 | 94 | * @param QueryStatement|null $queryStatement |
96 | 95 | */ |
97 | - public function __construct(QueryStatement $queryStatement = null) |
|
98 | - { |
|
96 | + public function __construct(QueryStatement $queryStatement = null) { |
|
99 | 97 | parent::__construct($queryStatement); |
100 | 98 | $this->havingStatement = new HavingStatement($this->queryStatement); |
101 | 99 | } |
@@ -103,8 +101,7 @@ discard block |
||
103 | 101 | /** |
104 | 102 | * Clone the object |
105 | 103 | */ |
106 | - public function __clone() |
|
107 | - { |
|
104 | + public function __clone() { |
|
108 | 105 | parent::__clone(); |
109 | 106 | $this->havingStatement = new HavingStatement($this->queryStatement); |
110 | 107 | } |