| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | 76 | $value = $this->castAttribute($attribute, $value); | 
| 77 | -        if (! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { | |
| 77 | +        if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { | |
| 78 | 78 | $this->changed[$attribute] = true; | 
| 79 | 79 | $this->state = StateEnum::CHANGED; | 
| 80 | 80 | } | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 | |
| 86 | 86 | public function get($attribute) | 
| 87 | 87 |      { | 
| 88 | -        if (! $attribute) { | |
| 88 | +        if (!$attribute) { | |
| 89 | 89 | return null; | 
| 90 | 90 | } | 
| 91 | 91 | |
| @@ -96,7 +96,7 @@ discard block | ||
| 96 | 96 | |
| 97 | 97 | public function getPersistanceState() | 
| 98 | 98 |      { | 
| 99 | -        if (! empty($this->changed)) { | |
| 99 | +        if (!empty($this->changed)) { | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 | return $this->state; | 
| @@ -120,7 +120,7 @@ discard block | ||
| 120 | 120 | $changes = $this->changed; | 
| 121 | 121 |          foreach ($this->attributes as $name => $value) { | 
| 122 | 122 |              if (is_object($value) && method_exists($value, 'getChanges')) { | 
| 123 | -                if (! empty($value->getChanges())) { | |
| 123 | +                if (!empty($value->getChanges())) { | |
| 124 | 124 | $changes[$name] = true; | 
| 125 | 125 | } | 
| 126 | 126 | } | 
| @@ -56,7 +56,7 @@ | ||
| 56 | 56 | ->newQuery(); | 
| 57 | 57 | |
| 58 | 58 | $query = $this->joinWithThroughTable($query) | 
| 59 | - ->where($this->options[RelationOption::THROUGH_NATIVE_COLUMN], $nativePks); | |
| 59 | + ->where($this->options[RelationOption::THROUGH_NATIVE_COLUMN], $nativePks); | |
| 60 | 60 | |
| 61 | 61 | if ($this->getOption(RelationOption::QUERY_CALLBACK) && | 
| 62 | 62 |              is_callable($this->getOption(RelationOption::QUERY_CALLBACK))) { | 
| @@ -19,28 +19,28 @@ discard block | ||
| 19 | 19 | $this->setOptionIfMissing(RelationOption::THROUGH_COLUMNS_PREFIX, 'pivot_'); | 
| 20 | 20 | |
| 21 | 21 | $foreignKey = $this->foreignMapper->getPrimaryKey(); | 
| 22 | -        if (! isset($this->options[RelationOption::FOREIGN_KEY])) { | |
| 22 | +        if (!isset($this->options[RelationOption::FOREIGN_KEY])) { | |
| 23 | 23 | $this->options[RelationOption::FOREIGN_KEY] = $foreignKey; | 
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | $nativeKey = $this->foreignMapper->getPrimaryKey(); | 
| 27 | -        if (! isset($this->options[RelationOption::NATIVE_KEY])) { | |
| 27 | +        if (!isset($this->options[RelationOption::NATIVE_KEY])) { | |
| 28 | 28 | $this->options[RelationOption::NATIVE_KEY] = $nativeKey; | 
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | -        if (! isset($this->options[RelationOption::THROUGH_TABLE])) { | |
| 31 | +        if (!isset($this->options[RelationOption::THROUGH_TABLE])) { | |
| 32 | 32 | $tables = [$this->foreignMapper->getTable(), $this->nativeMapper->getTable()]; | 
| 33 | 33 | sort($tables); | 
| 34 | 34 |              $this->options[RelationOption::THROUGH_TABLE] = implode('_', $tables); | 
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | -        if (! isset($this->options[RelationOption::THROUGH_NATIVE_COLUMN])) { | |
| 37 | +        if (!isset($this->options[RelationOption::THROUGH_NATIVE_COLUMN])) { | |
| 38 | 38 | $prefix = Inflector::singularize($this->nativeMapper->getTableAlias(true)); | 
| 39 | 39 | |
| 40 | 40 | $this->options[RelationOption::THROUGH_NATIVE_COLUMN] = $this->getKeyColumn($prefix, $nativeKey); | 
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | -        if (! isset($this->options[RelationOption::THROUGH_FOREIGN_COLUMN])) { | |
| 43 | +        if (!isset($this->options[RelationOption::THROUGH_FOREIGN_COLUMN])) { | |
| 44 | 44 | $prefix = Inflector::singularize($this->foreignMapper->getTableAlias(true)); | 
| 45 | 45 | |
| 46 | 46 | $this->options[RelationOption::THROUGH_FOREIGN_COLUMN] = $this->getKeyColumn($prefix, $foreignKey); | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | $throughAlias = $this->getOption(RelationOption::THROUGH_TABLE_ALIAS); | 
| 101 | 101 | $throughName = $throughAlias ?? $through; | 
| 102 | 102 | |
| 103 | -        if (! empty($throughColumns)) { | |
| 103 | +        if (!empty($throughColumns)) { | |
| 104 | 104 | $prefix = $this->getOption(RelationOption::THROUGH_COLUMNS_PREFIX); | 
| 105 | 105 |              foreach ($throughColumns as $col) { | 
| 106 | 106 |                  $query->columns("{$throughName}.{$col} AS {$prefix}{$col}"); | 
| @@ -143,7 +143,7 @@ discard block | ||
| 143 | 143 | public function attachEntities(EntityInterface $nativeEntity, EntityInterface $foreignEntity) | 
| 144 | 144 |      { | 
| 145 | 145 |          foreach ($this->keyPairs as $nativeCol => $foreignCol) { | 
| 146 | - $nativeKeyValue = $this->nativeMapper->getEntityAttribute($nativeEntity, $nativeCol); | |
| 146 | + $nativeKeyValue = $this->nativeMapper->getEntityAttribute($nativeEntity, $nativeCol); | |
| 147 | 147 | $this->foreignMapper->setEntityAttribute($foreignEntity, $foreignCol, $nativeKeyValue); | 
| 148 | 148 | } | 
| 149 | 149 | } | 
| @@ -166,7 +166,7 @@ discard block | ||
| 166 | 166 |          $remainingRelations = $this->getRemainingRelations($action->getOption('relations')); | 
| 167 | 167 | |
| 168 | 168 | // no cascade delete? treat as save so we can process the changes | 
| 169 | -        if (! $this->isCascade()) { | |
| 169 | +        if (!$this->isCascade()) { | |
| 170 | 170 | $this->addActionOnSave($action); | 
| 171 | 171 |          } else { | 
| 172 | 172 | // retrieve them again from the DB since the related collection might not have everything | 
| @@ -192,11 +192,11 @@ discard block | ||
| 192 | 192 | return; | 
| 193 | 193 | } | 
| 194 | 194 | |
| 195 | - $changes = $foreignEntities->getChanges(); | |
| 195 | + $changes = $foreignEntities->getChanges(); | |
| 196 | 196 | |
| 197 | 197 | // save the entities still in the collection | 
| 198 | 198 |          foreach ($foreignEntities as $foreignEntity) { | 
| 199 | -            if (! empty($foreignEntity->getChanges())) { | |
| 199 | +            if (!empty($foreignEntity->getChanges())) { | |
| 200 | 200 | $saveAction = $this->foreignMapper | 
| 201 | 201 | ->newSaveAction($foreignEntity, [ | 
| 202 | 202 | 'relations' => $remainingRelations | 
| @@ -32,7 +32,7 @@ | ||
| 32 | 32 | protected function addActionOnDelete(BaseAction $action) | 
| 33 | 33 |      { | 
| 34 | 34 | // no cascade delete? treat it as a save | 
| 35 | -        if (! $this->isCascade()) { | |
| 35 | +        if (!$this->isCascade()) { | |
| 36 | 36 | $this->addActionOnSave($action); | 
| 37 | 37 |          } else { | 
| 38 | 38 | $nativeEntity = $action->getEntity(); | 
| @@ -14,11 +14,11 @@ discard block | ||
| 14 | 14 | parent::applyDefaults(); | 
| 15 | 15 | |
| 16 | 16 | $foreignKey = $this->foreignMapper->getPrimaryKey(); | 
| 17 | -        if (! isset($this->options[RelationOption::FOREIGN_KEY])) { | |
| 17 | +        if (!isset($this->options[RelationOption::FOREIGN_KEY])) { | |
| 18 | 18 | $this->options[RelationOption::FOREIGN_KEY] = $foreignKey; | 
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | -        if (! isset($this->options[RelationOption::NATIVE_KEY])) { | |
| 21 | +        if (!isset($this->options[RelationOption::NATIVE_KEY])) { | |
| 22 | 22 | $nativeKey = $this->getKeyColumn($this->name, $foreignKey); | 
| 23 | 23 | $this->options[RelationOption::NATIVE_KEY] = $nativeKey; | 
| 24 | 24 | } | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | protected function addActionOnDelete(BaseAction $action) | 
| 91 | 91 |      { | 
| 92 | 92 | // no cascade delete? treat it as a save | 
| 93 | -        if (! $this->isCascade()) { | |
| 93 | +        if (!$this->isCascade()) { | |
| 94 | 94 | $this->addActionOnSave($action); | 
| 95 | 95 |          } else { | 
| 96 | 96 | $nativeEntity = $action->getEntity(); | 
| @@ -61,7 +61,7 @@ discard block | ||
| 61 | 61 | |
| 62 | 62 | protected function setOptionIfMissing($name, $value) | 
| 63 | 63 |      { | 
| 64 | -        if (! isset($this->options[$name])) { | |
| 64 | +        if (!isset($this->options[$name])) { | |
| 65 | 65 | $this->options[$name] = $value; | 
| 66 | 66 | } | 
| 67 | 67 | } | 
| @@ -130,7 +130,7 @@ discard block | ||
| 130 | 130 | |
| 131 | 131 | public function addActions(BaseAction $action) | 
| 132 | 132 |      { | 
| 133 | -        if (! $this->cascadeIsAllowedForAction($action)) { | |
| 133 | +        if (!$this->cascadeIsAllowedForAction($action)) { | |
| 134 | 134 | return; | 
| 135 | 135 | } | 
| 136 | 136 | |
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | protected function cascadeIsAllowedForAction(BaseAction $action) | 
| 200 | 200 |      { | 
| 201 | 201 |          $relations = $action->getOption('relations'); | 
| 202 | -        if (is_array($relations) && ! in_array($this->name, $relations)) { | |
| 202 | +        if (is_array($relations) && !in_array($this->name, $relations)) { | |
| 203 | 203 | return false; | 
| 204 | 204 | } | 
| 205 | 205 | |
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | */ | 
| 218 | 218 | protected function getRemainingRelations($relations) | 
| 219 | 219 |      { | 
| 220 | -        if (! is_array($relations)) { | |
| 220 | +        if (!is_array($relations)) { | |
| 221 | 221 | return $relations; | 
| 222 | 222 | } | 
| 223 | 223 | |
| @@ -233,7 +233,7 @@ discard block | ||
| 233 | 233 |          if (is_array($guards)) { | 
| 234 | 234 |              foreach ($guards as $col => $val) { | 
| 235 | 235 | // guards that are strings (eg: 'deleted_at is null') can't be used as extra columns | 
| 236 | -                if (! is_int($col)) { | |
| 236 | +                if (!is_int($col)) { | |
| 237 | 237 | $cols[$col] = $val; | 
| 238 | 238 | } | 
| 239 | 239 | } | 
| @@ -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[RelationOption::NATIVE_KEY])) { | |
| 17 | +        if (!isset($this->options[RelationOption::NATIVE_KEY])) { | |
| 18 | 18 | $this->options[RelationOption::NATIVE_KEY] = $nativeKey; | 
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | -        if (! isset($this->options[RelationOption::FOREIGN_KEY])) { | |
| 21 | +        if (!isset($this->options[RelationOption::FOREIGN_KEY])) { | |
| 22 | 22 | $prefix = Inflector::singularize($this->nativeMapper->getTable()); | 
| 23 | 23 | $this->options[RelationOption::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 | } | 
| @@ -92,7 +92,7 @@ discard block | ||
| 92 | 92 |          $remainingRelations = $this->getRemainingRelations($action->getOption('relations')); | 
| 93 | 93 | |
| 94 | 94 | // no cascade delete? treat as save so we can process the changes | 
| 95 | -        if (! $this->isCascade()) { | |
| 95 | +        if (!$this->isCascade()) { | |
| 96 | 96 | $this->addActionOnSave($action); | 
| 97 | 97 |          } else { | 
| 98 | 98 | // retrieve them again from the DB since the related collection might not have everything | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | |
| 125 | 125 | // save the entities still in the collection | 
| 126 | 126 |          foreach ($foreignEntities as $foreignEntity) { | 
| 127 | -            if (! empty($foreignEntity->getChanges())) { | |
| 127 | +            if (!empty($foreignEntity->getChanges())) { | |
| 128 | 128 | $saveAction = $this->foreignMapper | 
| 129 | 129 | ->newSaveAction($foreignEntity, ['relations' => $remainingRelations]); | 
| 130 | 130 | $saveAction->addColumns($this->getExtraColumnsForAction()); | 
| @@ -47,8 +47,8 @@ | ||
| 47 | 47 |          if (count($columns) > 0) { | 
| 48 | 48 | $updateSql = new \Sirius\Sql\Update($connection); | 
| 49 | 49 | $updateSql->table($this->mapper->getTable()) | 
| 50 | - ->columns($columns) | |
| 51 | - ->where($this->mapper->getPrimaryKey(), $this->entity->getPk()); | |
| 50 | + ->columns($columns) | |
| 51 | + ->where($this->mapper->getPrimaryKey(), $this->entity->getPk()); | |
| 52 | 52 | $updateSql->perform(); | 
| 53 | 53 | } | 
| 54 | 54 | } | 
| @@ -55,7 +55,7 @@ | ||
| 55 | 55 | |
| 56 | 56 | public function revert() | 
| 57 | 57 |      { | 
| 58 | -        if (! $this->hasRun) { | |
| 58 | +        if (!$this->hasRun) { | |
| 59 | 59 | return; | 
| 60 | 60 | } | 
| 61 | 61 | $this->entity->setPersistanceState($this->entityState); | 
| @@ -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->entity->setPk($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->entity->setPK($this->entityId); | 
| @@ -98,12 +98,12 @@ discard block | ||
| 98 | 98 | |
| 99 | 99 | protected function addActionsForRelatedEntities() | 
| 100 | 100 |      { | 
| 101 | -        if ($this->getOption('relations') === false || ! $this->mapper) { | |
| 101 | +        if ($this->getOption('relations') === false || !$this->mapper) { | |
| 102 | 102 | return; | 
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 |          foreach ($this->getMapper()->getRelations() as $name) { | 
| 106 | -            if (! $this->mapper->hasRelation($name)) { | |
| 106 | +            if (!$this->mapper->hasRelation($name)) { | |
| 107 | 107 | continue; | 
| 108 | 108 | } | 
| 109 | 109 | $this->mapper->getRelation($name)->addActions($this); | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 | /** @var ActionInterface $action */ | 
| 141 | 141 |          foreach ($executed as $action) { | 
| 142 | 142 | // if called by another action, that action will call `onSuccess` | 
| 143 | -            if (! $calledByAnotherAction || $action !== $this) { | |
| 143 | +            if (!$calledByAnotherAction || $action !== $this) { | |
| 144 | 144 | $action->onSuccess(); | 
| 145 | 145 | } | 
| 146 | 146 | } |