Completed
Branch master (19da56)
by Adrian
01:49
created
src/Relation/Aggregate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
     {
85 85
         $keys = $this->relation->getKeyPairs();
86 86
         foreach ($keys as $nativeCol => $foreignCol) {
87
-            $entityValue  = $this->relation->getNativeMapper()->getEntityAttribute($entity, $nativeCol);
87
+            $entityValue = $this->relation->getNativeMapper()->getEntityAttribute($entity, $nativeCol);
88 88
             $rowValue = $row[$foreignCol];
89 89
             // if both native and foreign key values are present (not unlinked entities) they must be the same
90 90
             // otherwise we assume that the entities can be linked together
Please login to merge, or discard this patch.
src/Action/DeletePivotRows.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
         }
40 40
 
41 41
         $delete = new \Sirius\Sql\Delete($this->mapper->getWriteConnection());
42
-        $delete->from((string) $this->relation->getOption(RelationConfig::THROUGH_TABLE));
42
+        $delete->from((string)$this->relation->getOption(RelationConfig::THROUGH_TABLE));
43 43
         $delete->whereAll($conditions, false);
44 44
 
45 45
         $delete->perform();
Please login to merge, or discard this patch.
src/Entity/Tracker.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function __construct(array $rows = [])
42 42
     {
43
-        $this->rows   = $rows;
43
+        $this->rows = $rows;
44 44
     }
45 45
 
46 46
     public function setRelation($name, Relation $relation, $callback, array $nextLoad = [], $overwrite = false)
47 47
     {
48
-        if ($overwrite || ! isset($this->relations[$name])) {
48
+        if ($overwrite || !isset($this->relations[$name])) {
49 49
             $this->relations[$name]        = $relation;
50 50
             $this->relationCallback[$name] = $callback;
51 51
             if (!empty($nextLoad)) {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function getResultsForRelation($name)
63 63
     {
64
-        if (! isset($this->relations[$name])) {
64
+        if (!isset($this->relations[$name])) {
65 65
             return [];
66 66
         }
67 67
 
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         }
98 98
 
99 99
         /** @var Query $query */
100
-        $query         = $aggregate->getQuery($this);
100
+        $query = $aggregate->getQuery($this);
101 101
 
102
-        $results                      = $query->fetchAll();
102
+        $results = $query->fetchAll();
103 103
         $this->aggregateResults[$name] = $results instanceof Collection ? $results->getValues() : $results;
104 104
 
105 105
         return $this->aggregateResults[$name];
Please login to merge, or discard this patch.
src/Mapper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $mapper->entityClass = $mapperConfig->entityClass;
145 145
         }
146 146
 
147
-        if (isset($mapperConfig->behaviours) && ! empty($mapperConfig->behaviours)) {
147
+        if (isset($mapperConfig->behaviours) && !empty($mapperConfig->behaviours)) {
148 148
             $mapper->use(...$mapperConfig->behaviours);
149 149
         }
150 150
 
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
     {
156 156
         $this->orm = $orm;
157 157
 
158
-        if (! $entityHydrator) {
158
+        if (!$entityHydrator) {
159 159
             $entityHydrator = new GenericEntityHydrator();
160 160
             $entityHydrator->setMapper($this);
161 161
             $entityHydrator->setCastingManager($orm->getCastingManager());
162 162
         }
163 163
         $this->entityHydrator = $entityHydrator;
164 164
 
165
-        if (! $queryBuilder) {
165
+        if (!$queryBuilder) {
166 166
             $queryBuilder = QueryBuilder::getInstance();
167 167
         }
168 168
         $this->queryBuilder = $queryBuilder;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         $mapper = $this;
234 234
 
235 235
         $singular = Inflector::singularize($this->getTableAlias(true));
236
-        $castingManager->register($singular, function ($value) use ($mapper) {
236
+        $castingManager->register($singular, function($value) use ($mapper) {
237 237
             if ($value instanceof $this->entityClass) {
238 238
                 return $value;
239 239
             }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         });
243 243
 
244 244
         $plural = $this->getTableAlias(true);
245
-        $castingManager->register($plural, function ($values) use ($mapper) {
245
+        $castingManager->register($plural, function($values) use ($mapper) {
246 246
             if ($values instanceof Collection) {
247 247
                 return $values;
248 248
             }
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      */
279 279
     public function getTableAlias($returnTableIfNull = false)
280 280
     {
281
-        return (! $this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias;
281
+        return (!$this->tableAlias && $returnTableIfNull) ? $this->table : $this->tableAlias;
282 282
     }
283 283
 
284 284
     public function getTableReference()
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
             return null;
348 348
         }
349 349
 
350
-        $receivedTracker = ! ! $tracker;
351
-        if (! $tracker) {
350
+        $receivedTracker = !!$tracker;
351
+        if (!$tracker) {
352 352
             $receivedTracker = false;
353 353
             $tracker         = new Tracker([$data]);
354 354
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         $this->injectAggregates($entity, $tracker, $load);
359 359
         $entity->setPersistenceState(StateEnum::SYNCHRONIZED);
360 360
 
361
-        if (! $receivedTracker) {
361
+        if (!$receivedTracker) {
362 362
             $tracker->replaceRows([$entity]);
363 363
         }
364 364
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             $queryCallback = $eagerLoad[$name] ?? null;
404 404
             $nextLoad      = Arr::getChildren($eagerLoad, $name);
405 405
 
406
-            if (! $tracker->hasRelation($name)) {
406
+            if (!$tracker->hasRelation($name)) {
407 407
                 $tracker->setRelation($name, $relation, $queryCallback, $nextLoad);
408 408
             }
409 409
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     protected function injectAggregates(EntityInterface $entity, Tracker $tracker, array $eagerLoad = [])
421 421
     {
422 422
         foreach (array_keys($this->relations) as $name) {
423
-            $relation      = $this->getRelation($name);
423
+            $relation = $this->getRelation($name);
424 424
             if (!method_exists($relation, 'getAggregates')) {
425 425
                 continue;
426 426
             }
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
     public function getRelation($name): Relation
471 471
     {
472
-        if (! $this->hasRelation($name)) {
472
+        if (!$this->hasRelation($name)) {
473 473
             throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper");
474 474
         }
475 475
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
             $this->relations[$name] = $this->orm->createRelation($this, $name, $this->relations[$name]);
478 478
         }
479 479
         $relation = $this->relations[$name];
480
-        if (! $relation instanceof Relation) {
480
+        if (!$relation instanceof Relation) {
481 481
             throw new \InvalidArgumentException("Relation named {$name} is not a proper Relation instance");
482 482
         }
483 483
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 
532 532
     public function newSaveAction(EntityInterface $entity, $options): Update
533 533
     {
534
-        if (! $this->getEntityAttribute($entity, $this->primaryKey)) {
534
+        if (!$this->getEntityAttribute($entity, $this->primaryKey)) {
535 535
             $action = new Insert($this, $entity, $options);
536 536
         } else {
537 537
             $action = new Update($this, $entity, $options);
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 
569 569
     protected function assertCanPersistEntity($entity)
570 570
     {
571
-        if (! $entity || ! $entity instanceof $this->entityClass) {
571
+        if (!$entity || !$entity instanceof $this->entityClass) {
572 572
             throw new \InvalidArgumentException(sprintf(
573 573
                 'Mapper %s can only persist entity of class %s. %s class provided',
574 574
                 __CLASS__,
Please login to merge, or discard this patch.
src/Relation/ManyToOne.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
     public function joinSubselect(Query $query, string $reference)
29 29
     {
30 30
         $subselect = $query->subSelectForJoinWith()
31
-                           ->from($this->foreignMapper->getTable())
32
-                           ->columns($this->foreignMapper->getTable() . '.*')
33
-                           ->as($reference);
31
+                            ->from($this->foreignMapper->getTable())
32
+                            ->columns($this->foreignMapper->getTable() . '.*')
33
+                            ->as($reference);
34 34
 
35 35
         $subselect = $this->applyQueryCallback($subselect);
36 36
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             $this->addActionOnSave($action);
109 109
         } else {
110 110
             $foreignEntity = $this->nativeMapper
111
-                                  ->getEntityAttribute($action->getEntity(), $this->name);
111
+                                    ->getEntityAttribute($action->getEntity(), $this->name);
112 112
 
113 113
             if ($foreignEntity) {
114 114
                 $remainingRelations = $this->getRemainingRelations($action->getOption('relations'));
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
         parent::applyDefaults();
16 16
 
17 17
         $foreignKey = $this->foreignMapper->getPrimaryKey();
18
-        if (! isset($this->options[RelationConfig::FOREIGN_KEY])) {
18
+        if (!isset($this->options[RelationConfig::FOREIGN_KEY])) {
19 19
             $this->options[RelationConfig::FOREIGN_KEY] = $foreignKey;
20 20
         }
21 21
 
22
-        if (! isset($this->options[RelationConfig::NATIVE_KEY])) {
22
+        if (!isset($this->options[RelationConfig::NATIVE_KEY])) {
23 23
             $nativeKey                                 = $this->getKeyColumn($this->name, $foreignKey);
24 24
             $this->options[RelationConfig::NATIVE_KEY] = $nativeKey;
25 25
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $state = $foreignEntity->getPersistenceState();
88 88
         $foreignEntity->setPersistenceState(StateEnum::SYNCHRONIZED);
89 89
 
90
-        $nativeKey  = (array)$this->getOption(RelationConfig::NATIVE_KEY);
90
+        $nativeKey = (array)$this->getOption(RelationConfig::NATIVE_KEY);
91 91
 
92 92
         foreach ($nativeKey as $k => $col) {
93 93
             $this->nativeMapper->setEntityAttribute(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     protected function addActionOnDelete(BaseAction $action)
105 105
     {
106 106
         // no cascade delete? treat it as a save
107
-        if (! $this->isCascade()) {
107
+        if (!$this->isCascade()) {
108 108
             $this->addActionOnSave($action);
109 109
         } else {
110 110
             $foreignEntity = $this->nativeMapper
Please login to merge, or discard this patch.
src/Relation/OneToOne.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             $this->addActionOnSave($action);
35 35
         } else {
36 36
             $foreignEntity = $this->nativeMapper
37
-                                  ->getEntityAttribute($action->getEntity(), $this->name);
37
+                                    ->getEntityAttribute($action->getEntity(), $this->name);
38 38
 
39 39
             if ($foreignEntity) {
40 40
                 $remainingRelations = $this->getRemainingRelations($action->getOption('relations'));
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
             $foreignEntity = $this->nativeMapper
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Relation/ManyToMany.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             ->newQuery();
61 61
 
62 62
         $query = $this->joinWithThroughTable($query)
63
-                      ->where($this->options[RelationConfig::THROUGH_NATIVE_COLUMN], $nativePks);
63
+                        ->where($this->options[RelationConfig::THROUGH_NATIVE_COLUMN], $nativePks);
64 64
 
65 65
         $query = $this->applyQueryCallback($query);
66 66
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
     public function joinSubselect(Query $query, string $reference)
113 113
     {
114 114
         $subselect = $query->subSelectForJoinWith()
115
-                           ->from($this->foreignMapper->getTable())
116
-                           ->columns($this->foreignMapper->getTable() . '.*')
117
-                           ->as($reference);
115
+                            ->from($this->foreignMapper->getTable())
116
+                            ->columns($this->foreignMapper->getTable() . '.*')
117
+                            ->as($reference);
118 118
 
119 119
         $subselect = $this->joinWithThroughTable($subselect);
120 120
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,28 +23,28 @@  discard block
 block discarded – undo
23 23
         $this->setOptionIfMissing(RelationConfig::THROUGH_COLUMNS_PREFIX, 'pivot_');
24 24
 
25 25
         $foreignKey = $this->foreignMapper->getPrimaryKey();
26
-        if (! isset($this->options[RelationConfig::FOREIGN_KEY])) {
26
+        if (!isset($this->options[RelationConfig::FOREIGN_KEY])) {
27 27
             $this->options[RelationConfig::FOREIGN_KEY] = $foreignKey;
28 28
         }
29 29
 
30 30
         $nativeKey = $this->foreignMapper->getPrimaryKey();
31
-        if (! isset($this->options[RelationConfig::NATIVE_KEY])) {
31
+        if (!isset($this->options[RelationConfig::NATIVE_KEY])) {
32 32
             $this->options[RelationConfig::NATIVE_KEY] = $nativeKey;
33 33
         }
34 34
 
35
-        if (! isset($this->options[RelationConfig::THROUGH_TABLE])) {
35
+        if (!isset($this->options[RelationConfig::THROUGH_TABLE])) {
36 36
             $tables = [$this->foreignMapper->getTable(), $this->nativeMapper->getTable()];
37 37
             sort($tables);
38 38
             $this->options[RelationConfig::THROUGH_TABLE] = implode('_', $tables);
39 39
         }
40 40
 
41
-        if (! isset($this->options[RelationConfig::THROUGH_NATIVE_COLUMN])) {
41
+        if (!isset($this->options[RelationConfig::THROUGH_NATIVE_COLUMN])) {
42 42
             $prefix = Inflector::singularize($this->nativeMapper->getTableAlias(true));
43 43
 
44 44
             $this->options[RelationConfig::THROUGH_NATIVE_COLUMN] = $this->getKeyColumn($prefix, $nativeKey);
45 45
         }
46 46
 
47
-        if (! isset($this->options[RelationConfig::THROUGH_FOREIGN_COLUMN])) {
47
+        if (!isset($this->options[RelationConfig::THROUGH_FOREIGN_COLUMN])) {
48 48
             $prefix = Inflector::singularize($this->foreignMapper->getTableAlias(true));
49 49
 
50 50
             $this->options[RelationConfig::THROUGH_FOREIGN_COLUMN] = $this->getKeyColumn($prefix, $foreignKey);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $throughAlias = $this->getOption(RelationConfig::THROUGH_TABLE_ALIAS);
96 96
         $throughName  = $throughAlias ?? $through;
97 97
 
98
-        if (! empty($throughColumns)) {
98
+        if (!empty($throughColumns)) {
99 99
             $prefix = $this->getOption(RelationConfig::THROUGH_COLUMNS_PREFIX);
100 100
             foreach ($throughColumns as $col) {
101 101
                 $query->columns("{$throughName}.{$col} AS {$prefix}{$col}");
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             /** @var Collection $collection */
150 150
             $collection = $this->nativeMapper->getEntityAttribute($nativeEntity, $this->name);
151 151
             foreach ($found as $foreignEntity) {
152
-                if (! $collection->contains($foreignEntity)) {
152
+                if (!$collection->contains($foreignEntity)) {
153 153
                     $collection->add($foreignEntity);
154 154
                 }
155 155
             }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $remainingRelations = $this->getRemainingRelations($action->getOption('relations'));
197 197
 
198 198
         // no cascade delete? treat as save so we can process the changes
199
-        if (! $this->isCascade()) {
199
+        if (!$this->isCascade()) {
200 200
             $this->addActionOnSave($action);
201 201
         } else {
202 202
             // retrieve them again from the DB since the related collection might not have everything
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $remainingRelations = $this->getRemainingRelations($action->getOption('relations'));
220 220
 
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
 block discarded – undo
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
Please login to merge, or discard this patch.