@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | $delete = new \Sirius\Sql\Delete($this->mapper->getWriteConnection()); |
| 21 | 21 | $delete->from($this->mapper->getTable()) |
| 22 | - ->where('id', $entityId); |
|
| 22 | + ->where('id', $entityId); |
|
| 23 | 23 | $delete->perform(); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -21,10 +21,10 @@ |
||
| 21 | 21 | |
| 22 | 22 | $update = new \Sirius\Sql\Update($this->mapper->getWriteConnection()); |
| 23 | 23 | $update->table($this->mapper->getTable()) |
| 24 | - ->columns([ |
|
| 25 | - $this->getOption('deleted_at_column') => $this->now |
|
| 26 | - ]) |
|
| 27 | - ->where('id', $entityId); |
|
| 24 | + ->columns([ |
|
| 25 | + $this->getOption('deleted_at_column') => $this->now |
|
| 26 | + ]) |
|
| 27 | + ->where('id', $entityId); |
|
| 28 | 28 | $update->perform(); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | protected function execute() |
| 14 | 14 | { |
| 15 | 15 | $entityId = $this->entity->getPk(); |
| 16 | - if ( ! $entityId) { |
|
| 16 | + if (!$entityId) { |
|
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | |
| 84 | 84 | $insert = new \Sirius\Sql\Insert($conn); |
| 85 | 85 | $insert->into($throughTable) |
| 86 | - ->columns($insertColumns) |
|
| 87 | - ->perform(); |
|
| 86 | + ->columns($insertColumns) |
|
| 87 | + ->perform(); |
|
| 88 | 88 | } |
| 89 | 89 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $conn = $this->relation->getNativeMapper()->getWriteConnection(); |
| 52 | 52 | $throughTable = (string)$this->relation->getOption(RelationOption::THROUGH_TABLE); |
| 53 | 53 | |
| 54 | - $throughNativeColumns = (array) $this->relation->getOption(RelationOption::THROUGH_NATIVE_COLUMN); |
|
| 55 | - $throughForeignColumns = (array) $this->relation->getOption(RelationOption::THROUGH_FOREIGN_COLUMN); |
|
| 56 | - $nativeKey = (array) $this->nativeEntity->getPk(); |
|
| 57 | - $foreignKey = (array) $this->foreignEntity->getPk(); |
|
| 54 | + $throughNativeColumns = (array)$this->relation->getOption(RelationOption::THROUGH_NATIVE_COLUMN); |
|
| 55 | + $throughForeignColumns = (array)$this->relation->getOption(RelationOption::THROUGH_FOREIGN_COLUMN); |
|
| 56 | + $nativeKey = (array)$this->nativeEntity->getPk(); |
|
| 57 | + $foreignKey = (array)$this->foreignEntity->getPk(); |
|
| 58 | 58 | |
| 59 | 59 | $delete = new \Sirius\Sql\Delete($conn); |
| 60 | 60 | $delete->from($throughTable); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $throughColumnPrefix = $this->relation->getOption(RelationOption::THROUGH_COLUMNS_PREFIX); |
| 74 | - foreach((array)$this->relation->getOption(RelationOption::THROUGH_COLUMNS) as $col) { |
|
| 74 | + foreach ((array)$this->relation->getOption(RelationOption::THROUGH_COLUMNS) as $col) { |
|
| 75 | 75 | $insertColumns[$col] = $this->foreignEntity->get("{$throughColumnPrefix}{$col}"); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | public static function new(...$args) |
| 11 | 11 | { |
| 12 | 12 | if ($args[0] instanceof Connection) { |
| 13 | - return new ConnectionLocator(function () use ($args) { |
|
| 13 | + return new ConnectionLocator(function() use ($args) { |
|
| 14 | 14 | return $args[0]; |
| 15 | 15 | }); |
| 16 | 16 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public function __construct(ConnectionLocator $connectionLocator, CastingManager $castingManager = null) |
| 29 | 29 | { |
| 30 | 30 | $this->connectionLocator = $connectionLocator; |
| 31 | - if (! $castingManager) { |
|
| 31 | + if (!$castingManager) { |
|
| 32 | 32 | $castingManager = new CastingManager(); |
| 33 | 33 | } |
| 34 | 34 | $this->castingManager = $castingManager; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | unset($this->lazyMappers[$mapperName]); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if (! isset($this->mappers[$mapperName]) || ! $this->mappers[$mapperName]) { |
|
| 65 | + if (!isset($this->mappers[$mapperName]) || !$this->mappers[$mapperName]) { |
|
| 66 | 66 | throw new \InvalidArgumentException(sprintf('Mapper named %s is not registered', $mapperName)); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $foreignMapper = $options[RelationOption::FOREIGN_MAPPER]; |
| 95 | 95 | if ($this->has($foreignMapper)) { |
| 96 | - if (! $foreignMapper instanceof Mapper) { |
|
| 96 | + if (!$foreignMapper instanceof Mapper) { |
|
| 97 | 97 | $foreignMapper = $this->get($foreignMapper); |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | $type = $options[RelationOption::TYPE]; |
| 101 | 101 | $relationClass = __NAMESPACE__ . '\\Relation\\' . Str::className($type); |
| 102 | 102 | |
| 103 | - if (! class_exists($relationClass)) { |
|
| 103 | + if (!class_exists($relationClass)) { |
|
| 104 | 104 | throw new InvalidArgumentException("{$relationClass} does not exist"); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $mapper = $mapperConfigOrFactory($this); |
| 117 | - if (! $mapper instanceof Mapper) { |
|
| 117 | + if (!$mapper instanceof Mapper) { |
|
| 118 | 118 | throw new \InvalidArgumentException( |
| 119 | 119 | 'The mapper generated from the factory is not a valid `Mapper` instance' |
| 120 | 120 | ); |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if ($action instanceof Update && $this->updateColumn) { |
| 45 | - if ( ! empty($action->getEntity()->getChanges())) { |
|
| 45 | + if (!empty($action->getEntity()->getChanges())) { |
|
| 46 | 46 | $action->addColumns([$this->updateColumn => time()]); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -148,7 +148,7 @@ |
||
| 148 | 148 | |
| 149 | 149 | public function reference($table, $tableAlias) |
| 150 | 150 | { |
| 151 | - if (! $tableAlias || $table == $tableAlias) { |
|
| 151 | + if (!$tableAlias || $table == $tableAlias) { |
|
| 152 | 152 | return $table; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $mapper->entityClass = $mapperConfig->entityClass; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ($mapperConfig->behaviours && ! empty($mapperConfig->behaviours)) { |
|
| 139 | + if ($mapperConfig->behaviours && !empty($mapperConfig->behaviours)) { |
|
| 140 | 140 | $mapper->use(...$mapperConfig->behaviours); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | public function __construct(Orm $orm, FactoryInterface $entityFactory = null, QueryBuilder $queryBuilder = null) |
| 147 | 147 | { |
| 148 | 148 | $this->orm = $orm; |
| 149 | - if ( ! $entityFactory) { |
|
| 149 | + if (!$entityFactory) { |
|
| 150 | 150 | $entityFactory = new GenericEntityFactory($orm, $this); |
| 151 | 151 | } |
| 152 | - if ( ! $queryBuilder) { |
|
| 152 | + if (!$queryBuilder) { |
|
| 153 | 153 | $this->queryBuilder = QueryBuilder::getInstance(); |
| 154 | 154 | } |
| 155 | 155 | $this->entityFactory = $entityFactory; |
@@ -220,12 +220,12 @@ discard block |
||
| 220 | 220 | $mapper = $this; |
| 221 | 221 | |
| 222 | 222 | $singular = Inflector::singularize($this->getTableAlias(true)); |
| 223 | - $castingManager->register($singular, function ($value) use ($mapper, $castingManager) { |
|
| 223 | + $castingManager->register($singular, function($value) use ($mapper, $castingManager) { |
|
| 224 | 224 | return $value !== null ? $mapper->newEntity($value, $castingManager) : null; |
| 225 | 225 | }); |
| 226 | 226 | |
| 227 | 227 | $plural = $this->getTableAlias(true); |
| 228 | - $castingManager->register($plural, function ($values) use ($mapper, $castingManager) { |
|
| 228 | + $castingManager->register($plural, function($values) use ($mapper, $castingManager) { |
|
| 229 | 229 | $collection = new Collection(); |
| 230 | 230 | foreach ($values as $value) { |
| 231 | 231 | $collection->add($mapper->newEntity($value, $castingManager)); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function getTableAlias($returnTableIfNull = false) |
| 258 | 258 | { |
| 259 | - return ( ! $this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
| 259 | + return (!$this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | public function getTableReference() |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | return null; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $receivedTracker = ! ! $tracker; |
|
| 325 | - if ( ! $tracker) { |
|
| 324 | + $receivedTracker = !!$tracker; |
|
| 325 | + if (!$tracker) { |
|
| 326 | 326 | $receivedTracker = false; |
| 327 | 327 | $tracker = new Tracker($this, [$data]); |
| 328 | 328 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | $this->injectRelations($entity, $tracker, $load); |
| 332 | 332 | $entity->setPersistanceState(StateEnum::SYNCHRONIZED); |
| 333 | 333 | |
| 334 | - if ( ! $receivedTracker) { |
|
| 334 | + if (!$receivedTracker) { |
|
| 335 | 335 | $tracker->replaceRows([$entity]); |
| 336 | 336 | if ($tracker->isDisposable()) { |
| 337 | 337 | unset($tracker); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | $queryCallback = $eagerLoad[$name] ?? null; |
| 387 | 387 | $nextLoad = Arr::getChildren($eagerLoad, $name); |
| 388 | 388 | |
| 389 | - if ( ! $tracker->hasRelation($name)) { |
|
| 389 | + if (!$tracker->hasRelation($name)) { |
|
| 390 | 390 | $tracker->setRelation($name, $relation, $queryCallback); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | public function getRelation($name): Relation |
| 425 | 425 | { |
| 426 | - if ( ! $this->hasRelation($name)) { |
|
| 426 | + if (!$this->hasRelation($name)) { |
|
| 427 | 427 | throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper"); |
| 428 | 428 | } |
| 429 | 429 | |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $this->relations[$name] = $this->orm->createRelation($this, $name, $this->relations[$name]); |
| 432 | 432 | } |
| 433 | 433 | $relation = $this->relations[$name]; |
| 434 | - if ( ! $relation instanceof Relation) { |
|
| 434 | + if (!$relation instanceof Relation) { |
|
| 435 | 435 | throw new \InvalidArgumentException("Relation named {$name} is not a proper Relation instance"); |
| 436 | 436 | } |
| 437 | 437 | |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | |
| 475 | 475 | public function newSaveAction(EntityInterface $entity, $options): BaseAction |
| 476 | 476 | { |
| 477 | - if ( ! $entity->getPk()) { |
|
| 477 | + if (!$entity->getPk()) { |
|
| 478 | 478 | $action = new Insert($this, $entity, $options); |
| 479 | 479 | } else { |
| 480 | 480 | $action = new Update($this, $entity, $options); |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | protected function assertCanPersistEntity($entity) |
| 503 | 503 | { |
| 504 | - if ( ! $entity || ! $entity instanceof $this->entityClass) { |
|
| 504 | + if (!$entity || !$entity instanceof $this->entityClass) { |
|
| 505 | 505 | throw new \InvalidArgumentException(sprintf( |
| 506 | 506 | 'Mapper %s can only persist entity of class %s. %s class provided', |
| 507 | 507 | __CLASS__, |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | if (strpos($key, $separator)) { |
| 27 | 27 | $parents = static::getParents($key, $separator); |
| 28 | 28 | foreach ($parents as $parent) { |
| 29 | - if (! isset($arr[$parent])) { |
|
| 29 | + if (!isset($arr[$parent])) { |
|
| 30 | 30 | $arr[$parent] = null; |
| 31 | 31 | } |
| 32 | 32 | } |