@@ -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; |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | * @package Platine\Orm |
| 65 | 65 | * @implements RepositoryInterface<Entity> |
| 66 | 66 | */ |
| 67 | -class Repository implements RepositoryInterface |
|
| 68 | -{ |
|
| 67 | +class Repository implements RepositoryInterface { |
|
| 69 | 68 | /** |
| 70 | 69 | * The entity class |
| 71 | 70 | * @var class-string |
@@ -125,8 +124,7 @@ discard block |
||
| 125 | 124 | * @param EntityManager $manager |
| 126 | 125 | * @param class-string $entityClass |
| 127 | 126 | */ |
| 128 | - public function __construct(EntityManager $manager, string $entityClass) |
|
| 129 | - { |
|
| 127 | + public function __construct(EntityManager $manager, string $entityClass) { |
|
| 130 | 128 | $this->manager = $manager; |
| 131 | 129 | $this->entityClass = $entityClass; |
| 132 | 130 | } |
@@ -314,8 +312,7 @@ discard block |
||
| 314 | 312 | /** |
| 315 | 313 | * {@inheritedoc} |
| 316 | 314 | */ |
| 317 | - public function insert(Entity $entity) |
|
| 318 | - { |
|
| 315 | + public function insert(Entity $entity) { |
|
| 319 | 316 | $data = Proxy::instance()->getEntityDataMapper($entity); |
| 320 | 317 | $mapper = $data->getEntityMapper(); |
| 321 | 318 | $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([ |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | public function get(array $columns = [], bool $primaryColumn = true): ?Entity |
| 140 | 140 | { |
| 141 | 141 | $result = $this->query($columns, $primaryColumn) |
| 142 | - ->fetchAssoc() |
|
| 143 | - ->get(); |
|
| 142 | + ->fetchAssoc() |
|
| 143 | + ->get(); |
|
| 144 | 144 | |
| 145 | 145 | if ($result === false) { |
| 146 | 146 | return null; |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
| 292 | - * Find entities record using primary key values |
|
| 293 | - * @param mixed ...$ids |
|
| 294 | - * |
|
| 295 | - * @return array<int, Entity> |
|
| 296 | - */ |
|
| 292 | + * Find entities record using primary key values |
|
| 293 | + * @param mixed ...$ids |
|
| 294 | + * |
|
| 295 | + * @return array<int, Entity> |
|
| 296 | + */ |
|
| 297 | 297 | public function findAll(...$ids): array |
| 298 | 298 | { |
| 299 | 299 | if (is_array($ids[0])) { |
@@ -526,6 +526,6 @@ discard block |
||
| 526 | 526 | protected function transaction(Closure $callback) |
| 527 | 527 | { |
| 528 | 528 | return $this->manager->getConnection() |
| 529 | - ->transaction($callback); |
|
| 529 | + ->transaction($callback); |
|
| 530 | 530 | } |
| 531 | 531 | } |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | * @class EntityQuery |
| 65 | 65 | * @package Platine\Orm\Query |
| 66 | 66 | */ |
| 67 | -class EntityQuery extends Query |
|
| 68 | -{ |
|
| 67 | +class EntityQuery extends Query { |
|
| 69 | 68 | /** |
| 70 | 69 | * |
| 71 | 70 | * @var EntityManager |
@@ -330,8 +329,7 @@ discard block |
||
| 330 | 329 | * @param string|Expression|Closure $column |
| 331 | 330 | * @return mixed |
| 332 | 331 | */ |
| 333 | - public function column($column) |
|
| 334 | - { |
|
| 332 | + public function column($column) { |
|
| 335 | 333 | (new ColumnExpression($this->queryStatement))->column($column); |
| 336 | 334 | |
| 337 | 335 | return $this->executeAggregate(); |
@@ -343,8 +341,7 @@ discard block |
||
| 343 | 341 | * @param bool $distinct |
| 344 | 342 | * @return mixed |
| 345 | 343 | */ |
| 346 | - public function count($column = '*', bool $distinct = false) |
|
| 347 | - { |
|
| 344 | + public function count($column = '*', bool $distinct = false) { |
|
| 348 | 345 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
| 349 | 346 | |
| 350 | 347 | return $this->executeAggregate(); |
@@ -356,8 +353,7 @@ discard block |
||
| 356 | 353 | * @param bool $distinct |
| 357 | 354 | * @return mixed |
| 358 | 355 | */ |
| 359 | - public function avg($column, bool $distinct = false) |
|
| 360 | - { |
|
| 356 | + public function avg($column, bool $distinct = false) { |
|
| 361 | 357 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
| 362 | 358 | |
| 363 | 359 | return $this->executeAggregate(); |
@@ -369,8 +365,7 @@ discard block |
||
| 369 | 365 | * @param bool $distinct |
| 370 | 366 | * @return mixed |
| 371 | 367 | */ |
| 372 | - public function sum($column, bool $distinct = false) |
|
| 373 | - { |
|
| 368 | + public function sum($column, bool $distinct = false) { |
|
| 374 | 369 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
| 375 | 370 | |
| 376 | 371 | return $this->executeAggregate(); |
@@ -382,8 +377,7 @@ discard block |
||
| 382 | 377 | * @param bool $distinct |
| 383 | 378 | * @return mixed |
| 384 | 379 | */ |
| 385 | - public function min($column, bool $distinct = false) |
|
| 386 | - { |
|
| 380 | + public function min($column, bool $distinct = false) { |
|
| 387 | 381 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
| 388 | 382 | |
| 389 | 383 | return $this->executeAggregate(); |
@@ -395,8 +389,7 @@ discard block |
||
| 395 | 389 | * @param bool $distinct |
| 396 | 390 | * @return mixed |
| 397 | 391 | */ |
| 398 | - public function max($column, bool $distinct = false) |
|
| 399 | - { |
|
| 392 | + public function max($column, bool $distinct = false) { |
|
| 400 | 393 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
| 401 | 394 | |
| 402 | 395 | return $this->executeAggregate(); |
@@ -405,8 +398,7 @@ discard block |
||
| 405 | 398 | /** |
| 406 | 399 | * Clone of object |
| 407 | 400 | */ |
| 408 | - public function __clone() |
|
| 409 | - { |
|
| 401 | + public function __clone() { |
|
| 410 | 402 | parent::__clone(); |
| 411 | 403 | $this->havingStatement = new HavingStatement($this->queryStatement); |
| 412 | 404 | } |
@@ -495,8 +487,7 @@ discard block |
||
| 495 | 487 | * Execute the aggregate |
| 496 | 488 | * @return mixed |
| 497 | 489 | */ |
| 498 | - protected function executeAggregate() |
|
| 499 | - { |
|
| 490 | + protected function executeAggregate() { |
|
| 500 | 491 | $this->queryStatement->addTables([$this->mapper->getTable()]); |
| 501 | 492 | |
| 502 | 493 | if ($this->mapper->hasSoftDelete()) { |
@@ -531,8 +522,7 @@ discard block |
||
| 531 | 522 | * |
| 532 | 523 | * @return mixed |
| 533 | 524 | */ |
| 534 | - protected function transaction(Closure $callback) |
|
| 535 | - { |
|
| 525 | + protected function transaction(Closure $callback) { |
|
| 536 | 526 | return $this->manager->getConnection() |
| 537 | 527 | ->transaction($callback); |
| 538 | 528 | } |
@@ -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 | } |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | * Class EntityMapperInterface |
| 53 | 53 | * @package Platine\Orm\Mapper |
| 54 | 54 | */ |
| 55 | -interface EntityMapperInterface |
|
| 56 | -{ |
|
| 55 | +interface EntityMapperInterface { |
|
| 57 | 56 | /** |
| 58 | 57 | * The name of the entity |
| 59 | 58 | * @param string $name |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | return $this; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * {@inheritedoc} |
|
| 227 | - */ |
|
| 225 | + /** |
|
| 226 | + * {@inheritedoc} |
|
| 227 | + */ |
|
| 228 | 228 | public function sequence(string $sequence): self |
| 229 | 229 | { |
| 230 | 230 | $this->sequence = $sequence; |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | return $this; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - /** |
|
| 256 | - * {@inheritedoc} |
|
| 257 | - */ |
|
| 255 | + /** |
|
| 256 | + * {@inheritedoc} |
|
| 257 | + */ |
|
| 258 | 258 | public function guarded(array $columns): self |
| 259 | 259 | { |
| 260 | 260 | $this->guarded = $columns; |
@@ -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 | } |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * Class EntityMapper |
| 56 | 56 | * @package Platine\Orm\Mapper |
| 57 | 57 | */ |
| 58 | -class EntityMapper implements EntityMapperInterface |
|
| 59 | -{ |
|
| 58 | +class EntityMapper implements EntityMapperInterface { |
|
| 60 | 59 | /** |
| 61 | 60 | * The name of the entity |
| 62 | 61 | * @var string |
@@ -177,8 +176,7 @@ discard block |
||
| 177 | 176 | * Create new instance |
| 178 | 177 | * @param string $entityClass |
| 179 | 178 | */ |
| 180 | - public function __construct(string $entityClass) |
|
| 181 | - { |
|
| 179 | + public function __construct(string $entityClass) { |
|
| 182 | 180 | $this->entityClass = $entityClass; |
| 183 | 181 | } |
| 184 | 182 | |
@@ -435,15 +433,13 @@ discard block |
||
| 435 | 433 | $primaryKey = $this->getPrimaryKey(); |
| 436 | 434 | $prefix = $this->getName(); |
| 437 | 435 | |
| 438 | - $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey |
|
| 439 | - { |
|
| 436 | + $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey { |
|
| 440 | 437 | /** |
| 441 | 438 | * |
| 442 | 439 | * @param PrimaryKey $primaryKey |
| 443 | 440 | * @param string $prefix |
| 444 | 441 | */ |
| 445 | - public function __construct(PrimaryKey $primaryKey, string $prefix) |
|
| 446 | - { |
|
| 442 | + public function __construct(PrimaryKey $primaryKey, string $prefix) { |
|
| 447 | 443 | /** @var array<string, string> $columns */ |
| 448 | 444 | $columns = []; |
| 449 | 445 | |
@@ -462,8 +458,7 @@ discard block |
||
| 462 | 458 | * |
| 463 | 459 | * @return callable|null |
| 464 | 460 | */ |
| 465 | - public function getPrimaryKeyGenerator() |
|
| 466 | - { |
|
| 461 | + public function getPrimaryKeyGenerator() { |
|
| 467 | 462 | return $this->primaryKeyGenerator; |
| 468 | 463 | } |
| 469 | 464 | |
@@ -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 | |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | * Class DataMapper |
| 68 | 68 | * @package Platine\Orm\Mapper |
| 69 | 69 | */ |
| 70 | -class DataMapper implements DataMapperInterface |
|
| 71 | -{ |
|
| 70 | +class DataMapper implements DataMapperInterface { |
|
| 72 | 71 | /** |
| 73 | 72 | * The raw columns data |
| 74 | 73 | * @var array<string, mixed> |
@@ -230,8 +229,7 @@ discard block |
||
| 230 | 229 | /** |
| 231 | 230 | * {@inheritedoc} |
| 232 | 231 | */ |
| 233 | - public function getColumn(string $name) |
|
| 234 | - { |
|
| 232 | + public function getColumn(string $name) { |
|
| 235 | 233 | if ($this->refresh) { |
| 236 | 234 | $this->hydrate(); |
| 237 | 235 | } |
@@ -352,8 +350,7 @@ discard block |
||
| 352 | 350 | /** |
| 353 | 351 | * {@inheritedoc} |
| 354 | 352 | */ |
| 355 | - public function getRelated(string $name, callable $callback = null) |
|
| 356 | - { |
|
| 353 | + public function getRelated(string $name, callable $callback = null) { |
|
| 357 | 354 | if (array_key_exists($name, $this->relations)) { |
| 358 | 355 | return $this->relations[$name]; |
| 359 | 356 | } |
@@ -612,8 +609,7 @@ discard block |
||
| 612 | 609 | * |
| 613 | 610 | * @return mixed |
| 614 | 611 | */ |
| 615 | - protected function castGet($value, string $type) |
|
| 616 | - { |
|
| 612 | + protected function castGet($value, string $type) { |
|
| 617 | 613 | $original = $type; |
| 618 | 614 | |
| 619 | 615 | if ($type[0] === '?') { |
@@ -663,8 +659,7 @@ discard block |
||
| 663 | 659 | * |
| 664 | 660 | * @return mixed |
| 665 | 661 | */ |
| 666 | - protected function castSet($value, string $type) |
|
| 667 | - { |
|
| 662 | + protected function castSet($value, string $type) { |
|
| 668 | 663 | $original = $type; |
| 669 | 664 | |
| 670 | 665 | if ($type[0] === '?') { |
@@ -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)) { |
@@ -52,8 +52,7 @@ discard block |
||
| 52 | 52 | * Class RelationFactory |
| 53 | 53 | * @package Platine\Orm\Relation |
| 54 | 54 | */ |
| 55 | -class RelationFactory |
|
| 56 | -{ |
|
| 55 | +class RelationFactory { |
|
| 57 | 56 | /** |
| 58 | 57 | * The relation name |
| 59 | 58 | * @var string |
@@ -71,8 +70,7 @@ discard block |
||
| 71 | 70 | * @param string $name |
| 72 | 71 | * @param Closure $callback |
| 73 | 72 | */ |
| 74 | - public function __construct(string $name, Closure $callback) |
|
| 75 | - { |
|
| 73 | + public function __construct(string $name, Closure $callback) { |
|
| 76 | 74 | $this->name = $name; |
| 77 | 75 | $this->callback = $callback; |
| 78 | 76 | } |