Passed
Push — master ( a3bed2...42839b )
by Erik
06:20
created
src/Eloquent/Concerns/Authorizable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function authorizeToCreate(): void
19 19
     {
20
-        if (! static::authorizedToCreate()) {
20
+        if (!static::authorizedToCreate()) {
21 21
             throw new AuthorizationException("Not allowed to perform create on {$this->getModelClass()}");
22 22
         }
23 23
     }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function authorize(string $ability, $arguments = []): void
167 167
     {
168
-        if (! $this->authorized($ability, $arguments)) {
168
+        if (!$this->authorized($ability, $arguments)) {
169 169
             throw new AuthorizationException("Not allowed to perform {$ability} on {$this->getModelClass()}");
170 170
         }
171 171
     }
Please login to merge, or discard this patch.
src/Eloquent/Concerns/InteractsWithRelations.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             $relationType = $this->getRelationTypeName($relation);
62 62
             $method = "fill{$relationType}Relation";
63 63
 
64
-            if (! method_exists($this, $method)) {
64
+            if (!method_exists($this, $method)) {
65 65
                 throw new RuntimeException("Unknown or unfillable relation type: {$key} of type ${relationType}");
66 66
             }
67 67
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             $relationType = $this->getRelationTypeName($relation);
83 83
             $method = "connect{$relationType}Relation";
84 84
 
85
-            if (! method_exists($this, $method)) {
85
+            if (!method_exists($this, $method)) {
86 86
                 throw new RuntimeException("Unknown or unfillable connection type: {$key} of type ${relationType}");
87 87
             }
88 88
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected function connectBelongsToRelation(Relations\BelongsTo $relation, $id)
101 101
     {
102
-        if (! $id) {
102
+        if (!$id) {
103 103
             $relation->dissociate();
104 104
 
105 105
             return;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         $relation->associate($model);
112 112
 
113
-        $this->queue(function () use ($schema) {
113
+        $this->queue(function() use ($schema) {
114 114
             $schema->authorizeToAdd($this->getModel());
115 115
         });
116 116
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     protected function fillBelongsToRelation(Relations\BelongsTo $relation, $attributes = [])
126 126
     {
127
-        if (! $attributes) {
127
+        if (!$attributes) {
128 128
             $relation->dissociate();
129 129
 
130 130
             return;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         $relation->associate($model);
138 138
 
139
-        $this->queue(function () use ($schema) {
139
+        $this->queue(function() use ($schema) {
140 140
             $schema->authorizeToAdd($this->getModel());
141 141
         });
142 142
     }
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
      */
151 151
     protected function connectHasOneRelation(Relations\HasOne $relation, $id)
152 152
     {
153
-        if (! $id) {
153
+        if (!$id) {
154 154
             $relation->delete();
155 155
 
156 156
             return;
157 157
         }
158 158
 
159
-        $this->queue(function () use ($id, $relation) {
159
+        $this->queue(function() use ($id, $relation) {
160 160
             $model = $relation->getRelated()->findOrFail($id);
161 161
             $this->authorizeToAdd($model);
162 162
             $relation->save($model);
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      */
174 174
     protected function fillHasOneRelation(Relations\HasOne $relation, $attributes)
175 175
     {
176
-        if (! $attributes) {
176
+        if (!$attributes) {
177 177
             $relation->delete();
178 178
 
179 179
             return;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $modelSchema->authorizeToCreate();
185 185
         $modelSchema->fill($attributes);
186 186
 
187
-        $this->queue(function () use ($modelSchema, $relation) {
187
+        $this->queue(function() use ($modelSchema, $relation) {
188 188
             $this->authorizeToAdd($modelSchema->getModel());
189 189
             $relation->save($modelSchema->getInstance());
190 190
             $modelSchema->save();
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     protected function connectHasManyRelation(Relations\HasMany $relation, array $ids)
202 202
     {
203
-        $this->queue(function () use ($relation, $ids) {
203
+        $this->queue(function() use ($relation, $ids) {
204 204
             $models = $relation->getModel()->findMany($ids);
205 205
 
206 206
             foreach ($models as $model) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     protected function fillHasManyRelation(Relations\HasMany $relation, array $values)
222 222
     {
223
-        $this->queue(function () use ($relation, $values) {
223
+        $this->queue(function() use ($relation, $values) {
224 224
             $related = $relation->getRelated();
225 225
             $relation->delete();
226 226
 
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
     ) {
270 270
         $values = collect($values);
271 271
 
272
-        $this->queue(function () use ($detaching, $relation, $values) {
272
+        $this->queue(function() use ($detaching, $relation, $values) {
273 273
             $current = $relation->newQuery()->pluck($relation->getRelatedPivotKeyName());
274 274
 
275 275
             if ($detaching) {
276 276
                 $detach = $current->diff($values);
277 277
 
278
-                $relation->getRelated()->newQuery()->findMany($detach)->each(function (Model $model) {
278
+                $relation->getRelated()->newQuery()->findMany($detach)->each(function(Model $model) {
279 279
                     $this->authorizeToDetach($model);
280 280
                 });
281 281
             }
282 282
 
283 283
             $attach = $values->diff($current);
284 284
 
285
-            $relation->getRelated()->newQuery()->findMany($attach)->each(function (Model $model) {
285
+            $relation->getRelated()->newQuery()->findMany($attach)->each(function(Model $model) {
286 286
                 $this->authorizeToAttach($model);
287 287
             });
288 288
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
         $pivotClass = $relation->getPivotClass();
310 310
 
311 311
         // Returns an associative array of [ id => pivot ]
312
-        $values = collect($values)->mapWithKeys(function ($data) use ($accessor, $relatedKey) {
312
+        $values = collect($values)->mapWithKeys(function($data) use ($accessor, $relatedKey) {
313 313
             return [$data[$relatedKey] => $data[$accessor] ?? []];
314
-        })->map(function ($attributes) use ($pivotClass) {
314
+        })->map(function($attributes) use ($pivotClass) {
315 315
             $instance = new $pivotClass;
316 316
             $pivotSchema = $this->registry->getSchemaForModel($instance);
317 317
             $pivotSchema->fill($attributes);
@@ -319,20 +319,20 @@  discard block
 block discarded – undo
319 319
             return $pivotSchema->getInstance()->getAttributes();
320 320
         });
321 321
 
322
-        $this->queue(function () use ($values, $detaching, $relation) {
322
+        $this->queue(function() use ($values, $detaching, $relation) {
323 323
             $current = $relation->newQuery()->pluck($relation->getRelatedPivotKeyName());
324 324
 
325 325
             if ($detaching) {
326 326
                 $detach = $current->diff($values->keys());
327 327
 
328
-                $relation->getRelated()->newQuery()->findMany($detach)->each(function (Model $model) {
328
+                $relation->getRelated()->newQuery()->findMany($detach)->each(function(Model $model) {
329 329
                     $this->authorizeToDetach($model);
330 330
                 });
331 331
             }
332 332
 
333 333
             $attach = $values->keys()->diff($current);
334 334
 
335
-            $relation->getRelated()->newQuery()->findMany($attach)->each(function (Model $model) use ($values) {
335
+            $relation->getRelated()->newQuery()->findMany($attach)->each(function(Model $model) use ($values) {
336 336
                 $this->authorizeToAttach($model, $values->get($model->getKey()));
337 337
             });
338 338
 
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
             $pivots[] = $attributes[$accessor] ?? null;
362 362
         }
363 363
 
364
-        $this->queue(function () use ($detaching, $relation, $instances, $pivots) {
365
-            $data = $instances->pluck('id')->mapWithKeys(function ($id, $key) use ($pivots) {
364
+        $this->queue(function() use ($detaching, $relation, $instances, $pivots) {
365
+            $data = $instances->pluck('id')->mapWithKeys(function($id, $key) use ($pivots) {
366 366
                 $pivot = $pivots[$key] ?? null;
367 367
 
368 368
                 return $pivot ? [$id => $pivot] : [$key => $id];
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
 
371 371
             $results = $relation->sync($data, $detaching);
372 372
 
373
-            $relation->getRelated()->newQuery()->findMany($results['detached'])->each(function (Model $model) {
373
+            $relation->getRelated()->newQuery()->findMany($results['detached'])->each(function(Model $model) {
374 374
                 $this->authorizeToDetach($model);
375 375
             });
376 376
 
377
-            $relation->getRelated()->newQuery()->findMany($results['attached'])->each(function (Model $model) {
377
+            $relation->getRelated()->newQuery()->findMany($results['attached'])->each(function(Model $model) {
378 378
                 $this->authorizeToAttach($model);
379 379
             });
380 380
         });
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
      */
390 390
     protected function connectMorphToRelation(Relations\MorphTo $relation, $data)
391 391
     {
392
-        if (! $data) {
392
+        if (!$data) {
393 393
             $relation->dissociate();
394 394
 
395 395
             return;
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 
403 403
             $data = collect($data);
404 404
 
405
-            [$key, $id] = $data->mapWithKeys(function ($item, $key) {
405
+            [$key, $id] = $data->mapWithKeys(function($item, $key) {
406 406
                 return [$key, $item];
407 407
             });
408 408
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
      */
425 425
     protected function fillMorphToRelation(Relations\MorphTo $relation, $data)
426 426
     {
427
-        if (! $data) {
427
+        if (!$data) {
428 428
             $relation->dissociate();
429 429
 
430 430
             return;
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 
438 438
             $data = collect($data);
439 439
 
440
-            [$key, $attributes] = $data->mapWithKeys(function ($item, $key) {
440
+            [$key, $attributes] = $data->mapWithKeys(function($item, $key) {
441 441
                 return [$key, $item];
442 442
             });
443 443
 
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
      */
474 474
     protected function connectMorphManyRelation(Relations\MorphMany $relation, array $ids)
475 475
     {
476
-        $this->queue(function () use ($relation, $ids) {
477
-            $relation->each(function (Model $model) use ($relation) {
476
+        $this->queue(function() use ($relation, $ids) {
477
+            $relation->each(function(Model $model) use ($relation) {
478 478
                 $model->setAttribute($relation->getMorphType(), null);
479 479
                 $model->setAttribute($relation->getForeignKeyName(), null);
480 480
                 $model->save();
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
      */
496 496
     protected function fillMorphManyRelation(Relations\MorphMany $relation, array $values)
497 497
     {
498
-        $this->queue(function () use ($relation, $values) {
498
+        $this->queue(function() use ($relation, $values) {
499 499
             $relation->delete();
500 500
             $related = $relation->getRelated();
501 501
             $relatedSchema = $this->registry->getSchemaForModel($related);
Please login to merge, or discard this patch.
src/Mutations/UpdateMutation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         return array_merge(
34 34
             parent::args(),
35
-            $this->modelSchema->getLookupFields()->map(function (Field $field) {
35
+            $this->modelSchema->getLookupFields()->map(function(Field $field) {
36 36
                 return $field->getType();
37 37
             })->toArray()
38 38
         );
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $input = $args->input->toArray();
50 50
         $model = $this->findOrFail($args);
51 51
 
52
-        return DB::transaction(function () use ($input, $model) {
52
+        return DB::transaction(function() use ($input, $model) {
53 53
             $modelSchema = $this->registry->getSchemaForModel($model);
54 54
 
55 55
             return $modelSchema->updateIfAuthorized($input);
Please login to merge, or discard this patch.
src/Mutations/AttachPivotMutation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         }
48 48
 
49 49
         return $this->modelSchema->getLookupFields()
50
-            ->map(function (Field $field) {
50
+            ->map(function(Field $field) {
51 51
                 return $field->getType();
52 52
             })
53 53
             ->merge(['input' => $type])
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $input = $args->input->toArray();
77 77
         $model = $this->findOrFail($args);
78 78
 
79
-        return DB::transaction(function () use ($input, $model) {
79
+        return DB::transaction(function() use ($input, $model) {
80 80
             $modelSchema = $this->registry->getSchemaForModel($model);
81 81
 
82 82
             $relation = $this->getRelation($model);
Please login to merge, or discard this patch.
src/Mutations/CreateMutation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     {
33 33
         $input = $args->input->toArray();
34 34
 
35
-        return DB::transaction(function () use ($input) {
35
+        return DB::transaction(function() use ($input) {
36 36
             return $this->getModelSchema()->createIfAuthorized($input);
37 37
         });
38 38
     }
Please login to merge, or discard this patch.
src/Mutations/DeleteMutation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      */
42 42
     public function args(): array
43 43
     {
44
-        return $this->modelSchema->getLookupFields()->map(function (Field $field) {
44
+        return $this->modelSchema->getLookupFields()->map(function(Field $field) {
45 45
             return $field->getType();
46 46
         })->toArray();
47 47
     }
Please login to merge, or discard this patch.
src/Mutations/Concerns/QueriesModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     {
64 64
         $result = $this->find($args);
65 65
 
66
-        if (! $result) {
66
+        if (!$result) {
67 67
             throw (new ModelNotFoundException)->setModel(class_basename($this->model));
68 68
         }
69 69
 
Please login to merge, or discard this patch.
src/Support/RootQuery.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     {
30 30
         $fields = collect($this->fields);
31 31
 
32
-        return $fields->map(function (RootField $field) {
32
+        return $fields->map(function(RootField $field) {
33 33
             return $field->toArray();
34 34
         });
35 35
     }
Please login to merge, or discard this patch.
src/Eloquent/ModelSchema.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     {
195 195
         $key = $this->instance->getKeyName();
196 196
 
197
-        if (! $key) {
197
+        if (!$key) {
198 198
             return [];
199 199
         }
200 200
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function getFields(): Collection
215 215
     {
216
-        return collect($this->getKeyField())->merge($this->fields())->map(function (Field $field, string $key) {
217
-            if (! $field->getAccessor()) {
216
+        return collect($this->getKeyField())->merge($this->fields())->map(function(Field $field, string $key) {
217
+            if (!$field->getAccessor()) {
218 218
                 $field->accessor($key);
219 219
             }
220 220
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function getFillableFields(): Collection
234 234
     {
235
-        return $this->getFields()->filter(function (Field $field) {
235
+        return $this->getFields()->filter(function(Field $field) {
236 236
             return $field->isFillable();
237 237
         });
238 238
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function getSearchableFields(): Collection
246 246
     {
247
-        return $this->getFields()->filter(function (Field $field) {
247
+        return $this->getFields()->filter(function(Field $field) {
248 248
             return $field->isSearchable();
249 249
         });
250 250
     }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function getSearchableRelationFields(): Collection
258 258
     {
259
-        return $this->getRelationFields()->filter(function (Field $field) {
259
+        return $this->getRelationFields()->filter(function(Field $field) {
260 260
             return $field->isSearchable();
261 261
         });
262 262
     }
@@ -269,15 +269,15 @@  discard block
 block discarded – undo
269 269
     public function getLookupFields(): Collection
270 270
     {
271 271
         $fields = collect($this->getFields())
272
-            ->filter(function (Field $field) {
272
+            ->filter(function(Field $field) {
273 273
                 return $field->isUnique();
274 274
             });
275 275
 
276 276
         $relations = collect($this->getRelationFields())
277
-            ->filter(function ($field) {
277
+            ->filter(function($field) {
278 278
                 return $field instanceof EloquentField;
279 279
             })
280
-            ->map(function (EloquentField $field) {
280
+            ->map(function(EloquentField $field) {
281 281
                 $lookupTypeName = $field->getName().'LookupType';
282 282
 
283 283
                 return $this->registry->field($lookupTypeName);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         return collect()
287 287
             ->merge($fields)
288 288
             ->merge($relations)
289
-            ->map(function (Field $field) {
289
+            ->map(function(Field $field) {
290 290
                 return $field->nullable();
291 291
             });
292 292
     }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function getLookupTypes(): Collection
300 300
     {
301
-        return $this->getLookupFields()->map(function (Field $field) {
301
+        return $this->getLookupFields()->map(function(Field $field) {
302 302
             return $field->getType();
303 303
         });
304 304
     }
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
      */
311 311
     public function getRelationFields(): Collection
312 312
     {
313
-        return collect($this->relations())->map(function (Field $field, string $key) {
314
-            if (! $field->getAccessor()) {
313
+        return collect($this->relations())->map(function(Field $field, string $key) {
314
+            if (!$field->getAccessor()) {
315 315
                 $field->accessor($key);
316 316
             }
317 317
 
318
-            if (! $field->getWith()) {
318
+            if (!$field->getWith()) {
319 319
                 $field->with($field->getAccessor());
320 320
             }
321 321
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      */
331 331
     public function getFillableRelationFields(): Collection
332 332
     {
333
-        return $this->getRelationFields()->filter(function (Field $field) {
333
+        return $this->getRelationFields()->filter(function(Field $field) {
334 334
             return $field->isFillable();
335 335
         });
336 336
     }
@@ -343,13 +343,13 @@  discard block
 block discarded – undo
343 343
      */
344 344
     public function getRelations(): Collection
345 345
     {
346
-        return collect($this->relations())->map(function (Field $field, string $key) {
347
-            if (! $field->getAccessor()) {
346
+        return collect($this->relations())->map(function(Field $field, string $key) {
347
+            if (!$field->getAccessor()) {
348 348
                 $field->accessor($key);
349 349
             }
350 350
 
351 351
             return $field;
352
-        })->map(function (Field $field) {
352
+        })->map(function(Field $field) {
353 353
             $accessor = $field->getAccessor();
354 354
 
355 355
             Utils::invariant(
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     public function getFieldByKey(string $key): ?Field
371 371
     {
372 372
         return $this->getFields()->merge($this->getRelationFields())
373
-            ->first(function (Field $field, $fieldKey) use ($key) {
373
+            ->first(function(Field $field, $fieldKey) use ($key) {
374 374
                 return $fieldKey === $key;
375 375
             });
376 376
     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function getConnections(): Collection
384 384
     {
385
-        return collect($this->getRelationFields())->map(function (Field $field, $key) {
385
+        return collect($this->getRelationFields())->map(function(Field $field, $key) {
386 386
             return $field->isList() ? Str::singular($key).'Ids' : $key.'Id';
387 387
         });
388 388
     }
Please login to merge, or discard this patch.