@@ -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 | |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | unset($this->columns[$name]); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * {@inheritedoc} |
|
| 319 | - */ |
|
| 317 | + /** |
|
| 318 | + * {@inheritedoc} |
|
| 319 | + */ |
|
| 320 | 320 | public function hasColumn(string $column): bool |
| 321 | 321 | { |
| 322 | 322 | return array_key_exists($column, $this->columns) |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | $this->rawColumns[$name] = $value; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * {@inheritedoc} |
|
| 354 | - */ |
|
| 352 | + /** |
|
| 353 | + * {@inheritedoc} |
|
| 354 | + */ |
|
| 355 | 355 | public function getRelated(string $name, callable $callback = null) |
| 356 | 356 | { |
| 357 | 357 | if (array_key_exists($name, $this->relations)) { |
@@ -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] === '?') { |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * Class RepositoryInterface |
| 54 | 54 | * @package Platine\Orm |
| 55 | 55 | */ |
| 56 | -interface RepositoryInterface |
|
| 57 | -{ |
|
| 56 | +interface RepositoryInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * Return the instance of EntityQuery |
| 60 | 59 | * @param string|array<int, string>|array<string, Closure> $with |
@@ -50,8 +50,7 @@ |
||
| 50 | 50 | * Class HasOne |
| 51 | 51 | * @package Platine\Orm\Relation |
| 52 | 52 | */ |
| 53 | -class HasOne extends HasRelation |
|
| 54 | -{ |
|
| 53 | +class HasOne extends HasRelation { |
|
| 55 | 54 | |
| 56 | 55 | /** |
| 57 | 56 | * {@inheritedoc} |
@@ -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 | } |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * Class RelationLoader |
| 56 | 56 | * @package Platine\Orm\Relation |
| 57 | 57 | */ |
| 58 | -class RelationLoader |
|
| 59 | -{ |
|
| 58 | +class RelationLoader { |
|
| 60 | 59 | |
| 61 | 60 | /** |
| 62 | 61 | * |
@@ -124,8 +123,7 @@ discard block |
||
| 124 | 123 | * @param DataMapper $mapper |
| 125 | 124 | * @return null|Entity|array<int, Entity> |
| 126 | 125 | */ |
| 127 | - public function getResult(DataMapper $mapper) |
|
| 128 | - { |
|
| 126 | + public function getResult(DataMapper $mapper) { |
|
| 129 | 127 | $results = $this->loadResults(); |
| 130 | 128 | |
| 131 | 129 | if ($this->inverse) { |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | * Class HasRelation |
| 60 | 60 | * @package Platine\Orm\Relation |
| 61 | 61 | */ |
| 62 | -abstract class HasRelation extends Relation |
|
| 63 | -{ |
|
| 62 | +abstract class HasRelation extends Relation { |
|
| 64 | 63 | |
| 65 | 64 | /** |
| 66 | 65 | * Whether is many or not |
@@ -157,8 +156,7 @@ discard block |
||
| 157 | 156 | /** |
| 158 | 157 | * {@inheritedoc} |
| 159 | 158 | */ |
| 160 | - public function getResult(DataMapper $mapper, ?callable $callback = null) |
|
| 161 | - { |
|
| 159 | + public function getResult(DataMapper $mapper, ?callable $callback = null) { |
|
| 162 | 160 | $manager = $mapper->getEntityManager(); |
| 163 | 161 | $owner = $mapper->getEntityMapper(); |
| 164 | 162 | $related = $manager->getEntityMapper($this->entityClass); |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | - * |
|
| 101 | - * @param DataMapper $mapper |
|
| 102 | - * @param Entity $entity |
|
| 103 | - * |
|
| 104 | - * @return bool |
|
| 105 | - */ |
|
| 100 | + * |
|
| 101 | + * @param DataMapper $mapper |
|
| 102 | + * @param Entity $entity |
|
| 103 | + * |
|
| 104 | + * @return bool |
|
| 105 | + */ |
|
| 106 | 106 | public function link(DataMapper $mapper, Entity $entity): bool |
| 107 | 107 | { |
| 108 | 108 | $manager = $mapper->getEntityManager(); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | }); |
| 377 | 377 | |
| 378 | - $foreignKeys = $this->foreignKey->getValue($mapper->getRawColumns(), true); |
|
| 378 | + $foreignKeys = $this->foreignKey->getValue($mapper->getRawColumns(), true); |
|
| 379 | 379 | if (is_array($foreignKeys)) { |
| 380 | 380 | foreach ($foreignKeys as $fkColumn => $value) { |
| 381 | 381 | $select->where($junctionTable . '.' . $fkColumn)->is($value); |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | }; |
| 263 | 263 | |
| 264 | - $linkKey = new ForeignKey(array_map(function ($value) use ($junctionTable) { |
|
| 264 | + $linkKey = new ForeignKey(array_map(function($value) use ($junctionTable) { |
|
| 265 | 265 | return 'hidden_' . $junctionTable . $value; |
| 266 | 266 | }, $this->foreignKey->columns())); |
| 267 | 267 | |
| 268 | - $select->join($joinTable, function (Join $join) use ($junctionTable, $joinTable) { |
|
| 268 | + $select->join($joinTable, function(Join $join) use ($junctionTable, $joinTable) { |
|
| 269 | 269 | foreach ($this->junction->columns() as $pkColumn => $fkColumn) { |
| 270 | 270 | $join->on($junctionTable . '.' . $fkColumn, $joinTable . '.' . $pkColumn); |
| 271 | 271 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | } |
| 370 | 370 | }; |
| 371 | 371 | |
| 372 | - $select->join($joinTable, function (Join $join) use ($junctionTable, $joinTable) { |
|
| 372 | + $select->join($joinTable, function(Join $join) use ($junctionTable, $joinTable) { |
|
| 373 | 373 | foreach ($this->junction->columns() as $pkColumn => $fkColumn) { |
| 374 | 374 | $join->on($junctionTable . '.' . $fkColumn, $joinTable . '.' . $pkColumn); |
| 375 | 375 | } |
@@ -66,8 +66,7 @@ discard block |
||
| 66 | 66 | * Class ShareRelation |
| 67 | 67 | * @package Platine\Orm\Relation |
| 68 | 68 | */ |
| 69 | -abstract class ShareRelation extends Relation |
|
| 70 | -{ |
|
| 69 | +abstract class ShareRelation extends Relation { |
|
| 71 | 70 | |
| 72 | 71 | /** |
| 73 | 72 | * Whether is many or not |
@@ -214,8 +213,7 @@ discard block |
||
| 214 | 213 | } |
| 215 | 214 | |
| 216 | 215 | $queryStatement = new QueryStatement(); |
| 217 | - $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery |
|
| 218 | - { |
|
| 216 | + $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery { |
|
| 219 | 217 | /** |
| 220 | 218 | * |
| 221 | 219 | * @var string |
@@ -304,8 +302,7 @@ discard block |
||
| 304 | 302 | /** |
| 305 | 303 | * {@inheritedoc} |
| 306 | 304 | */ |
| 307 | - public function getResult(DataMapper $mapper, ?callable $callback = null) |
|
| 308 | - { |
|
| 305 | + public function getResult(DataMapper $mapper, ?callable $callback = null) { |
|
| 309 | 306 | $manager = $mapper->getEntityManager(); |
| 310 | 307 | $owner = $mapper->getEntityMapper(); |
| 311 | 308 | $related = $manager->getEntityMapper($this->entityClass); |
@@ -322,8 +319,7 @@ discard block |
||
| 322 | 319 | $joinTable = $related->getTable(); |
| 323 | 320 | |
| 324 | 321 | $queryStatement = new QueryStatement(); |
| 325 | - $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery |
|
| 326 | - { |
|
| 322 | + $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery { |
|
| 327 | 323 | /** |
| 328 | 324 | * |
| 329 | 325 | * @var string |
@@ -409,15 +405,13 @@ discard block |
||
| 409 | 405 | */ |
| 410 | 406 | protected function buildJunction(EntityMapper $owner, EntityMapper $related): Junction |
| 411 | 407 | { |
| 412 | - return new class ($owner, $related) extends Junction |
|
| 413 | - { |
|
| 408 | + return new class ($owner, $related) extends Junction { |
|
| 414 | 409 | /** |
| 415 | 410 | * |
| 416 | 411 | * @param EntityMapper $owner |
| 417 | 412 | * @param EntityMapper $related |
| 418 | 413 | */ |
| 419 | - public function __construct(EntityMapper $owner, EntityMapper $related) |
|
| 420 | - { |
|
| 414 | + public function __construct(EntityMapper $owner, EntityMapper $related) { |
|
| 421 | 415 | $table = [$owner->getTable(), $related->getTable()]; |
| 422 | 416 | sort($table); |
| 423 | 417 | parent::__construct(implode('_', $table), $related->getForeignKey()->columns()); |