@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | protected function applyDefaults(): void |
| 15 | 15 | { |
| 16 | 16 | $nativeKey = $this->nativeMapper->getPrimaryKey(); |
| 17 | - if (! isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
| 17 | + if (!isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
| 18 | 18 | $this->options[RelationConfig::NATIVE_KEY] = $nativeKey; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - if (! isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
| 21 | + if (!isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
| 22 | 22 | $prefix = Inflector::singularize($this->nativeMapper->getTable()); |
| 23 | 23 | $this->options[RelationConfig::FOREIGN_KEY] = $this->getKeyColumn($prefix, $nativeKey); |
| 24 | 24 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function attachEntities(EntityInterface $nativeEntity, EntityInterface $foreignEntity) |
| 70 | 70 | { |
| 71 | 71 | foreach ($this->keyPairs as $nativeCol => $foreignCol) { |
| 72 | - $nativeKeyValue = $this->nativeMapper->getEntityAttribute($nativeEntity, $nativeCol); |
|
| 72 | + $nativeKeyValue = $this->nativeMapper->getEntityAttribute($nativeEntity, $nativeCol); |
|
| 73 | 73 | $this->foreignMapper->setEntityAttribute($foreignEntity, $foreignCol, $nativeKeyValue); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $remainingRelations = $this->getRemainingRelations($action->getOption('relations')); |
| 92 | 92 | |
| 93 | 93 | // no cascade delete? treat as save so we can process the changes |
| 94 | - if (! $this->isCascade()) { |
|
| 94 | + if (!$this->isCascade()) { |
|
| 95 | 95 | $this->addActionOnSave($action); |
| 96 | 96 | } else { |
| 97 | 97 | // retrieve them again from the DB since the related collection might not have everything |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // save the entities still in the collection |
| 125 | 125 | foreach ($foreignEntities as $foreignEntity) { |
| 126 | - if (! empty($foreignEntity->getChanges())) { |
|
| 126 | + if (!empty($foreignEntity->getChanges())) { |
|
| 127 | 127 | $saveAction = $this->foreignMapper |
| 128 | 128 | ->newSaveAction($foreignEntity, ['relations' => $remainingRelations]); |
| 129 | 129 | $saveAction->addColumns($this->getExtraColumnsForAction()); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __construct(ConnectionLocator $connectionLocator, CastingManager $castingManager = null) |
| 30 | 30 | { |
| 31 | 31 | $this->connectionLocator = $connectionLocator; |
| 32 | - if (! $castingManager) { |
|
| 32 | + if (!$castingManager) { |
|
| 33 | 33 | $castingManager = new CastingManager(); |
| 34 | 34 | } |
| 35 | 35 | $this->castingManager = $castingManager; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | unset($this->lazyMappers[$mapperName]); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if (! isset($this->mappers[$mapperName]) || ! $this->mappers[$mapperName]) { |
|
| 66 | + if (!isset($this->mappers[$mapperName]) || !$this->mappers[$mapperName]) { |
|
| 67 | 67 | throw new InvalidArgumentException(sprintf('Mapper named %s is not registered', $mapperName)); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
| 96 | 96 | if ($this->has($foreignMapper)) { |
| 97 | - if (! $foreignMapper instanceof Mapper) { |
|
| 97 | + if (!$foreignMapper instanceof Mapper) { |
|
| 98 | 98 | $foreignMapper = $this->get($foreignMapper); |
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | $type = $options[RelationConfig::TYPE]; |
| 102 | 102 | $relationClass = __NAMESPACE__ . '\\Relation\\' . Str::className($type); |
| 103 | 103 | |
| 104 | - if (! class_exists($relationClass)) { |
|
| 104 | + if (!class_exists($relationClass)) { |
|
| 105 | 105 | throw new InvalidArgumentException("{$relationClass} does not exist"); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $mapper = $mapperConfigOrFactory($this); |
| 118 | - if (! $mapper instanceof Mapper) { |
|
| 118 | + if (!$mapper instanceof Mapper) { |
|
| 119 | 119 | throw new InvalidArgumentException( |
| 120 | 120 | 'The mapper generated from the factory is not a valid `Mapper` instance' |
| 121 | 121 | ); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $mapper->entityClass = $mapperConfig->entityClass; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ($mapperConfig->behaviours && ! empty($mapperConfig->behaviours)) { |
|
| 140 | + if ($mapperConfig->behaviours && !empty($mapperConfig->behaviours)) { |
|
| 141 | 141 | $mapper->use(...$mapperConfig->behaviours); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | public function __construct(Orm $orm, HydratorInterface $entityHydrator = null, QueryBuilder $queryBuilder = null) |
| 148 | 148 | { |
| 149 | 149 | $this->orm = $orm; |
| 150 | - if (! $entityHydrator) { |
|
| 150 | + if (!$entityHydrator) { |
|
| 151 | 151 | $entityHydrator = new GenericEntityHydrator($orm, $this); |
| 152 | 152 | } |
| 153 | - if (! $queryBuilder) { |
|
| 153 | + if (!$queryBuilder) { |
|
| 154 | 154 | $this->queryBuilder = QueryBuilder::getInstance(); |
| 155 | 155 | } |
| 156 | 156 | $this->entityHydrator = $entityHydrator; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $mapper = $this; |
| 222 | 222 | |
| 223 | 223 | $singular = Inflector::singularize($this->getTableAlias(true)); |
| 224 | - $castingManager->register($singular, function ($value) use ($mapper, $castingManager) { |
|
| 224 | + $castingManager->register($singular, function($value) use ($mapper, $castingManager) { |
|
| 225 | 225 | if ($value instanceof $this->entityClass) { |
| 226 | 226 | return $value; |
| 227 | 227 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | }); |
| 231 | 231 | |
| 232 | 232 | $plural = $this->getTableAlias(true); |
| 233 | - $castingManager->register($plural, function ($values) use ($mapper, $castingManager) { |
|
| 233 | + $castingManager->register($plural, function($values) use ($mapper, $castingManager) { |
|
| 234 | 234 | if ($values instanceof Collection) { |
| 235 | 235 | return $values; |
| 236 | 236 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public function getTableAlias($returnTableIfNull = false) |
| 266 | 266 | { |
| 267 | - return (! $this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
| 267 | + return (!$this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | public function getTableReference() |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | return null; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - $receivedTracker = ! ! $tracker; |
|
| 333 | - if (! $tracker) { |
|
| 332 | + $receivedTracker = !!$tracker; |
|
| 333 | + if (!$tracker) { |
|
| 334 | 334 | $receivedTracker = false; |
| 335 | 335 | $tracker = new Tracker($this, [$data]); |
| 336 | 336 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $this->injectRelations($entity, $tracker, $load); |
| 340 | 340 | $entity->setPersistenceState(StateEnum::SYNCHRONIZED); |
| 341 | 341 | |
| 342 | - if (! $receivedTracker) { |
|
| 342 | + if (!$receivedTracker) { |
|
| 343 | 343 | $tracker->replaceRows([$entity]); |
| 344 | 344 | if ($tracker->isDisposable()) { |
| 345 | 345 | unset($tracker); |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $queryCallback = $eagerLoad[$name] ?? null; |
| 395 | 395 | $nextLoad = Arr::getChildren($eagerLoad, $name); |
| 396 | 396 | |
| 397 | - if (! $tracker->hasRelation($name)) { |
|
| 397 | + if (!$tracker->hasRelation($name)) { |
|
| 398 | 398 | $tracker->setRelation($name, $relation, $queryCallback); |
| 399 | 399 | } |
| 400 | 400 | |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | public function getRelation($name): Relation |
| 433 | 433 | { |
| 434 | - if (! $this->hasRelation($name)) { |
|
| 434 | + if (!$this->hasRelation($name)) { |
|
| 435 | 435 | throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper"); |
| 436 | 436 | } |
| 437 | 437 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | $this->relations[$name] = $this->orm->createRelation($this, $name, $this->relations[$name]); |
| 440 | 440 | } |
| 441 | 441 | $relation = $this->relations[$name]; |
| 442 | - if (! $relation instanceof Relation) { |
|
| 442 | + if (!$relation instanceof Relation) { |
|
| 443 | 443 | throw new \InvalidArgumentException("Relation named {$name} is not a proper Relation instance"); |
| 444 | 444 | } |
| 445 | 445 | |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | public function newSaveAction(EntityInterface $entity, $options): BaseAction |
| 494 | 494 | { |
| 495 | - if (! $entity->getPk()) { |
|
| 495 | + if (!$entity->getPk()) { |
|
| 496 | 496 | $action = new Insert($this, $entity, $options); |
| 497 | 497 | } else { |
| 498 | 498 | $action = new Update($this, $entity, $options); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | |
| 530 | 530 | protected function assertCanPersistEntity($entity) |
| 531 | 531 | { |
| 532 | - if (! $entity || ! $entity instanceof $this->entityClass) { |
|
| 532 | + if (!$entity || !$entity instanceof $this->entityClass) { |
|
| 533 | 533 | throw new \InvalidArgumentException(sprintf( |
| 534 | 534 | 'Mapper %s can only persist entity of class %s. %s class provided', |
| 535 | 535 | __CLASS__, |