@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | protected function addActionOnDelete(BaseAction $action) |
31 | 31 | { |
32 | 32 | // no cascade delete? treat it as a save |
33 | - if (! $this->isCascade()) { |
|
33 | + if (!$this->isCascade()) { |
|
34 | 34 | $this->addActionOnSave($action); |
35 | 35 | } else { |
36 | 36 | $nativeEntity = $action->getEntity(); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | protected function addActionOnSave(BaseAction $action) |
50 | 50 | { |
51 | - if (! $this->relationWasChanged($action->getEntity())) { |
|
51 | + if (!$this->relationWasChanged($action->getEntity())) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | $foreignEntity = $this->nativeMapper->getEntityAttribute($action->getEntity(), $this->name); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | ->newQuery(); |
58 | 58 | |
59 | 59 | $query = $this->joinWithThroughTable($query) |
60 | - ->where($this->options[RelationConfig::THROUGH_NATIVE_COLUMN], $nativePks); |
|
60 | + ->where($this->options[RelationConfig::THROUGH_NATIVE_COLUMN], $nativePks); |
|
61 | 61 | |
62 | 62 | $query = $this->applyQueryCallback($query); |
63 | 63 | |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | { |
111 | 111 | $tableRef = $this->foreignMapper->getTableAlias(true); |
112 | 112 | $subselect = $query->subSelectForJoinWith() |
113 | - ->from($this->foreignMapper->getTable()) |
|
114 | - ->columns($this->foreignMapper->getTable() . '.*') |
|
115 | - ->as($reference); |
|
113 | + ->from($this->foreignMapper->getTable()) |
|
114 | + ->columns($this->foreignMapper->getTable() . '.*') |
|
115 | + ->as($reference); |
|
116 | 116 | |
117 | 117 | $subselect = $this->joinWithThroughTable($subselect); |
118 | 118 |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | $this->setOptionIfMissing(RelationConfig::THROUGH_COLUMNS_PREFIX, 'pivot_'); |
21 | 21 | |
22 | 22 | $foreignKey = $this->foreignMapper->getPrimaryKey(); |
23 | - if (! isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
23 | + if (!isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
24 | 24 | $this->options[RelationConfig::FOREIGN_KEY] = $foreignKey; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $nativeKey = $this->foreignMapper->getPrimaryKey(); |
28 | - if (! isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
28 | + if (!isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
29 | 29 | $this->options[RelationConfig::NATIVE_KEY] = $nativeKey; |
30 | 30 | } |
31 | 31 | |
32 | - if (! isset($this->options[RelationConfig::THROUGH_TABLE])) { |
|
32 | + if (!isset($this->options[RelationConfig::THROUGH_TABLE])) { |
|
33 | 33 | $tables = [$this->foreignMapper->getTable(), $this->nativeMapper->getTable()]; |
34 | 34 | sort($tables); |
35 | 35 | $this->options[RelationConfig::THROUGH_TABLE] = implode('_', $tables); |
36 | 36 | } |
37 | 37 | |
38 | - if (! isset($this->options[RelationConfig::THROUGH_NATIVE_COLUMN])) { |
|
38 | + if (!isset($this->options[RelationConfig::THROUGH_NATIVE_COLUMN])) { |
|
39 | 39 | $prefix = Inflector::singularize($this->nativeMapper->getTableAlias(true)); |
40 | 40 | |
41 | 41 | $this->options[RelationConfig::THROUGH_NATIVE_COLUMN] = $this->getKeyColumn($prefix, $nativeKey); |
42 | 42 | } |
43 | 43 | |
44 | - if (! isset($this->options[RelationConfig::THROUGH_FOREIGN_COLUMN])) { |
|
44 | + if (!isset($this->options[RelationConfig::THROUGH_FOREIGN_COLUMN])) { |
|
45 | 45 | $prefix = Inflector::singularize($this->foreignMapper->getTableAlias(true)); |
46 | 46 | |
47 | 47 | $this->options[RelationConfig::THROUGH_FOREIGN_COLUMN] = $this->getKeyColumn($prefix, $foreignKey); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $throughAlias = $this->getOption(RelationConfig::THROUGH_TABLE_ALIAS); |
93 | 93 | $throughName = $throughAlias ?? $through; |
94 | 94 | |
95 | - if (! empty($throughColumns)) { |
|
95 | + if (!empty($throughColumns)) { |
|
96 | 96 | $prefix = $this->getOption(RelationConfig::THROUGH_COLUMNS_PREFIX); |
97 | 97 | foreach ($throughColumns as $col) { |
98 | 98 | $query->columns("{$throughName}.{$col} AS {$prefix}{$col}"); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | if ($this->entityHasRelationLoaded($nativeEntity)) { |
151 | 151 | /** @var Collection $collection */ |
152 | 152 | $collection = $this->nativeMapper->getEntityAttribute($nativeEntity, $this->name); |
153 | - if (! $collection->contains($foreignEntity)) { |
|
153 | + if (!$collection->contains($foreignEntity)) { |
|
154 | 154 | $collection->add($foreignEntity); |
155 | 155 | } |
156 | 156 | } else { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $remainingRelations = $this->getRemainingRelations($action->getOption('relations')); |
198 | 198 | |
199 | 199 | // no cascade delete? treat as save so we can process the changes |
200 | - if (! $this->isCascade()) { |
|
200 | + if (!$this->isCascade()) { |
|
201 | 201 | $this->addActionOnSave($action); |
202 | 202 | } else { |
203 | 203 | // retrieve them again from the DB since the related collection might not have everything |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | /** @var Collection $foreignEntities */ |
221 | 221 | $foreignEntities = $this->nativeMapper->getEntityAttribute($action->getEntity(), $this->name); |
222 | - if (! $foreignEntities) { |
|
222 | + if (!$foreignEntities) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | // save the entities still in the collection |
229 | 229 | foreach ($foreignEntities as $foreignEntity) { |
230 | - if (! empty($foreignEntity->getChanges())) { |
|
230 | + if (!empty($foreignEntity->getChanges())) { |
|
231 | 231 | $saveAction = $this->foreignMapper |
232 | 232 | ->newSaveAction($foreignEntity, [ |
233 | 233 | 'relations' => $remainingRelations |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | public function __construct( |
42 | 42 | ConnectionLocator $connectionLocator, |
43 | 43 | CastingManager $castingManager = null |
44 | - ){ |
|
44 | + ) { |
|
45 | 45 | $this->connectionLocator = $connectionLocator; |
46 | 46 | |
47 | - if (! $castingManager) { |
|
47 | + if (!$castingManager) { |
|
48 | 48 | $castingManager = new CastingManager(); |
49 | 49 | } |
50 | 50 | $this->castingManager = $castingManager; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | unset($this->lazyMappers[$name]); |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! isset($this->mappers[$name]) || ! $this->mappers[$name]) { |
|
83 | + if (!isset($this->mappers[$name]) || !$this->mappers[$name]) { |
|
84 | 84 | throw new InvalidArgumentException(sprintf('Mapper named %s is not registered', $name)); |
85 | 85 | } |
86 | 86 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | $mapper = $mapperConfigOrFactory($this); |
122 | - if (! $mapper instanceof Mapper) { |
|
122 | + if (!$mapper instanceof Mapper) { |
|
123 | 123 | throw new InvalidArgumentException( |
124 | 124 | 'The mapper generated from the factory is not a valid `Mapper` instance' |
125 | 125 | ); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $mapper->entityClass = $mapperConfig->entityClass; |
139 | 139 | } |
140 | 140 | |
141 | - if ($mapperConfig->behaviours && ! empty($mapperConfig->behaviours)) { |
|
141 | + if ($mapperConfig->behaviours && !empty($mapperConfig->behaviours)) { |
|
142 | 142 | $mapper->use(...$mapperConfig->behaviours); |
143 | 143 | } |
144 | 144 | |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | { |
150 | 150 | $this->orm = $orm; |
151 | 151 | |
152 | - if (! $entityHydrator) { |
|
152 | + if (!$entityHydrator) { |
|
153 | 153 | $entityHydrator = new GenericEntityHydrator(); |
154 | 154 | $entityHydrator->setMapper($this); |
155 | 155 | $entityHydrator->setCastingManager($orm->getCastingManager()); |
156 | 156 | } |
157 | 157 | $this->entityHydrator = $entityHydrator; |
158 | 158 | |
159 | - if (! $queryBuilder) { |
|
159 | + if (!$queryBuilder) { |
|
160 | 160 | $queryBuilder = QueryBuilder::getInstance(); |
161 | 161 | } |
162 | 162 | $this->queryBuilder = $queryBuilder; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $mapper = $this; |
228 | 228 | |
229 | 229 | $singular = Inflector::singularize($this->getTableAlias(true)); |
230 | - $castingManager->register($singular, function ($value) use ($mapper, $castingManager) { |
|
230 | + $castingManager->register($singular, function($value) use ($mapper, $castingManager) { |
|
231 | 231 | if ($value instanceof $this->entityClass) { |
232 | 232 | return $value; |
233 | 233 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | }); |
237 | 237 | |
238 | 238 | $plural = $this->getTableAlias(true); |
239 | - $castingManager->register($plural, function ($values) use ($mapper, $castingManager) { |
|
239 | + $castingManager->register($plural, function($values) use ($mapper, $castingManager) { |
|
240 | 240 | if ($values instanceof Collection) { |
241 | 241 | return $values; |
242 | 242 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function getTableAlias($returnTableIfNull = false) |
274 | 274 | { |
275 | - return (! $this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
275 | + return (!$this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | public function getTableReference() |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | return null; |
342 | 342 | } |
343 | 343 | |
344 | - $receivedTracker = ! ! $tracker; |
|
345 | - if (! $tracker) { |
|
344 | + $receivedTracker = !!$tracker; |
|
345 | + if (!$tracker) { |
|
346 | 346 | $receivedTracker = false; |
347 | 347 | $tracker = new Tracker($this, [$data]); |
348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $this->injectRelations($entity, $tracker, $load); |
352 | 352 | $entity->setPersistenceState(StateEnum::SYNCHRONIZED); |
353 | 353 | |
354 | - if (! $receivedTracker) { |
|
354 | + if (!$receivedTracker) { |
|
355 | 355 | $tracker->replaceRows([$entity]); |
356 | 356 | if ($tracker->isDisposable()) { |
357 | 357 | unset($tracker); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $queryCallback = $eagerLoad[$name] ?? null; |
407 | 407 | $nextLoad = Arr::getChildren($eagerLoad, $name); |
408 | 408 | |
409 | - if (! $tracker->hasRelation($name)) { |
|
409 | + if (!$tracker->hasRelation($name)) { |
|
410 | 410 | $tracker->setRelation($name, $relation, $queryCallback); |
411 | 411 | } |
412 | 412 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | public function getRelation($name): Relation |
456 | 456 | { |
457 | - if (! $this->hasRelation($name)) { |
|
457 | + if (!$this->hasRelation($name)) { |
|
458 | 458 | throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper"); |
459 | 459 | } |
460 | 460 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $this->relations[$name] = $this->orm->createRelation($this, $name, $this->relations[$name]); |
463 | 463 | } |
464 | 464 | $relation = $this->relations[$name]; |
465 | - if (! $relation instanceof Relation) { |
|
465 | + if (!$relation instanceof Relation) { |
|
466 | 466 | throw new \InvalidArgumentException("Relation named {$name} is not a proper Relation instance"); |
467 | 467 | } |
468 | 468 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | |
517 | 517 | public function newSaveAction(EntityInterface $entity, $options): BaseAction |
518 | 518 | { |
519 | - if (! $entity->getPk()) { |
|
519 | + if (!$entity->getPk()) { |
|
520 | 520 | $action = new Insert($this, $entity, $options); |
521 | 521 | } else { |
522 | 522 | $action = new Update($this, $entity, $options); |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | protected function assertCanPersistEntity($entity) |
555 | 555 | { |
556 | - if (! $entity || ! $entity instanceof $this->entityClass) { |
|
556 | + if (!$entity || !$entity instanceof $this->entityClass) { |
|
557 | 557 | throw new \InvalidArgumentException(sprintf( |
558 | 558 | 'Mapper %s can only persist entity of class %s. %s class provided', |
559 | 559 | __CLASS__, |
@@ -22,14 +22,14 @@ |
||
22 | 22 | { |
23 | 23 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
24 | 24 | if ($this->orm->has($foreignMapper)) { |
25 | - if (! $foreignMapper instanceof Mapper) { |
|
25 | + if (!$foreignMapper instanceof Mapper) { |
|
26 | 26 | $foreignMapper = $this->orm->get($foreignMapper); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | $type = $options[RelationConfig::TYPE]; |
30 | 30 | $relationClass = __NAMESPACE__ . '\\' . Str::className($type); |
31 | 31 | |
32 | - if (! class_exists($relationClass)) { |
|
32 | + if (!class_exists($relationClass)) { |
|
33 | 33 | throw new \InvalidArgumentException("{$relationClass} does not exist"); |
34 | 34 | } |
35 | 35 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function hydrate(array $attributes = []) |
33 | 33 | { |
34 | 34 | $attributes = $this->castingManager |
35 | - ->castArray($attributes, $this->mapper->getCasts()); |
|
35 | + ->castArray($attributes, $this->mapper->getCasts()); |
|
36 | 36 | $attributes = Arr::renameKeys($attributes, $this->mapper->getColumnAttributeMap()); |
37 | 37 | $class = $this->mapper->getEntityClass() ?? GenericEntity::class; |
38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | array_flip($this->mapper->getColumnAttributeMap()) |
47 | 47 | ); |
48 | 48 | $data = $this->castingManager |
49 | - ->castArrayForDb($data, $this->mapper->getCasts()); |
|
49 | + ->castArrayForDb($data, $this->mapper->getCasts()); |
|
50 | 50 | |
51 | 51 | return Arr::only($data, $this->mapper->getColumns()); |
52 | 52 | } |