@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function includesRelation($relationName) { |
| 118 | - $relations = (array) $this->getOption('relations'); |
|
| 118 | + $relations = (array)$this->getOption('relations'); |
|
| 119 | 119 | |
| 120 | 120 | return $relations === true || in_array($relationName, $relations); |
| 121 | 121 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function addActionsForRelatedEntities() |
| 128 | 128 | { |
| 129 | - if (! $this->mapper) { |
|
| 129 | + if (!$this->mapper) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | $mapper->getHydrator()->set($action->getEntity(), $this->updateColumn, $now); |
| 46 | 46 | } |
| 47 | 47 | if ($action instanceof Update && $this->updateColumn) { |
| 48 | - if ( ! empty($action->getEntity()->getChanges())) { |
|
| 48 | + if (!empty($action->getEntity()->getChanges())) { |
|
| 49 | 49 | $action->addColumns([$this->updateColumn => $now]); |
| 50 | 50 | $mapper->getHydrator()->set($action->getEntity(), $this->updateColumn, $now); |
| 51 | 51 | } |
@@ -39,27 +39,27 @@ |
||
| 39 | 39 | { |
| 40 | 40 | $errors = []; |
| 41 | 41 | |
| 42 | - if ( ! $this->entityNamespace) { |
|
| 42 | + if (!$this->entityNamespace) { |
|
| 43 | 43 | $errors[] = 'Missing entity namespace property'; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ( ! $this->entityDestination) { |
|
| 46 | + if (!$this->entityDestination) { |
|
| 47 | 47 | $errors[] = 'Missing entity destination property'; |
| 48 | - } elseif ( ! is_dir($this->entityDestination)) { |
|
| 48 | + } elseif (!is_dir($this->entityDestination)) { |
|
| 49 | 49 | $errors[] = sprintf('%s is not a valid directory', $this->entityDestination); |
| 50 | - } elseif ( ! is_writable($this->entityDestination)) { |
|
| 50 | + } elseif (!is_writable($this->entityDestination)) { |
|
| 51 | 51 | $errors[] = sprintf('%s is not writable', $this->entityDestination); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ( ! $this->mapperNamespace) { |
|
| 54 | + if (!$this->mapperNamespace) { |
|
| 55 | 55 | $errors[] = 'Missing mapper namespace property'; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( ! $this->mapperDestination) { |
|
| 58 | + if (!$this->mapperDestination) { |
|
| 59 | 59 | $errors[] = 'Missing entity destination property'; |
| 60 | - } elseif ( ! is_dir($this->mapperDestination)) { |
|
| 60 | + } elseif (!is_dir($this->mapperDestination)) { |
|
| 61 | 61 | $errors[] = sprintf('%s is not a valid directory', $this->mapperDestination); |
| 62 | - } elseif ( ! is_writable($this->mapperDestination)) { |
|
| 62 | + } elseif (!is_writable($this->mapperDestination)) { |
|
| 63 | 63 | $errors[] = sprintf('%s is not writable', $this->mapperDestination); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -49,28 +49,28 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $errors = []; |
| 51 | 51 | |
| 52 | - if ( ! $this->name) { |
|
| 52 | + if (!$this->name) { |
|
| 53 | 53 | $errors[] = "Unknown relation name"; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( ! $this->type) { |
|
| 56 | + if (!$this->type) { |
|
| 57 | 57 | $errors[] = "Unknown relation type"; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( ! $this->nativeKey) { |
|
| 60 | + if (!$this->nativeKey) { |
|
| 61 | 61 | $errors[] = "Missing native key column"; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ( ! $this->foreignMapper) { |
|
| 64 | + if (!$this->foreignMapper) { |
|
| 65 | 65 | $errors[] = "Missing foreign mapper name"; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( ! $this->foreignKey) { |
|
| 68 | + if (!$this->foreignKey) { |
|
| 69 | 69 | $errors[] = "Missing foreign key"; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $strategies = [RelationConfig::LOAD_LAZY, RelationConfig::LOAD_EAGER, RelationConfig::LOAD_NONE]; |
| 73 | - if ( ! in_array($this->loadStrategy, $strategies)) { |
|
| 73 | + if (!in_array($this->loadStrategy, $strategies)) { |
|
| 74 | 74 | $errors[] = sprintf("Relation loading strategy is not valid (allowed values: %s)", implode(', ', $strategies)); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $value !== 0 && |
| 204 | 204 | $value !== '' && |
| 205 | 205 | $value !== [] && |
| 206 | - ! is_object($value)) { |
|
| 206 | + !is_object($value)) { |
|
| 207 | 207 | $result[Str::underscore($prop)] = $value; |
| 208 | 208 | } |
| 209 | 209 | if (is_object($value) && is_callable($value)) { |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | protected function maybeSetAdditionalProperties() |
| 49 | 49 | { |
| 50 | - if ( ! $this->mapper || ! $this->foreignMapper) { |
|
| 50 | + if (!$this->mapper || !$this->foreignMapper) { |
|
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ( ! $this->throughTable) { |
|
| 54 | + if (!$this->throughTable) { |
|
| 55 | 55 | $tablePrefix = $this->mapper->getTableAlias() ? |
| 56 | 56 | str_replace($this->mapper->getTable(), '', $this->mapper->getTableAlias()) |
| 57 | 57 | : ''; |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( ! $this->throughNativeColumn) { |
|
| 69 | + if (!$this->throughNativeColumn) { |
|
| 70 | 70 | $this->throughNativeColumn = Inflector::singularize($this->mapper->getName()) . '_id'; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if ( ! $this->throughForeignColumn) { |
|
| 73 | + if (!$this->throughForeignColumn) { |
|
| 74 | 74 | $this->throughForeignColumn = Inflector::singularize($this->foreignMapper) . '_id'; |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function setMapper(Mapper $mapper): Relation |
| 16 | 16 | { |
| 17 | - if ($mapper && ! $this->foreignKey) { |
|
| 17 | + if ($mapper && !$this->foreignKey) { |
|
| 18 | 18 | $this->foreignKey = Inflector::singularize($mapper->getName()) . '_id'; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - if ($mapper && ! $this->nativeKey) { |
|
| 21 | + if ($mapper && !$this->nativeKey) { |
|
| 22 | 22 | $this->nativeKey = $mapper->getPrimaryKey(); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | public function setForeignMapper($foreignMapper): Relation |
| 17 | 17 | { |
| 18 | - if ($foreignMapper && ! $this->nativeKey) { |
|
| 18 | + if ($foreignMapper && !$this->nativeKey) { |
|
| 19 | 19 | $this->nativeKey = Inflector::singularize($foreignMapper) . '_id'; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -134,86 +134,86 @@ |
||
| 134 | 134 | public static function varchar(string $name, $length = 255) |
| 135 | 135 | { |
| 136 | 136 | return static::make($name) |
| 137 | - ->setType(static::TYPE_VARCHAR) |
|
| 138 | - ->setLength($length); |
|
| 137 | + ->setType(static::TYPE_VARCHAR) |
|
| 138 | + ->setLength($length); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public static function bool(string $name) |
| 142 | 142 | { |
| 143 | 143 | return static::make($name) |
| 144 | - ->setType(static::TYPE_BOOLEAN); |
|
| 144 | + ->setType(static::TYPE_BOOLEAN); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public static function string(string $name) |
| 148 | 148 | { |
| 149 | 149 | return static::make($name) |
| 150 | - ->setType(static::TYPE_TEXT); |
|
| 150 | + ->setType(static::TYPE_TEXT); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public static function datetime(string $name) |
| 154 | 154 | { |
| 155 | 155 | return static::make($name) |
| 156 | - ->setType(static::TYPE_DATETIME); |
|
| 156 | + ->setType(static::TYPE_DATETIME); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | public static function date(string $name) |
| 160 | 160 | { |
| 161 | 161 | return static::make($name) |
| 162 | - ->setType(static::TYPE_DATE); |
|
| 162 | + ->setType(static::TYPE_DATE); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public static function timestamp(string $name) |
| 166 | 166 | { |
| 167 | 167 | return static::make($name) |
| 168 | - ->setType(static::TYPE_TIMESTAMP); |
|
| 168 | + ->setType(static::TYPE_TIMESTAMP); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | public static function json(string $name) |
| 172 | 172 | { |
| 173 | 173 | return static::make($name) |
| 174 | - ->setType(static::TYPE_JSON); |
|
| 174 | + ->setType(static::TYPE_JSON); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public static function float(string $name) |
| 178 | 178 | { |
| 179 | 179 | return static::make($name) |
| 180 | - ->setType(static::TYPE_FLOAT); |
|
| 180 | + ->setType(static::TYPE_FLOAT); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | public static function integer(string $name, $unsigned = false) |
| 184 | 184 | { |
| 185 | 185 | return static::make($name) |
| 186 | - ->setType(static::TYPE_INTEGER) |
|
| 187 | - ->setUnsigned($unsigned); |
|
| 186 | + ->setType(static::TYPE_INTEGER) |
|
| 187 | + ->setUnsigned($unsigned); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | public static function tinyInteger(string $name, $unsigned = false) |
| 191 | 191 | { |
| 192 | 192 | return static::make($name) |
| 193 | - ->setType(static::TYPE_TINY_INTEGER) |
|
| 194 | - ->setUnsigned($unsigned); |
|
| 193 | + ->setType(static::TYPE_TINY_INTEGER) |
|
| 194 | + ->setUnsigned($unsigned); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public static function smallInteger(string $name, $unsigned = false) |
| 198 | 198 | { |
| 199 | 199 | return static::make($name) |
| 200 | - ->setType(static::TYPE_SMALL_INTEGER) |
|
| 201 | - ->setUnsigned($unsigned); |
|
| 200 | + ->setType(static::TYPE_SMALL_INTEGER) |
|
| 201 | + ->setUnsigned($unsigned); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | public static function bigInteger(string $name, $unsigned = false) |
| 205 | 205 | { |
| 206 | 206 | return static::make($name) |
| 207 | - ->setType(static::TYPE_BIG_INTEGER) |
|
| 208 | - ->setUnsigned($unsigned); |
|
| 207 | + ->setType(static::TYPE_BIG_INTEGER) |
|
| 208 | + ->setUnsigned($unsigned); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | public static function decimal(string $name, int $digits, int $precision) |
| 212 | 212 | { |
| 213 | 213 | return static::make($name) |
| 214 | - ->setType(static::TYPE_DECIMAL) |
|
| 215 | - ->setDigits($digits) |
|
| 216 | - ->setPrecision($precision); |
|
| 214 | + ->setType(static::TYPE_DECIMAL) |
|
| 215 | + ->setDigits($digits) |
|
| 216 | + ->setPrecision($precision); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public function getErrors(): array |
@@ -152,11 +152,11 @@ |
||
| 152 | 152 | { |
| 153 | 153 | $errors = []; |
| 154 | 154 | |
| 155 | - if ( ! $this->name) { |
|
| 155 | + if (!$this->name) { |
|
| 156 | 156 | $errors[] = 'Column requires a name'; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( ! $this->type) { |
|
| 159 | + if (!$this->type) { |
|
| 160 | 160 | $errors[] = 'Column requires a type'; |
| 161 | 161 | } elseif (($type = $this->getConstantByValue($this->type)) && substr($type, 0, 5) !== 'TYPE_') { |
| 162 | 162 | $errors[] = sprintf('Column does not have a valid type (%s)', $this->type); |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | |
| 69 | 69 | if ($this->deletedAtColumn && ! array_key_exists($this->deletedAtColumn, $columns)) { |
| 70 | 70 | $mapper->addColumn(Column::datetime($this->deletedAtColumn) |
| 71 | - ->setNullable(true)); |
|
| 71 | + ->setNullable(true)); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $this; |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | |
| 67 | 67 | $columns = $mapper->getColumns(); |
| 68 | 68 | |
| 69 | - if ($this->deletedAtColumn && ! array_key_exists($this->deletedAtColumn, $columns)) { |
|
| 69 | + if ($this->deletedAtColumn && !array_key_exists($this->deletedAtColumn, $columns)) { |
|
| 70 | 70 | $mapper->addColumn(Column::datetime($this->deletedAtColumn) |
| 71 | 71 | ->setNullable(true)); |
| 72 | 72 | } |