@@ -63,9 +63,9 @@ |
||
63 | 63 | |
64 | 64 | unset($this->lazyLoaders[$attribute]); |
65 | 65 | $value = $this->castAttribute($attribute, $value); |
66 | - if (! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
66 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
67 | 67 | $this->markChanged($attribute); |
68 | - $this->state = StateEnum::CHANGED; |
|
68 | + $this->state = StateEnum::CHANGED; |
|
69 | 69 | } |
70 | 70 | $this->attributes[$attribute] = $value; |
71 | 71 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | $changes = $this->changed; |
99 | 99 | foreach ($this->attributes as $name => $value) { |
100 | 100 | if (is_object($value) && method_exists($value, 'getChanges')) { |
101 | - if (! empty($value->getChanges())) { |
|
101 | + if (!empty($value->getChanges())) { |
|
102 | 102 | $changes[$name] = true; |
103 | 103 | } |
104 | 104 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | return $this->set($entity, $this->getMapperConfig()->getPrimaryKey(), $value); |
75 | 75 | } |
76 | 76 | |
77 | - public function hydrateToArray(array $attributes= []): array |
|
77 | + public function hydrateToArray(array $attributes = []): array |
|
78 | 78 | { |
79 | 79 | $attributes = Arr::renameKeys($attributes, $this->getMapperConfig()->getColumnAttributeMap()); |
80 | 80 | if ($this->castingManager) { |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $relation = $this->mapper->getRelation($name); |
92 | 92 | if ($relation instanceof ToOneInterface |
93 | 93 | && isset($attributes[$name]) |
94 | - && ! is_object($attributes[$name])) { |
|
94 | + && !is_object($attributes[$name])) { |
|
95 | 95 | $attributes[$name] = $relation->getForeignMapper()->newEntity($attributes[$name]); |
96 | 96 | } elseif ($relation instanceof ToManyInterface |
97 | - && ! $relation instanceof ToOneInterface) { |
|
97 | + && !$relation instanceof ToOneInterface) { |
|
98 | 98 | /** |
99 | 99 | * here we need to check against ToOneInterface as well |
100 | 100 | * because OneToOne relation extends |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return; |
61 | 61 | } |
62 | 62 | $foreignMapper = $this->mapper->getRelation($relationName) |
63 | - ->getForeignMapper(); |
|
63 | + ->getForeignMapper(); |
|
64 | 64 | $currentValue = $this->mapper->getHydrator()->get($entity, $relationName); |
65 | 65 | $this->patchOrCreate($foreignMapper, $currentValue, $attributes); |
66 | 66 | $this->mapper->getHydrator()->set($entity, $relationName, $currentValue); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | private function patchCollection(EntityInterface $entity, string $relationName, $attributes) |
70 | 70 | { |
71 | 71 | $foreignMapper = $this->mapper->getRelation($relationName) |
72 | - ->getForeignMapper(); |
|
72 | + ->getForeignMapper(); |
|
73 | 73 | /** @var Collection|null $collection */ |
74 | 74 | $collection = $this->mapper->getHydrator()->get($entity, $relationName); |
75 | 75 | if (!$collection || $collection->isEmpty()) { |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $foreignMapper = $this->mapper->getRelation($relationName) |
72 | 72 | ->getForeignMapper(); |
73 | 73 | /** @var Collection|null $collection */ |
74 | - $collection = $this->mapper->getHydrator()->get($entity, $relationName); |
|
74 | + $collection = $this->mapper->getHydrator()->get($entity, $relationName); |
|
75 | 75 | if (!$collection || $collection->isEmpty()) { |
76 | 76 | $this->mapper->getHydrator()->set($entity, $relationName, $foreignMapper->newCollection($attributes)); |
77 | 77 | return; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function includesRelation($relationName) |
118 | 118 | { |
119 | - $relations = (array) $this->getOption('relations'); |
|
119 | + $relations = (array)$this->getOption('relations'); |
|
120 | 120 | |
121 | 121 | return $relations === true || in_array($relationName, $relations); |
122 | 122 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function addActionsForRelatedEntities() |
129 | 129 | { |
130 | - if (! $this->mapper) { |
|
130 | + if (!$this->mapper) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function getTableAlias($fallbackToTable = false) |
132 | 132 | { |
133 | - return (! $this->tableAlias && $fallbackToTable) ? $this->table : $this->tableAlias; |
|
133 | + return (!$this->tableAlias && $fallbackToTable) ? $this->table : $this->tableAlias; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function getColumns(): array |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | public function getTableReference() |
179 | 179 | { |
180 | - if (! $this->tableReference) { |
|
180 | + if (!$this->tableReference) { |
|
181 | 181 | $this->tableReference = QueryHelper::reference($this->table, $this->tableAlias); |
182 | 182 | } |
183 | 183 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function underscore(string $str): string |
17 | 17 | { |
18 | - if (! isset(static::$cache['underscore'][$str])) { |
|
18 | + if (!isset(static::$cache['underscore'][$str])) { |
|
19 | 19 | $str = preg_replace("/([A-Z]+)/", ' $1', $str); |
20 | 20 | $str = strtolower($str); |
21 | 21 | $str = preg_replace("/[^a-z0-9]+/", ' ', $str); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public static function methodName(string $str, string $verb): string |
30 | 30 | { |
31 | 31 | $key = $verb . $str; |
32 | - if (! isset(static::$cache['methodName'][$key])) { |
|
32 | + if (!isset(static::$cache['methodName'][$key])) { |
|
33 | 33 | static::$cache['methodName'][$key] = strtolower($verb) . static::className($str); |
34 | 34 | } |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | public static function variableName(string $str): string |
40 | 40 | { |
41 | - if (! isset(static::$cache['variableName'][$str])) { |
|
41 | + if (!isset(static::$cache['variableName'][$str])) { |
|
42 | 42 | $class = static::className($str); |
43 | 43 | |
44 | 44 | static::$cache['variableName'][$str] = strtolower(substr($class, 0, 1)) . substr($class, 1); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public static function className(string $str): string |
51 | 51 | { |
52 | - if (! isset(static::$cache['className'][$str])) { |
|
52 | + if (!isset(static::$cache['className'][$str])) { |
|
53 | 53 | $str = strtolower($str); |
54 | 54 | $str = preg_replace("/[^a-z0-9]+/", ' ', $str); |
55 | 55 | $str = ucwords($str); |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | |
27 | 27 | protected function addActionOnDelete(BaseAction $action) |
28 | 28 | { |
29 | - $relations = $action->getOption('relations'); |
|
29 | + $relations = $action->getOption('relations'); |
|
30 | 30 | |
31 | 31 | // no cascade delete? treat it as a save |
32 | - if (! $this->isCascade()) { |
|
32 | + if (!$this->isCascade()) { |
|
33 | 33 | $this->addActionOnSave($action); |
34 | 34 | } elseif ($relations === true || in_array($this->name, (array)$relations)) { |
35 | 35 | $nativeEntity = $action->getEntity(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ->first(); |
42 | 42 | |
43 | 43 | if ($foreignEntity) { |
44 | - $deleteAction = $this->foreignMapper |
|
44 | + $deleteAction = $this->foreignMapper |
|
45 | 45 | ->newDeleteAction($foreignEntity, ['relations' => $remainingRelations]); |
46 | 46 | $action->prepend($deleteAction); |
47 | 47 | $action->append($this->newSyncAction($action->getEntity(), $foreignEntity, 'delete')); |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | |
62 | 62 | protected function addActionOnSave(BaseAction $action) |
63 | 63 | { |
64 | - if (! $this->relationWasChanged($action->getEntity())) { |
|
64 | + if (!$this->relationWasChanged($action->getEntity())) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | - if (! $action->includesRelation($this->name)) { |
|
68 | + if (!$action->includesRelation($this->name)) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | protected function setOptionIfMissing($name, $value) |
78 | 78 | { |
79 | - if (! isset($this->options[$name])) { |
|
79 | + if (!isset($this->options[$name])) { |
|
80 | 80 | $this->options[$name] = $value; |
81 | 81 | } |
82 | 82 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | protected function getKeyColumn($name, $column) |
117 | 117 | { |
118 | - if (! is_array($column)) { |
|
118 | + if (!is_array($column)) { |
|
119 | 119 | return $name . '_' . $column; |
120 | 120 | } |
121 | 121 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | foreach ($entities as $entity) { |
178 | 178 | $entityId = $this->getEntityId($this->foreignMapper, $entity, array_values($this->keyPairs)); |
179 | - if (! isset($result[$entityId])) { |
|
179 | + if (!isset($result[$entityId])) { |
|
180 | 180 | $result[$entityId] = []; |
181 | 181 | } |
182 | 182 | $result[$entityId][] = $entity; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | protected function getRemainingRelations($relations) |
225 | 225 | { |
226 | - if (! is_array($relations)) { |
|
226 | + if (!is_array($relations)) { |
|
227 | 227 | return $relations; |
228 | 228 | } |
229 | 229 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if (is_array($guards)) { |
245 | 245 | foreach ($guards as $col => $val) { |
246 | 246 | // guards that are strings (eg: 'deleted_at is null') can't be used as extra columns |
247 | - if (! is_int($col)) { |
|
247 | + if (!is_int($col)) { |
|
248 | 248 | $cols[$col] = $val; |
249 | 249 | } |
250 | 250 | } |