@@ -88,7 +88,7 @@ |
||
88 | 88 | |
89 | 89 | public function isLazyLoad() |
90 | 90 | { |
91 | - return ! isset($this->options[RelationConfig::LOAD_STRATEGY]) || |
|
91 | + return !isset($this->options[RelationConfig::LOAD_STRATEGY]) || |
|
92 | 92 | $this->options[RelationConfig::LOAD_STRATEGY] == RelationConfig::LOAD_LAZY; |
93 | 93 | } |
94 | 94 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ->newQuery(); |
59 | 59 | |
60 | 60 | $query = $this->joinWithThroughTable($query) |
61 | - ->where($this->options[RelationConfig::THROUGH_NATIVE_COLUMN], $nativePks); |
|
61 | + ->where($this->options[RelationConfig::THROUGH_NATIVE_COLUMN], $nativePks); |
|
62 | 62 | |
63 | 63 | $query = $this->applyQueryCallback($query); |
64 | 64 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | $subselect = $this->foreignMapper->newQuery(); |
112 | 112 | $subselect = $query->subSelectForJoinWith($this->foreignMapper) |
113 | - ->as($reference); |
|
113 | + ->as($reference); |
|
114 | 114 | #$subselect->resetGuards(); |
115 | 115 | #$subselect->setGuards($this->foreignMapper->getConfig()->getGuards()); |
116 | 116 |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | parent::applyDefaults(); |
22 | 22 | |
23 | 23 | $foreignKey = $this->foreignMapper->getConfig()->getPrimaryKey(); |
24 | - if ( ! isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
24 | + if (!isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
25 | 25 | $this->options[RelationConfig::FOREIGN_KEY] = $foreignKey; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $nativeKey = $this->foreignMapper->getConfig()->getPrimaryKey(); |
29 | - if ( ! isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
29 | + if (!isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
30 | 30 | $this->options[RelationConfig::NATIVE_KEY] = $nativeKey; |
31 | 31 | } |
32 | 32 | |
33 | - if ( ! isset($this->options[RelationConfig::THROUGH_TABLE])) { |
|
33 | + if (!isset($this->options[RelationConfig::THROUGH_TABLE])) { |
|
34 | 34 | $tables = [$this->foreignMapper->getConfig()->getTable(), $this->nativeMapper->getConfig()->getTable()]; |
35 | 35 | sort($tables); |
36 | 36 | $this->options[RelationConfig::THROUGH_TABLE] = implode('_', $tables); |
37 | 37 | } |
38 | 38 | |
39 | - if ( ! isset($this->options[RelationConfig::THROUGH_NATIVE_COLUMN])) { |
|
39 | + if (!isset($this->options[RelationConfig::THROUGH_NATIVE_COLUMN])) { |
|
40 | 40 | $prefix = Inflector::singularize($this->nativeMapper->getConfig()->getTableAlias(true)); |
41 | 41 | |
42 | 42 | $this->options[RelationConfig::THROUGH_NATIVE_COLUMN] = $this->getKeyColumn($prefix, $nativeKey); |
43 | 43 | } |
44 | 44 | |
45 | - if ( ! isset($this->options[RelationConfig::THROUGH_FOREIGN_COLUMN])) { |
|
45 | + if (!isset($this->options[RelationConfig::THROUGH_FOREIGN_COLUMN])) { |
|
46 | 46 | $prefix = Inflector::singularize($this->foreignMapper->getConfig()->getTableAlias(true)); |
47 | 47 | |
48 | 48 | $this->options[RelationConfig::THROUGH_FOREIGN_COLUMN] = $this->getKeyColumn($prefix, $foreignKey); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $throughAlias = $this->getOption(RelationConfig::THROUGH_TABLE_ALIAS); |
94 | 94 | $throughName = $throughAlias ?? $through; |
95 | 95 | |
96 | - if ( ! empty($throughColumns)) { |
|
96 | + if (!empty($throughColumns)) { |
|
97 | 97 | foreach ($throughColumns as $col => $alias) { |
98 | 98 | $query->columns("{$throughName}.{$col} AS {$alias}"); |
99 | 99 | } |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | |
154 | 154 | $found = $result[$nativeId] ?? []; |
155 | 155 | |
156 | - if ( ! empty($found) && $this->entityHasRelationLoaded($nativeEntity)) { |
|
156 | + if (!empty($found) && $this->entityHasRelationLoaded($nativeEntity)) { |
|
157 | 157 | /** @var Collection $collection */ |
158 | 158 | $collection = $this->nativeEntityHydrator->get($nativeEntity, $this->name); |
159 | 159 | foreach ($found as $foreignEntity) { |
160 | - if ( ! $collection->contains($foreignEntity)) { |
|
160 | + if (!$collection->contains($foreignEntity)) { |
|
161 | 161 | $collection->add($foreignEntity); |
162 | 162 | } |
163 | 163 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $remainingRelations = $this->getRemainingRelations($action->getOption('relations')); |
208 | 208 | |
209 | 209 | // no cascade delete? treat as save so we can process the changes |
210 | - if ( ! $this->isCascade()) { |
|
210 | + if (!$this->isCascade()) { |
|
211 | 211 | $this->addActionOnSave($action); |
212 | 212 | } else { |
213 | 213 | // retrieve them again from the DB since the related collection might not have everything |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | protected function addActionOnSave(BaseAction $action) |
229 | 229 | { |
230 | - if ( ! $action->includesRelation($this->name)) { |
|
230 | + if (!$action->includesRelation($this->name)) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | /** @var Collection $foreignEntities */ |
237 | 237 | $foreignEntities = $this->nativeEntityHydrator->get($action->getEntity(), $this->name); |
238 | - if ( ! $foreignEntities || !$foreignEntities instanceof Collection || $foreignEntities->isEmpty()) { |
|
238 | + if (!$foreignEntities || !$foreignEntities instanceof Collection || $foreignEntities->isEmpty()) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | // save the entities still in the collection |
245 | 245 | foreach ($foreignEntities as $foreignEntity) { |
246 | - if ( ! empty($foreignEntity->getChanges())) { |
|
246 | + if (!empty($foreignEntity->getChanges())) { |
|
247 | 247 | $saveAction = $this->foreignMapper |
248 | 248 | ->newSaveAction($foreignEntity, [ |
249 | 249 | 'relations' => $remainingRelations |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | unset($this->lazyMappers[$name]); |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! isset($this->mappers[$name]) || ! $this->mappers[$name]) { |
|
93 | + if (!isset($this->mappers[$name]) || !$this->mappers[$name]) { |
|
94 | 94 | throw new InvalidArgumentException(sprintf('Mapper named %s is not registered', $name)); |
95 | 95 | } |
96 | 96 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | { |
122 | 122 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
123 | 123 | if ($this->has($foreignMapper)) { |
124 | - if ( ! $foreignMapper instanceof Mapper) { |
|
124 | + if (!$foreignMapper instanceof Mapper) { |
|
125 | 125 | $foreignMapper = $this->get($foreignMapper); |
126 | 126 | } |
127 | 127 | } |
128 | 128 | $type = $options[RelationConfig::TYPE]; |
129 | 129 | $relationClass = 'Sirius\\Orm\\Relation\\' . Str::className($type); |
130 | 130 | |
131 | - if ( ! class_exists($relationClass)) { |
|
131 | + if (!class_exists($relationClass)) { |
|
132 | 132 | throw new InvalidArgumentException("{$relationClass} does not exist"); |
133 | 133 | } |
134 | 134 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | $mapper = $mapperConfigOrFactory($this); |
152 | - if ( ! $mapper instanceof Mapper) { |
|
152 | + if (!$mapper instanceof Mapper) { |
|
153 | 153 | throw new InvalidArgumentException( |
154 | 154 | 'The mapper generated from the factory is not a valid `Mapper` instance' |
155 | 155 | ); |
@@ -43,7 +43,7 @@ |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | if ($action instanceof Update && $this->updateColumn) { |
46 | - if ( ! empty($action->getEntity()->getChanges())) { |
|
46 | + if (!empty($action->getEntity()->getChanges())) { |
|
47 | 47 | $action->addColumns([$this->updateColumn => $now]); |
48 | 48 | } |
49 | 49 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | $changes = $this->changed; |
77 | 77 | foreach ($this->attributes as $name => $value) { |
78 | 78 | if (is_object($value) && method_exists($value, 'getChanges')) { |
79 | - if ( ! empty($value->getChanges())) { |
|
79 | + if (!empty($value->getChanges())) { |
|
80 | 80 | $changes[$name] = true; |
81 | 81 | } |
82 | 82 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $this->relations[$name] = $relation; |
64 | 64 | $this->relationCallback[$name] = $callback; |
65 | - if ( ! empty($nextLoad)) { |
|
65 | + if (!empty($nextLoad)) { |
|
66 | 66 | $this->relationNextLoad[$name] = $nextLoad; |
67 | 67 | } |
68 | 68 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function getResultsForRelation($name) |
76 | 76 | { |
77 | - if ( ! isset($this->relations[$name])) { |
|
77 | + if (!isset($this->relations[$name])) { |
|
78 | 78 | return []; |
79 | 79 | } |
80 | 80 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $result = []; |
112 | 112 | foreach ($this->rows as $row) { |
113 | 113 | $value = $this->getColumnsFromRow($row, $columns); |
114 | - if ($value && ! in_array($value, $result)) { |
|
114 | + if ($value && !in_array($value, $result)) { |
|
115 | 115 | $result[] = $value; |
116 | 116 | } |
117 | 117 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | public function getLazyAggregate(Aggregate $aggregate) |
143 | 143 | { |
144 | 144 | $name = $aggregate->getName(); |
145 | - if ( ! isset($this->lazyAggregates[$name])) { |
|
145 | + if (!isset($this->lazyAggregates[$name])) { |
|
146 | 146 | $this->lazyAggregates[$name] = new LazyAggregate($this, $aggregate); |
147 | 147 | } |
148 | 148 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public function getLazyRelation(Relation $relation) |
153 | 153 | { |
154 | 154 | $name = $relation->getOption('name'); |
155 | - if ( ! isset($this->lazyRelations[$name])) { |
|
155 | + if (!isset($this->lazyRelations[$name])) { |
|
156 | 156 | $this->lazyRelations[$name] = new LazyRelation($this, $relation); |
157 | 157 | } |
158 | 158 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | $queryNextLoad = $this->relationNextLoad[$name] ?? []; |
191 | - if ($queryNextLoad && ! empty($queryNextLoad)) { |
|
191 | + if ($queryNextLoad && !empty($queryNextLoad)) { |
|
192 | 192 | foreach ($queryNextLoad as $next => $callback) { |
193 | 193 | $query = $query->load([$next => $callback]); |
194 | 194 | } |
@@ -70,16 +70,16 @@ |
||
70 | 70 | $this->preventChangesIfDeleted(); |
71 | 71 | |
72 | 72 | $value = $this->castAttribute($attribute, $value); |
73 | - if ( ! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
73 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
74 | 74 | $this->markChanged($attribute); |
75 | - $this->state = StateEnum::CHANGED; |
|
75 | + $this->state = StateEnum::CHANGED; |
|
76 | 76 | } |
77 | 77 | $this->attributes[$attribute] = $value; |
78 | 78 | } |
79 | 79 | |
80 | 80 | protected function get($attribute) |
81 | 81 | { |
82 | - if ( ! $attribute) { |
|
82 | + if (!$attribute) { |
|
83 | 83 | return null; |
84 | 84 | } |
85 | 85 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | $value = $this->castAttribute($attribute, $value); |
60 | - if ( ! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
60 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
61 | 61 | $this->markChanged($attribute); |
62 | 62 | $this->state = StateEnum::CHANGED; |
63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | protected function get($attribute) |
70 | 70 | { |
71 | - if ( ! $attribute) { |
|
71 | + if (!$attribute) { |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function newSaveAction(EntityInterface $entity, $options) |
53 | 53 | { |
54 | - if ( ! $this->getHydrator()->getPk($entity) || $entity->getState() == StateEnum::NEW) { |
|
54 | + if (!$this->getHydrator()->getPk($entity) || $entity->getState() == StateEnum::NEW) { |
|
55 | 55 | $action = new Insert($this, $entity, $options); |
56 | 56 | } else { |
57 | 57 | $action = new Update($this, $entity, $options); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | protected function assertCanPersistEntity($entity) |
103 | 103 | { |
104 | 104 | $entityClass = $this->mapperConfig->getEntityClass(); |
105 | - if ( ! $entity || ! $entity instanceof $entityClass) { |
|
105 | + if (!$entity || !$entity instanceof $entityClass) { |
|
106 | 106 | throw new \InvalidArgumentException(sprintf( |
107 | 107 | 'Mapper %s can only persist entity of class %s. %s class provided', |
108 | 108 | __CLASS__, |