Test Setup Failed
Push — develop ( 13e851...151a72 )
by Jimmy
14:05
created
src/Support/Model.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         $foreignKey = $foreignKey ?? $this->assumeForeignKey($related);
257 257
 
258 258
         $builder = (new Builder())->setClass($related)
259
-                                  ->setClient($this->getClient());
259
+                                    ->setClient($this->getClient());
260 260
 
261 261
         return new BelongsTo($builder, $this, $foreignKey);
262 262
     }
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
         $foreignKey = $foreignKey ?? $this->assumeForeignKey($related);
277 277
 
278 278
         $builder = (new Builder())->setClass($related)
279
-                                  ->setClient($this->getClient())
280
-                                  ->setParent($this);
279
+                                    ->setClient($this->getClient())
280
+                                    ->setParent($this);
281 281
 
282 282
         return new ChildOf($builder, $this, $foreignKey);
283 283
     }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
         try {
311 311
             $this->getClient()
312
-                 ->delete($this->getPath());
312
+                    ->delete($this->getPath());
313 313
 
314 314
             return true;
315 315
         } catch (GuzzleException $e) {
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     public function givenOne($related, $attributes, $reset = false): Model
510 510
     {
511 511
         return (new $related([], $this->parentModel))->setClient($this->getClient())
512
-                                                     ->newFromBuilder($reset ? reset($attributes) : $attributes);
512
+                                                        ->newFromBuilder($reset ? reset($attributes) : $attributes);
513 513
     }
514 514
 
515 515
     /**
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
     public function hasMany($related): HasMany
525 525
     {
526 526
         $builder = (new Builder())->setClass($related)
527
-                                  ->setClient($this->getClient())
528
-                                  ->setParent($this);
527
+                                    ->setClient($this->getClient())
528
+                                    ->setParent($this);
529 529
 
530 530
         return new HasMany($builder, $this);
531 531
     }
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
             }
682 682
 
683 683
             $response = $this->getClient()
684
-                             ->post($this->getPath(), [$this->toArray()]);
684
+                                ->post($this->getPath(), [$this->toArray()]);
685 685
 
686 686
             $this->exists = true;
687 687
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     protected function assumeForeignKey($related): string
240 240
     {
241
-        return Str::snake((new $related())->getResponseKey()).'_id';
241
+        return Str::snake((new $related())->getResponseKey()) . '_id';
242 242
     }
243 243
 
244 244
     /**
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public function getOrderByDirectionParameter(): string
381 381
     {
382
-        return $this->orderByDirectionParameter ?? $this->getOrderByParameter().'desc';
382
+        return $this->orderByDirectionParameter ?? $this->getOrderByParameter() . 'desc';
383 383
     }
384 384
 
385 385
     /**
@@ -407,20 +407,20 @@  discard block
 block discarded – undo
407 407
         // If have an id, then put it on the end
408 408
         // NOTE: Halo treats creates & updates the same, so only on existing
409 409
         if ($this->exist && $this->getKey()) {
410
-            $path .= '/'.$this->getKey();
410
+            $path .= '/' . $this->getKey();
411 411
         }
412 412
 
413 413
         // Stick any extra things on the end
414
-        if (! is_null($extra)) {
415
-            $path .= '/'.ltrim($extra, '/');
414
+        if (!is_null($extra)) {
415
+            $path .= '/' . ltrim($extra, '/');
416 416
         }
417 417
 
418
-        if (! empty($query = $this->getDefaultWheres($query))) {
419
-            $path .= '?'.http_build_query($this->convertBoolToString($query));
418
+        if (!empty($query = $this->getDefaultWheres($query))) {
419
+            $path .= '?' . http_build_query($this->convertBoolToString($query));
420 420
         }
421 421
 
422 422
         // If there is a parentModel & not have an id (unless for nested), then prepend parentModel
423
-        if (! is_null($this->parentModel) && (! $this->getKey() || $this->isNested())) {
423
+        if (!is_null($this->parentModel) && (!$this->getKey() || $this->isNested())) {
424 424
             return $this->parentModel->getPath($path);
425 425
         }
426 426
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
     {
439 439
         $relation = $this->{$method}();
440 440
 
441
-        if (! $relation instanceof Relation) {
441
+        if (!$relation instanceof Relation) {
442 442
             $exception_message = is_null($relation)
443 443
                 ? '%s::%s must return a relationship instance, but "null" was returned. Was the "return" keyword used?'
444 444
                 : '%s::%s must return a relationship instance.';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 
451 451
         return tap(
452 452
             $relation->getResults(),
453
-            function ($results) use ($method) {
453
+            function($results) use ($method) {
454 454
                 $this->setRelation($method, $results);
455 455
             }
456 456
         );
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
         $model = (new $related([], $this->parentModel))->setClient($this->getClient());
492 492
 
493 493
         return (new Collection($given))->map(
494
-            function ($attributes) use ($model, $reset) {
494
+            function($attributes) use ($model, $reset) {
495 495
                 return $model->newFromBuilder($reset ? reset($attributes) : $attributes);
496 496
             }
497 497
         );
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
      */
597 597
     public function offsetExists($offset): bool
598 598
     {
599
-        return ! is_null($this->getAttribute($offset));
599
+        return !is_null($this->getAttribute($offset));
600 600
     }
601 601
 
602 602
     /**
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         }
677 677
 
678 678
         try {
679
-            if (! $this->isDirty()) {
679
+            if (!$this->isDirty()) {
680 680
                 return true;
681 681
             }
682 682
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
      */
708 708
     public function saveOrFail(): bool
709 709
     {
710
-        if (! $this->save()) {
710
+        if (!$this->save()) {
711 711
             throw new UnableToSaveException();
712 712
         }
713 713
 
Please login to merge, or discard this patch.
src/Support/Builder.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function __call(string $name, array $arguments)
163 163
     {
164
-        if (! isset($this->parentModel) && array_key_exists($name, $this->rootModels)) {
164
+        if (!isset($this->parentModel) && array_key_exists($name, $this->rootModels)) {
165 165
             return $this->newInstanceForModel($this->rootModels[$name]);
166 166
         }
167 167
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * @throws NoClientException
183 183
      * @throws TokenException
184 184
      */
185
-    public function __get(string $name): Collection|Model|null
185
+    public function __get(string $name): Collection | Model | null
186 186
     {
187 187
         return match (true) {
188 188
             $name === 'agent' => $this->newInstanceForModel(Agent::class)
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             $name === 'user' => $this->newInstanceForModel(User::class)
192 192
                 ->get(extra: 'me')
193 193
                 ->first(),
194
-            ! $this->parentModel && array_key_exists($name, $this->rootModels) => $this->{$name}()
194
+            !$this->parentModel && array_key_exists($name, $this->rootModels) => $this->{$name}()
195 195
                 ->get(),
196 196
             default => null,
197 197
         };
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
      * @throws NoClientException
231 231
      * @throws TokenException
232 232
      */
233
-    public function get(array|string $properties = ['*'], ?string $extra = null): Collection|Model
233
+    public function get(array | string $properties = ['*'], ?string $extra = null): Collection | Model
234 234
     {
235 235
         $properties = Arr::wrap($properties);
236 236
         $count = null;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                             ->toArray()
268 268
                 )
269 269
                 ->setClient($this->getClient()->setDebug(false)))
270
-            ->setPagination(count: $count, page: $page, pageSize: $pageSize);
270
+            ->setPagination(count : $count, page : $page, pageSize : $pageSize);
271 271
     }
272 272
 
273 273
     /**
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function getModel(): Model
279 279
     {
280
-        if (! isset($this->class)) {
280
+        if (!isset($this->class)) {
281 281
             throw new InvalidRelationshipException();
282 282
         }
283 283
 
284
-        if (! isset($this->model)) {
284
+        if (!isset($this->model)) {
285 285
             $this->model = (new $this->class([], $this->parentModel))->setClient($this->client);
286 286
         }
287 287
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      */
296 296
     public function getPath(?string $extra = null): ?string
297 297
     {
298
-        $w = (array)$this->wheres;
298
+        $w = (array) $this->wheres;
299 299
         $id = Arr::pull($w, $this->getModel()->getKeyName());
300 300
 
301 301
         return $this->getModel()
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      * @throws NoClientException
311 311
      * @throws TokenException
312 312
      */
313
-    public function find(int|string $id, array|string $properties = ['*']): Model
313
+    public function find(int | string $id, array | string $properties = ['*']): Model
314 314
     {
315 315
         return $this->whereId($id)
316 316
             ->get($properties)
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      *
333 333
      * @throws InvalidRelationshipException
334 334
      */
335
-    public function limit(int|string $count): self
335
+    public function limit(int | string $count): self
336 336
     {
337 337
         return $this->where('count', (int) $count);
338 338
     }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      *
418 418
      * @throws InvalidRelationshipException
419 419
      */
420
-    public function page(int|string $number, int|string|null $size = null): self
420
+    public function page(int | string $number, int | string | null $size = null): self
421 421
     {
422 422
         return $this->where('page_no', (int) $number)
423 423
             ->when($size, fn (self $b): self => $b->paginate($size));
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
      *
429 429
      * @throws InvalidRelationshipException
430 430
      */
431
-    public function pageinate(int|string|null $size = null): self
431
+    public function pageinate(int | string | null $size = null): self
432 432
     {
433 433
         return $this->paginate($size);
434 434
     }
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
      *
439 439
      * @throws InvalidRelationshipException
440 440
      */
441
-    public function paginate(int|string|null $size = null): self
441
+    public function paginate(int | string | null $size = null): self
442 442
     {
443 443
         return $this->unless($size, fn (self $b): self => $b->where('pageinate', false))
444 444
             ->when($size, fn (self $b): self => $b->where('pageinate', true)->where('page_size', (int) $size));
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
      */
482 482
     public function setClass(string $class): self
483 483
     {
484
-        if (! class_exists($class)) {
484
+        if (!class_exists($class)) {
485 485
             throw new ModelNotFoundException(sprintf('The model [%s] not found.', $class));
486 486
         }
487 487
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
      *
506 506
      * @throws InvalidRelationshipException
507 507
      */
508
-    public function take(int|string $count): self
508
+    public function take(int | string $count): self
509 509
     {
510 510
         return $this->limit($count);
511 511
     }
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
      *
530 530
      * @throws InvalidRelationshipException
531 531
      */
532
-    public function whereId(int|string|null $id): self
532
+    public function whereId(int | string | null $id): self
533 533
     {
534 534
         return $this->where($this->getModel()->getKeyName(), $id);
535 535
     }
Please login to merge, or discard this patch.