@@ -363,7 +363,7 @@ |
||
363 | 363 | { |
364 | 364 | return $this->addColumn( |
365 | 365 | Column::integer($name, true) |
366 | - ->setAutoIncrement(true) |
|
366 | + ->setAutoIncrement(true) |
|
367 | 367 | ); |
368 | 368 | } |
369 | 369 |
@@ -68,30 +68,30 @@ discard block |
||
68 | 68 | { |
69 | 69 | $errors = []; |
70 | 70 | |
71 | - if ( ! $this->table) { |
|
71 | + if (!$this->table) { |
|
72 | 72 | $errors[] = 'Missing table property'; |
73 | 73 | } |
74 | 74 | |
75 | - if ( ! $this->className) { |
|
75 | + if (!$this->className) { |
|
76 | 76 | $errors[] = 'Missing class name property'; |
77 | 77 | } |
78 | 78 | |
79 | 79 | if ($this->destination) { |
80 | - if ( ! is_dir($this->destination)) { |
|
80 | + if (!is_dir($this->destination)) { |
|
81 | 81 | $errors[] = sprintf('%s is not a valid directory', $this->destination); |
82 | - } elseif ( ! is_writable($this->destination)) { |
|
82 | + } elseif (!is_writable($this->destination)) { |
|
83 | 83 | $errors[] = sprintf('%s is not writable', $this->destination); |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - if ( ! $this->entityClass) { |
|
87 | + if (!$this->entityClass) { |
|
88 | 88 | $errors[] = 'Missing entity class name property'; |
89 | 89 | } |
90 | 90 | |
91 | 91 | if ($this->entityDestination) { |
92 | - if ( ! is_dir($this->entityDestination)) { |
|
92 | + if (!is_dir($this->entityDestination)) { |
|
93 | 93 | $errors[] = sprintf('%s is not a valid directory', $this->entityDestination); |
94 | - } elseif ( ! is_writable($this->entityDestination)) { |
|
94 | + } elseif (!is_writable($this->entityDestination)) { |
|
95 | 95 | $errors[] = sprintf('%s is not writable', $this->entityDestination); |
96 | 96 | } |
97 | 97 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | public function addRelation($name, Relation $relation): Mapper |
344 | 344 | { |
345 | 345 | $relation->setMapper($this); |
346 | - if ( ! $relation->getForeignMapper()) { |
|
346 | + if (!$relation->getForeignMapper()) { |
|
347 | 347 | $relation->setForeignMapper(Inflector::pluralize($name)); |
348 | 348 | } |
349 | 349 | $relation->setName($name); |
@@ -376,19 +376,19 @@ discard block |
||
376 | 376 | |
377 | 377 | $singular = Inflector::singularize($name); |
378 | 378 | |
379 | - if ( ! $this->table) { |
|
379 | + if (!$this->table) { |
|
380 | 380 | $this->setTable($name); |
381 | 381 | } |
382 | 382 | |
383 | - if ($this->table !== $name && ! $this->tableAlias) { |
|
383 | + if ($this->table !== $name && !$this->tableAlias) { |
|
384 | 384 | $this->setTableAlias($name); |
385 | 385 | } |
386 | 386 | |
387 | - if ( ! $this->className) { |
|
387 | + if (!$this->className) { |
|
388 | 388 | $this->setClassName(Str::className($singular) . 'Mapper'); |
389 | 389 | } |
390 | 390 | |
391 | - if ( ! $this->entityClass) { |
|
391 | + if (!$this->entityClass) { |
|
392 | 392 | $this->setEntityClass(Str::className($singular)); |
393 | 393 | } |
394 | 394 |
@@ -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 | } |