@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | protected function ensureHydratedElement($element) |
| 42 | 42 | { |
| 43 | - if (! $this->hydrator) { |
|
| 43 | + if (!$this->hydrator) { |
|
| 44 | 44 | return $element; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function add($element) |
| 79 | 79 | { |
| 80 | 80 | $element = $this->ensureHydratedElement($element); |
| 81 | - if (! $this->contains($element)) { |
|
| 81 | + if (!$this->contains($element)) { |
|
| 82 | 82 | $this->change('added', $element); |
| 83 | 83 | |
| 84 | 84 | return $this->collection->add($element); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | public function removeElement($element) |
| 103 | 103 | { |
| 104 | 104 | $element = $this->ensureHydratedElement($element); |
| 105 | - if (! $this->contains($element)) { |
|
| 105 | + if (!$this->contains($element)) { |
|
| 106 | 106 | return true; |
| 107 | 107 | } |
| 108 | 108 | $removed = $this->collection->removeElement($this->findByPk($this->hydrator->getPk($element))); |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function pluck($names) |
| 129 | 129 | { |
| 130 | - return $this->map(function ($item) use ($names) { |
|
| 131 | - if (! is_array($names)) { |
|
| 130 | + return $this->map(function($item) use ($names) { |
|
| 131 | + if (!is_array($names)) { |
|
| 132 | 132 | return $this->hydrator->get($item, $names); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - return ! ! $value; |
|
| 73 | + return !!$value; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // phpcs:ignore |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | return $value; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - return json_decode((string) $value, true); |
|
| 106 | + return json_decode((string)$value, true); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function json($value) |
| 110 | 110 | { |
| 111 | - if (! $value) { |
|
| 111 | + if (!$value) { |
|
| 112 | 112 | return new \ArrayObject(); |
| 113 | 113 | } |
| 114 | 114 | if (is_array($value)) { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // phpcs:ignore |
| 127 | 127 | public function json_for_db($value) |
| 128 | 128 | { |
| 129 | - if (! $value) { |
|
| 129 | + if (!$value) { |
|
| 130 | 130 | return null; |
| 131 | 131 | } |
| 132 | 132 | if (is_array($value)) { |
@@ -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 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | $this->relations[$name] = $relation; |
| 65 | 65 | $this->relationCallback[$name] = $callback; |
| 66 | - if (! empty($nextLoad)) { |
|
| 66 | + if (!empty($nextLoad)) { |
|
| 67 | 67 | $this->relationNextLoad[$name] = $nextLoad; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function getResultsForRelation($name) |
| 77 | 77 | { |
| 78 | - if (! isset($this->relations[$name])) { |
|
| 78 | + if (!isset($this->relations[$name])) { |
|
| 79 | 79 | return []; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $result = []; |
| 113 | 113 | foreach ($this->rows as $row) { |
| 114 | 114 | $value = $this->getColumnsFromRow($row, $columns, $hydrator); |
| 115 | - if ($value && ! in_array($value, $result)) { |
|
| 115 | + if ($value && !in_array($value, $result)) { |
|
| 116 | 116 | $result[] = $value; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function getLazyAggregate(Aggregate $aggregate) |
| 144 | 144 | { |
| 145 | 145 | $name = $aggregate->getName(); |
| 146 | - if (! isset($this->lazyAggregates[$name])) { |
|
| 146 | + if (!isset($this->lazyAggregates[$name])) { |
|
| 147 | 147 | $this->lazyAggregates[$name] = new LazyAggregate($this, $aggregate); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | public function getLazyRelation(Relation $relation) |
| 154 | 154 | { |
| 155 | 155 | $name = $relation->getOption('name'); |
| 156 | - if (! isset($this->lazyRelations[$name])) { |
|
| 156 | + if (!isset($this->lazyRelations[$name])) { |
|
| 157 | 157 | $this->lazyRelations[$name] = new LazyRelation($this, $relation); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | $queryNextLoad = $this->relationNextLoad[$name] ?? []; |
| 192 | - if ($queryNextLoad && ! empty($queryNextLoad)) { |
|
| 192 | + if ($queryNextLoad && !empty($queryNextLoad)) { |
|
| 193 | 193 | foreach ($queryNextLoad as $next => $callback) { |
| 194 | 194 | $query = $query->load([$next => $callback]); |
| 195 | 195 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | |
| 44 | 44 | unset($this->lazyLoaders[$attribute]); |
| 45 | 45 | $value = $this->castAttribute($attribute, $value); |
| 46 | - if (! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
| 46 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
| 47 | 47 | $this->markChanged($attribute); |
| 48 | 48 | $this->state = StateEnum::CHANGED; |
| 49 | 49 | } |
@@ -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; |