@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * Class EntityManager |
| 58 | 58 | * @package Platine\Orm |
| 59 | 59 | */ |
| 60 | -class EntityManager |
|
| 61 | -{ |
|
| 60 | +class EntityManager { |
|
| 62 | 61 | |
| 63 | 62 | /** |
| 64 | 63 | * The connection |
@@ -82,8 +81,7 @@ discard block |
||
| 82 | 81 | * Create new instance |
| 83 | 82 | * @param Connection $connection |
| 84 | 83 | */ |
| 85 | - public function __construct(Connection $connection) |
|
| 86 | - { |
|
| 84 | + public function __construct(Connection $connection) { |
|
| 87 | 85 | $this->connection = $connection; |
| 88 | 86 | $this->dateFormat = $connection->getDriver()->getDateFormat(); |
| 89 | 87 | } |
@@ -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; |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | * @class Repository |
| 64 | 64 | * @package Platine\Orm |
| 65 | 65 | */ |
| 66 | -class Repository implements RepositoryInterface |
|
| 67 | -{ |
|
| 66 | +class Repository implements RepositoryInterface { |
|
| 68 | 67 | |
| 69 | 68 | /** |
| 70 | 69 | * The entity class |
@@ -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 | } |
@@ -298,8 +296,7 @@ discard block |
||
| 298 | 296 | /** |
| 299 | 297 | * {@inheritedoc} |
| 300 | 298 | */ |
| 301 | - public function insert(Entity $entity) |
|
| 302 | - { |
|
| 299 | + public function insert(Entity $entity) { |
|
| 303 | 300 | $data = Proxy::instance()->getEntityDataMapper($entity); |
| 304 | 301 | $mapper = $data->getEntityMapper(); |
| 305 | 302 | $eventsHandlers = $mapper->getEventHandlers(); |
@@ -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 | * |
@@ -95,8 +94,7 @@ discard block |
||
| 95 | 94 | * |
| 96 | 95 | * @param QueryStatement|null $queryStatement |
| 97 | 96 | */ |
| 98 | - public function __construct(QueryStatement $queryStatement = null) |
|
| 99 | - { |
|
| 97 | + public function __construct(QueryStatement $queryStatement = null) { |
|
| 100 | 98 | parent::__construct($queryStatement); |
| 101 | 99 | $this->havingStatement = new HavingStatement($this->queryStatement); |
| 102 | 100 | } |
@@ -104,8 +102,7 @@ discard block |
||
| 104 | 102 | /** |
| 105 | 103 | * Clone the object |
| 106 | 104 | */ |
| 107 | - public function __clone() |
|
| 108 | - { |
|
| 105 | + public function __clone() { |
|
| 109 | 106 | parent::__clone(); |
| 110 | 107 | $this->havingStatement = new HavingStatement($this->queryStatement); |
| 111 | 108 | } |
@@ -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([ |
@@ -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 | * |
@@ -322,8 +321,7 @@ discard block |
||
| 322 | 321 | * @param string|Expression|Closure $column |
| 323 | 322 | * @return mixed |
| 324 | 323 | */ |
| 325 | - public function column($column) |
|
| 326 | - { |
|
| 324 | + public function column($column) { |
|
| 327 | 325 | (new ColumnExpression($this->queryStatement))->column($column); |
| 328 | 326 | |
| 329 | 327 | return $this->executeAggregate(); |
@@ -335,8 +333,7 @@ discard block |
||
| 335 | 333 | * @param bool $distinct |
| 336 | 334 | * @return mixed |
| 337 | 335 | */ |
| 338 | - public function count($column = '*', bool $distinct = true) |
|
| 339 | - { |
|
| 336 | + public function count($column = '*', bool $distinct = true) { |
|
| 340 | 337 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
| 341 | 338 | |
| 342 | 339 | return $this->executeAggregate(); |
@@ -348,8 +345,7 @@ discard block |
||
| 348 | 345 | * @param bool $distinct |
| 349 | 346 | * @return mixed |
| 350 | 347 | */ |
| 351 | - public function avg($column, bool $distinct = true) |
|
| 352 | - { |
|
| 348 | + public function avg($column, bool $distinct = true) { |
|
| 353 | 349 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
| 354 | 350 | |
| 355 | 351 | return $this->executeAggregate(); |
@@ -361,8 +357,7 @@ discard block |
||
| 361 | 357 | * @param bool $distinct |
| 362 | 358 | * @return mixed |
| 363 | 359 | */ |
| 364 | - public function sum($column, bool $distinct = true) |
|
| 365 | - { |
|
| 360 | + public function sum($column, bool $distinct = true) { |
|
| 366 | 361 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
| 367 | 362 | |
| 368 | 363 | return $this->executeAggregate(); |
@@ -374,8 +369,7 @@ discard block |
||
| 374 | 369 | * @param bool $distinct |
| 375 | 370 | * @return mixed |
| 376 | 371 | */ |
| 377 | - public function min($column, bool $distinct = true) |
|
| 378 | - { |
|
| 372 | + public function min($column, bool $distinct = true) { |
|
| 379 | 373 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
| 380 | 374 | |
| 381 | 375 | return $this->executeAggregate(); |
@@ -387,8 +381,7 @@ discard block |
||
| 387 | 381 | * @param bool $distinct |
| 388 | 382 | * @return mixed |
| 389 | 383 | */ |
| 390 | - public function max($column, bool $distinct = true) |
|
| 391 | - { |
|
| 384 | + public function max($column, bool $distinct = true) { |
|
| 392 | 385 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
| 393 | 386 | |
| 394 | 387 | return $this->executeAggregate(); |
@@ -397,8 +390,7 @@ discard block |
||
| 397 | 390 | /** |
| 398 | 391 | * Clone of object |
| 399 | 392 | */ |
| 400 | - public function __clone() |
|
| 401 | - { |
|
| 393 | + public function __clone() { |
|
| 402 | 394 | parent::__clone(); |
| 403 | 395 | $this->havingStatement = new HavingStatement($this->queryStatement); |
| 404 | 396 | } |
@@ -486,8 +478,7 @@ discard block |
||
| 486 | 478 | * Execute the aggregate |
| 487 | 479 | * @return mixed |
| 488 | 480 | */ |
| 489 | - protected function executeAggregate() |
|
| 490 | - { |
|
| 481 | + protected function executeAggregate() { |
|
| 491 | 482 | $this->queryStatement->addTables([$this->mapper->getTable()]); |
| 492 | 483 | |
| 493 | 484 | if ($this->mapper->hasSoftDelete()) { |
@@ -522,8 +513,7 @@ discard block |
||
| 522 | 513 | * |
| 523 | 514 | * @return mixed |
| 524 | 515 | */ |
| 525 | - protected function transaction(Closure $callback) |
|
| 526 | - { |
|
| 516 | + protected function transaction(Closure $callback) { |
|
| 527 | 517 | return $this->manager->getConnection() |
| 528 | 518 | ->transaction($callback); |
| 529 | 519 | } |
@@ -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 | } |
@@ -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 DataMapperInterface |
| 53 | 53 | * @package Platine\Orm\Mapper |
| 54 | 54 | */ |
| 55 | -interface DataMapperInterface |
|
| 56 | -{ |
|
| 55 | +interface DataMapperInterface { |
|
| 57 | 56 | |
| 58 | 57 | /** |
| 59 | 58 | * Whether the record is new |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | * Class Proxy |
| 60 | 60 | * @package Platine\Orm\Mapper |
| 61 | 61 | */ |
| 62 | -class Proxy |
|
| 63 | -{ |
|
| 62 | +class Proxy { |
|
| 64 | 63 | |
| 65 | 64 | /** |
| 66 | 65 | * The Entity data mapper arguments property |
@@ -78,8 +77,7 @@ discard block |
||
| 78 | 77 | * Create new instance |
| 79 | 78 | * @throws ReflectionException |
| 80 | 79 | */ |
| 81 | - private function __construct() |
|
| 82 | - { |
|
| 80 | + private function __construct() { |
|
| 83 | 81 | $reflection = new ReflectionClass(Entity::class); |
| 84 | 82 | |
| 85 | 83 | $this->dataMapperArgs = $reflection->getProperty('dataMapperArgs'); |