@@ -32,11 +32,11 @@ |
||
32 | 32 | { |
33 | 33 | $errors = []; |
34 | 34 | |
35 | - if ( ! $this->name) { |
|
35 | + if (!$this->name) { |
|
36 | 36 | $errors[] = 'Method requires a name'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( ! in_array($this->visibility, [ClassType::VISIBILITY_PUBLIC, ClassType::VISIBILITY_PROTECTED])) { |
|
39 | + if (!in_array($this->visibility, [ClassType::VISIBILITY_PUBLIC, ClassType::VISIBILITY_PROTECTED])) { |
|
40 | 40 | $errors[] = 'Wrong method visilibity type. Only `public` and `protected` are allowed.'; |
41 | 41 | } |
42 | 42 |
@@ -129,10 +129,10 @@ |
||
129 | 129 | public function newEntity(array $data): EntityInterface |
130 | 130 | { |
131 | 131 | $entity = $this->getHydrator() |
132 | - ->hydrate(array_merge( |
|
133 | - $this->getConfig()->getAttributeDefaults(), |
|
134 | - $data |
|
135 | - )); |
|
132 | + ->hydrate(array_merge( |
|
133 | + $this->getConfig()->getAttributeDefaults(), |
|
134 | + $data |
|
135 | + )); |
|
136 | 136 | |
137 | 137 | return $this->behaviours->apply($this, __FUNCTION__, $entity); |
138 | 138 | } |
@@ -167,7 +167,7 @@ |
||
167 | 167 | |
168 | 168 | public function getRelation(string $name): Relation |
169 | 169 | { |
170 | - if ( ! $this->hasRelation($name)) { |
|
170 | + if (!$this->hasRelation($name)) { |
|
171 | 171 | throw new \InvalidArgumentException("Relation named {$name} is not registered for this mapper"); |
172 | 172 | } |
173 | 173 |
@@ -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 |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | return $value; |
103 | 103 | } |
104 | 104 | |
105 | - return json_decode((string) $value, true); |
|
105 | + return json_decode((string)$value, true); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function json($value) |
109 | 109 | { |
110 | - if ( ! $value) { |
|
110 | + if (!$value) { |
|
111 | 111 | return new \ArrayObject(); |
112 | 112 | } |
113 | 113 | if (is_array($value)) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // phpcs:ignore |
126 | 126 | public function json_for_db($value) |
127 | 127 | { |
128 | - if ( ! $value) { |
|
128 | + if (!$value) { |
|
129 | 129 | return null; |
130 | 130 | } |
131 | 131 | if (is_array($value)) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function add($element) |
68 | 68 | { |
69 | 69 | $element = $this->ensureHydratedElement($element); |
70 | - if ( ! $this->contains($element)) { |
|
70 | + if (!$this->contains($element)) { |
|
71 | 71 | $this->change('added', $element); |
72 | 72 | |
73 | 73 | return parent::add($element); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function removeElement($element) |
90 | 90 | { |
91 | 91 | $element = $this->ensureHydratedElement($element); |
92 | - if ( ! $this->contains($element)) { |
|
92 | + if (!$this->contains($element)) { |
|
93 | 93 | return true; |
94 | 94 | } |
95 | 95 | $removed = parent::removeElement($this->findByPk($this->hydrator->getPk($element))); |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | |
114 | 114 | public function pluck($names) |
115 | 115 | { |
116 | - return $this->map(function ($item) use ($names) { |
|
117 | - if ( ! is_array($names)) { |
|
116 | + return $this->map(function($item) use ($names) { |
|
117 | + if (!is_array($names)) { |
|
118 | 118 | return $this->hydrator->get($item, $names); |
119 | 119 | } |
120 | 120 |
@@ -60,9 +60,9 @@ |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | $value = $this->castAttribute($attribute, $value); |
63 | - if ( ! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
63 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
64 | 64 | $this->markChanged($attribute); |
65 | - $this->state = StateEnum::CHANGED; |
|
65 | + $this->state = StateEnum::CHANGED; |
|
66 | 66 | } |
67 | 67 | $this->attributes[$attribute] = $value; |
68 | 68 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | $value = $this->castAttribute($attribute, $value); |
43 | - if ( ! isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
43 | + if (!isset($this->attributes[$attribute]) || $value != $this->attributes[$attribute]) { |
|
44 | 44 | $this->markChanged($attribute); |
45 | 45 | $this->state = StateEnum::CHANGED; |
46 | 46 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | $setter = $class->addMethod(Str::methodName($name . ' Attribute', 'set')); |
58 | 58 | $setter->setVisibility(ClassType::VISIBILITY_PROTECTED); |
59 | 59 | $setter->addParameter('value') |
60 | - ->setNullable($this->property->getNullable()) |
|
61 | - ->setType($alias); |
|
60 | + ->setNullable($this->property->getNullable()) |
|
61 | + ->setType($alias); |
|
62 | 62 | $setter->setBody($body); |
63 | 63 | $setter->setComment($this->property->getSetterComment()); |
64 | 64 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $setter = $class->addMethod(Str::methodName($name, 'set')); |
77 | 77 | $setter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
78 | 78 | $setter->addParameter('value') |
79 | - ->setType($type) |
|
80 | - ->setNullable($this->property->getNullable()); |
|
79 | + ->setType($type) |
|
80 | + ->setNullable($this->property->getNullable()); |
|
81 | 81 | $setter->setBody($body); |
82 | 82 | $setter->setComment($this->property->getSetterComment()); |
83 | 83 | } |
@@ -135,11 +135,11 @@ |
||
135 | 135 | $relation = $this->mapper->getRelation($name); |
136 | 136 | if ($relation instanceof ToOneInterface && |
137 | 137 | isset($attributes[$name]) && |
138 | - ! is_object($attributes[$name])) { |
|
138 | + !is_object($attributes[$name])) { |
|
139 | 139 | $attributes[$name] = $relation->getForeignMapper()->newEntity($attributes[$name]); |
140 | 140 | } elseif ($relation instanceof ToManyInterface && |
141 | - ! $relation instanceof ToOneInterface |
|
142 | - && ( ! isset($attributes[$name]) || is_array($attributes[$name]))) { |
|
141 | + !$relation instanceof ToOneInterface |
|
142 | + && (!isset($attributes[$name]) || is_array($attributes[$name]))) { |
|
143 | 143 | /** |
144 | 144 | * we also need to check against ToOneInterface because OneToOne relation extends |
145 | 145 | * OneToMany which implements ToOneInterface |
@@ -130,11 +130,11 @@ |
||
130 | 130 | $relation = $this->mapper->getRelation($name); |
131 | 131 | if ($relation instanceof ToOneInterface && |
132 | 132 | isset($attributes[$name]) && |
133 | - ! is_object($attributes[$name])) { |
|
133 | + !is_object($attributes[$name])) { |
|
134 | 134 | $attributes[$name] = $relation->getForeignMapper()->newEntity($attributes[$name]); |
135 | 135 | } elseif ($relation instanceof ToManyInterface && |
136 | - ! $relation instanceof ToOneInterface |
|
137 | - && ( ! isset($attributes[$name]) || is_array($attributes[$name]))) { |
|
136 | + !$relation instanceof ToOneInterface |
|
137 | + && (!isset($attributes[$name]) || is_array($attributes[$name]))) { |
|
138 | 138 | /** |
139 | 139 | * we also need to check against ToOneInterface because OneToOne relation extends |
140 | 140 | * OneToMany which implements ToOneInterface |