@@ -60,7 +60,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -23,28 +23,28 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -40,12 +40,12 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** @var Query $query */ |
| 88 | - $query = $aggregate->getQuery($this); |
|
| 88 | + $query = $aggregate->getQuery($this); |
|
| 89 | 89 | |
| 90 | - $results = $query->fetchAll(); |
|
| 90 | + $results = $query->fetchAll(); |
|
| 91 | 91 | $this->aggregateResults[$name] = $results instanceof Collection ? $results->getValues() : $results; |
| 92 | 92 | |
| 93 | 93 | return $this->aggregateResults[$name]; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $queryNextLoad = $this->relationNextLoad[$name] ?? []; |
| 161 | - if ($queryNextLoad && ! empty($queryNextLoad)) { |
|
| 161 | + if ($queryNextLoad && !empty($queryNextLoad)) { |
|
| 162 | 162 | foreach ($queryNextLoad as $next => $callback) { |
| 163 | 163 | $query = $query->load([$next => $callback]); |
| 164 | 164 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | protected function setOptionIfMissing($name, $value) |
| 65 | 65 | { |
| 66 | - if (! isset($this->options[$name])) { |
|
| 66 | + if (!isset($this->options[$name])) { |
|
| 67 | 67 | $this->options[$name] = $value; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function getRemainingRelations($relations) |
| 238 | 238 | { |
| 239 | - if (! is_array($relations)) { |
|
| 239 | + if (!is_array($relations)) { |
|
| 240 | 240 | return $relations; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | if (is_array($guards)) { |
| 258 | 258 | foreach ($guards as $col => $val) { |
| 259 | 259 | // guards that are strings (eg: 'deleted_at is null') can't be used as extra columns |
| 260 | - if (! is_int($col)) { |
|
| 260 | + if (!is_int($col)) { |
|
| 261 | 261 | $cols[$col] = $val; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | |
| 29 | 29 | $insertSql = new \Sirius\Sql\Insert($connection); |
| 30 | 30 | $insertSql->into($this->mapper->getTable()) |
| 31 | - ->columns($columns); |
|
| 31 | + ->columns($columns); |
|
| 32 | 32 | $insertSql->perform(); |
| 33 | 33 | $this->mapper->setEntityPk($this->entity, $connection->lastInsertId()); |
| 34 | 34 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | public function revert() |
| 37 | 37 | { |
| 38 | - if (! $this->hasRun) { |
|
| 38 | + if (!$this->hasRun) { |
|
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | 41 | $this->mapper->setEntityPk($this->entity, $this->entityId); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function joinWith($name): Query |
| 81 | 81 | { |
| 82 | - if (! $this->mapper->hasRelation($name)) { |
|
| 82 | + if (!$this->mapper->hasRelation($name)) { |
|
| 83 | 83 | throw new \InvalidArgumentException( |
| 84 | 84 | sprintf("Relation %s, not defined for %s", $name, $this->mapper->getTable()) |
| 85 | 85 | ); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | public function chunk(int $size, callable $callback, int $limit = 100000) |
| 142 | 142 | { |
| 143 | 143 | if (!$this->orderBy->build()) { |
| 144 | - $this->orderBy(...(array) $this->mapper->getPrimaryKey()); |
|
| 144 | + $this->orderBy(...(array)$this->mapper->getPrimaryKey()); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $run = 0; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $value = $this->castAttribute($attribute, $value); |
| 85 | - if (! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
| 85 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
| 86 | 86 | $this->changed[$attribute] = true; |
| 87 | 87 | $this->state = StateEnum::CHANGED; |
| 88 | 88 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | protected function get($attribute) |
| 95 | 95 | { |
| 96 | - if (! $attribute) { |
|
| 96 | + if (!$attribute) { |
|
| 97 | 97 | return null; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public function getPersistenceState() |
| 106 | 106 | { |
| 107 | - if (! empty($this->changed)) { |
|
| 107 | + if (!empty($this->changed)) { |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return $this->state; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $changes = $this->changed; |
| 135 | 135 | foreach ($this->attributes as $name => $value) { |
| 136 | 136 | if (is_object($value) && method_exists($value, 'getChanges')) { |
| 137 | - if (! empty($value->getChanges())) { |
|
| 137 | + if (!empty($value->getChanges())) { |
|
| 138 | 138 | $changes[$name] = true; |
| 139 | 139 | } |
| 140 | 140 | } |