Test Setup Failed
Push — develop ( 0e869e...cc4ffb )
by Jimmy
27:20 queued 13:45
created
routes/web.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,4 +5,4 @@
 block discarded – undo
5 5
 use Spinen\Halo\Http\Controllers\HaloController;
6 6
 
7 7
 Route::get(rtrim(Config::get('halo.oauth.authorization_code.route.sso', '/halo/sso'), '/'), HaloController::class)
8
-     ->name('halo.sso.redirect_uri');
8
+        ->name('halo.sso.redirect_uri');
Please login to merge, or discard this patch.
src/Api/Client.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
         $this->setToken($token);
28 28
     }
29 29
 
30
-     /**
31
-      * Shortcut to 'DELETE' request
32
-      *
33
-      * @throws GuzzleException
34
-      * @throws TokenException
35
-      */
36
-     public function delete(string $path): ?array
37
-     {
38
-         return $this->request($path, [], 'DELETE');
39
-     }
30
+        /**
31
+         * Shortcut to 'DELETE' request
32
+         *
33
+         * @throws GuzzleException
34
+         * @throws TokenException
35
+         */
36
+        public function delete(string $path): ?array
37
+        {
38
+            return $this->request($path, [], 'DELETE');
39
+        }
40 40
 
41 41
     /**
42 42
      * Generate keys need for PKCE
@@ -272,41 +272,41 @@  discard block
 block discarded – undo
272 272
         }
273 273
     }
274 274
 
275
-     /**
276
-      * Validate & set the configs
277
-      *
278
-      * @throws ClientConfigurationException
279
-      */
280
-     protected function setConfigs(array $configs): self
281
-     {
282
-         // Replace empty strings with nulls in config values
283
-         $this->configs = array_map(fn ($v) => $v === '' ? null : $v, $configs);
284
-
285
-         // Default to true if not set
286
-         $this->configs['oauth']['authorization_code']['pkce'] ??= true;
287
-
288
-         if (is_null($this->configs['oauth']['authorization_server'] ?? null)) {
289
-             throw new ClientConfigurationException('The "authorization_server" cannot be null');
290
-         }
291
-
292
-         if (! filter_var($this->configs['oauth']['authorization_server'], FILTER_VALIDATE_URL)) {
293
-             throw new ClientConfigurationException(
294
-                 sprintf('A valid url must be provided for "authorization_server" [%s]', $this->configs['oauth']['authorization_server'])
295
-             );
296
-         }
297
-
298
-         if (is_null($this->configs['resource_server'] ?? null)) {
299
-             throw new ClientConfigurationException('The "resource_server" cannot be null');
300
-         }
301
-
302
-         if (! filter_var($this->configs['resource_server'], FILTER_VALIDATE_URL)) {
303
-             throw new ClientConfigurationException(
304
-                 sprintf('A valid url must be provided for "resource_server" [%s]', $this->configs['resource_server'])
305
-             );
306
-         }
307
-
308
-         return $this;
309
-     }
275
+        /**
276
+         * Validate & set the configs
277
+         *
278
+         * @throws ClientConfigurationException
279
+         */
280
+        protected function setConfigs(array $configs): self
281
+        {
282
+            // Replace empty strings with nulls in config values
283
+            $this->configs = array_map(fn ($v) => $v === '' ? null : $v, $configs);
284
+
285
+            // Default to true if not set
286
+            $this->configs['oauth']['authorization_code']['pkce'] ??= true;
287
+
288
+            if (is_null($this->configs['oauth']['authorization_server'] ?? null)) {
289
+                throw new ClientConfigurationException('The "authorization_server" cannot be null');
290
+            }
291
+
292
+            if (! filter_var($this->configs['oauth']['authorization_server'], FILTER_VALIDATE_URL)) {
293
+                throw new ClientConfigurationException(
294
+                    sprintf('A valid url must be provided for "authorization_server" [%s]', $this->configs['oauth']['authorization_server'])
295
+                );
296
+            }
297
+
298
+            if (is_null($this->configs['resource_server'] ?? null)) {
299
+                throw new ClientConfigurationException('The "resource_server" cannot be null');
300
+            }
301
+
302
+            if (! filter_var($this->configs['resource_server'], FILTER_VALIDATE_URL)) {
303
+                throw new ClientConfigurationException(
304
+                    sprintf('A valid url must be provided for "resource_server" [%s]', $this->configs['resource_server'])
305
+                );
306
+            }
307
+
308
+            return $this;
309
+        }
310 310
 
311 311
     /**
312 312
      * Set debug
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
                 'verifier' => $verifier = base64_encode(Str::random($length)),
49 49
                 // Convert "+" to "-" & "/" to "_" & remove trailing "="
50 50
                 'challenge' => rtrim(
51
-                    characters: '=',
52
-                    string: strtr(
53
-                        from: '+/',
54
-                        string: base64_encode(hash(algo: 'sha256', data: $verifier, binary: true)),
55
-                        to: '-_',
51
+                    characters : '=',
52
+                    string : strtr(
53
+                        from : '+/',
54
+                        string : base64_encode(hash(algo : 'sha256', data : $verifier, binary : true)),
55
+                        to : '-_',
56 56
                     ),
57 57
                 ),
58 58
             ]
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $grant_type = $this->token->grant_type ?? $params['grant_type'];
102 102
 
103 103
         if (is_null($this->configs['oauth'][$grant_type]['id'] ?? null)) {
104
-            throw new ClientConfigurationException('The "client_id" for "'.$grant_type.'" cannot be null');
104
+            throw new ClientConfigurationException('The "client_id" for "' . $grant_type . '" cannot be null');
105 105
         }
106 106
 
107 107
         try {
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
                         ],
121 121
                     ],
122 122
                     uri: $this->uri(
123
-                        path: 'token?'.http_build_query(
123
+                        path: 'token?' . http_build_query(
124 124
                             $this->configs['tenant'] ? ['tenant' => $this->configs['tenant']] : [],
125 125
                         ),
126
-                        url: $this->configs['oauth']['authorization_server']
126
+                        url : $this->configs['oauth']['authorization_server']
127 127
                     ),
128 128
                 )
129 129
                     ->getBody()
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         }
199 199
 
200 200
         return $this->uri(
201
-            path: 'authorize?'.http_build_query(
201
+            path: 'authorize?' . http_build_query(
202 202
                 [
203 203
                     'client_id' => $this->configs['oauth']['authorization_code']['id'],
204 204
                     ...$challenge
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                     'scope' => $scope ?? $this->token->scope,
213 213
                     ...$this->configs['tenant'] ? ['tenant' => $this->configs['tenant']] : [],
214 214
                 ]),
215
-            url: $this->configs['oauth']['authorization_server']
215
+            url : $this->configs['oauth']['authorization_server']
216 216
         );
217 217
     }
218 218
 
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
     {
249 249
         try {
250 250
             return json_decode(
251
-                associative: true,
252
-                json: $this->guzzle->request(
253
-                    method: $method,
254
-                    options: [
251
+                associative : true,
252
+                json : $this->guzzle->request(
253
+                    method : $method,
254
+                    options : [
255 255
                         'debug' => $this->debug,
256 256
                         'headers' => [
257 257
                             'Authorization' => (string) $this->getToken(),
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                         ],
260 260
                         'body' => empty($data) ? null : json_encode($data),
261 261
                     ],
262
-                    uri: $this->uri($path),
262
+                    uri : $this->uri($path),
263 263
                 )
264 264
                     ->getBody()
265 265
                     ->getContents(),
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
              throw new ClientConfigurationException('The "authorization_server" cannot be null');
290 290
          }
291 291
 
292
-         if (! filter_var($this->configs['oauth']['authorization_server'], FILTER_VALIDATE_URL)) {
292
+         if (!filter_var($this->configs['oauth']['authorization_server'], FILTER_VALIDATE_URL)) {
293 293
              throw new ClientConfigurationException(
294 294
                  sprintf('A valid url must be provided for "authorization_server" [%s]', $this->configs['oauth']['authorization_server'])
295 295
              );
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
              throw new ClientConfigurationException('The "resource_server" cannot be null');
300 300
          }
301 301
 
302
-         if (! filter_var($this->configs['resource_server'], FILTER_VALIDATE_URL)) {
302
+         if (!filter_var($this->configs['resource_server'], FILTER_VALIDATE_URL)) {
303 303
              throw new ClientConfigurationException(
304 304
                  sprintf('A valid url must be provided for "resource_server" [%s]', $this->configs['resource_server'])
305 305
              );
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
     /**
322 322
      * Set the token & refresh if needed
323 323
      */
324
-    public function setToken(Token|string $token): self
324
+    public function setToken(Token | string $token): self
325 325
     {
326 326
         $this->token = is_string($token)
327
-            ? new Token(access_token: $token)
327
+            ? new Token(access_token : $token)
328 328
             : $token;
329 329
 
330 330
         return $this;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         $path = ltrim($path ?? '/', '/');
347 347
 
348 348
         return rtrim($url ?? $this->configs['resource_server'], '/')
349
-            .($path ? (Str::startsWith($path, '?') ? null : '/').$path : '/');
349
+            .($path ? (Str::startsWith($path, '?') ? null : '/') . $path : '/');
350 350
     }
351 351
 
352 352
     /**
Please login to merge, or discard this patch.
src/Api/Token.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function __toString(): string
35 35
     {
36
-        return $this->token_type.' '.$this->access_token;
36
+        return $this->token_type . ' ' . $this->access_token;
37 37
     }
38 38
 
39 39
     /**
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function isValid(?string $scope = null): bool
65 65
     {
66
-        return ! is_null($this->access_token) &&
67
-            ! $this->isExpired() &&
66
+        return !is_null($this->access_token) &&
67
+            !$this->isExpired() &&
68 68
             ($scope ? $this->allowedScope($scope) : true);
69 69
     }
70 70
 
Please login to merge, or discard this patch.
src/Http/Middleware/Filter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      */
29 29
     public function handle(Request $request, Closure $next)
30 30
     {
31
-        if (! $request->user()->halo_token) {
31
+        if (!$request->user()->halo_token) {
32 32
             // Set intended route, so that after linking account, user is put where they were going
33 33
             $this->redirector->setIntendedUrl($request->path());
34 34
 
Please login to merge, or discard this patch.
src/Providers/ServiceProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function register()
35 35
     {
36
-        $this->mergeConfigFrom(__DIR__.'/../../config/halo.php', 'halo');
36
+        $this->mergeConfigFrom(__DIR__ . '/../../config/halo.php', 'halo');
37 37
     }
38 38
 
39 39
     /**
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
     protected function registerPublishes()
55 55
     {
56 56
         if ($this->app->runningInConsole()) {
57
-            $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
57
+            $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
58 58
 
59 59
             $this->publishes(
60 60
                 groups: 'halo-config',
61 61
                 paths: [
62
-                    __DIR__.'/../../config/halo.php' => config_path('halo.php'),
62
+                    __DIR__ . '/../../config/halo.php' => config_path('halo.php'),
63 63
                 ],
64 64
             );
65 65
 
66 66
             $this->publishes(
67 67
                 groups: 'halo-migrations',
68 68
                 paths: [
69
-                    __DIR__.'/../../database/migrations' => database_path('migrations'),
69
+                    __DIR__ . '/../../database/migrations' => database_path('migrations'),
70 70
                 ],
71 71
             );
72 72
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                     'namespace' => 'Spinen\Halo\Http\Controllers',
84 84
                     'middleware' => Config::get('halo.oauth.authorization_code.route.middleware', ['web']),
85 85
                 ],
86
-                routes: fn () => $this->loadRoutesFrom(realpath(__DIR__.'/../../routes/web.php'))
86
+                routes: fn () => $this->loadRoutesFrom(realpath(__DIR__ . '/../../routes/web.php'))
87 87
             );
88 88
         }
89 89
     }
Please login to merge, or discard this patch.
src/Support/Relations/BelongsTo.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * Get the foreign key's name
44 44
      */
45
-    public function getForeignKey(): int|string|null
45
+    public function getForeignKey(): int | string | null
46 46
     {
47 47
         return $this->getChild()->{$this->getForeignKeyName()};
48 48
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getResults(): ?Model
67 67
     {
68
-        if (! $this->getForeignKey()) {
68
+        if (!$this->getForeignKey()) {
69 69
             return null;
70 70
         }
71 71
 
Please login to merge, or discard this patch.
src/Concerns/HasClient.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      */
22 22
     public function getClient(): Client
23 23
     {
24
-        if (! isset($this->client) && $this->parentModel) {
24
+        if (!isset($this->client) && $this->parentModel) {
25 25
             $this->client = $this->parentModel->getClient();
26 26
         }
27 27
 
Please login to merge, or discard this patch.
src/Concerns/HasHalo.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,13 +63,13 @@
 block discarded – undo
63 63
     public function haloToken(): Attribute
64 64
     {
65 65
         return Attribute::make(
66
-            get: fn ($value, array $attributes): ?Token => ! is_null($attributes['halo_token'])
66
+            get: fn ($value, array $attributes): ?Token => !is_null($attributes['halo_token'])
67 67
               ? unserialize(Crypt::decryptString($attributes['halo_token']))
68 68
               : null,
69
-            set: function ($value): ?string {
69
+            set : function($value): ?string {
70 70
                 // If setting the password & already have a client, then
71 71
                 // empty the client to use new password in client
72
-                if (! is_null($this->builder)) {
72
+                if (!is_null($this->builder)) {
73 73
                     $this->builder = null;
74 74
                 }
75 75
 
Please login to merge, or discard this patch.
src/Support/Builder.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function __call(string $name, array $arguments)
191 191
     {
192
-        if (! isset($this->parentModel) && array_key_exists($name, $this->rootModels)) {
192
+        if (!isset($this->parentModel) && array_key_exists($name, $this->rootModels)) {
193 193
             return $this->newInstanceForModel($this->rootModels[$name]);
194 194
         }
195 195
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      * @throws NoClientException
211 211
      * @throws TokenException
212 212
      */
213
-    public function __get(string $name): Collection|Model|null
213
+    public function __get(string $name): Collection | Model | null
214 214
     {
215 215
         return match (true) {
216 216
             $name === 'agent' => $this->newInstanceForModel(Agent::class)
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
             $name === 'user' => $this->newInstanceForModel(User::class)
223 223
                 ->get(extra: 'me')
224 224
                 ->first(),
225
-            ! $this->parentModel && array_key_exists($name, $this->rootModels) => $this->{$name}()
225
+            !$this->parentModel && array_key_exists($name, $this->rootModels) => $this->{$name}()
226 226
                 ->get(),
227 227
             default => null,
228 228
         };
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      * @throws NoClientException
260 260
      * @throws TokenException
261 261
      */
262
-    public function delete(int|string $id): bool
262
+    public function delete(int | string $id): bool
263 263
     {
264 264
         //  TODO: Consider allowing $id to be null & deleting all
265 265
         return $this->make([$this->getModel()->getKeyName() => $id])
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      * @throws NoClientException
275 275
      * @throws TokenException
276 276
      */
277
-    public function get(array|string $properties = ['*'], ?string $extra = null): Collection|Model
277
+    public function get(array | string $properties = ['*'], ?string $extra = null): Collection | Model
278 278
     {
279 279
         $properties = Arr::wrap($properties);
280 280
         $count = null;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                             ->toArray()
312 312
                 )
313 313
                 ->setClient($this->getClient()->setDebug(false)))
314
-            ->setPagination(count: $count, page: $page, pageSize: $pageSize);
314
+            ->setPagination(count : $count, page : $page, pageSize : $pageSize);
315 315
     }
316 316
 
317 317
     /**
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public function getModel(): Model
323 323
     {
324
-        if (! isset($this->class)) {
324
+        if (!isset($this->class)) {
325 325
             throw new InvalidRelationshipException();
326 326
         }
327 327
 
328
-        if (! isset($this->model)) {
328
+        if (!isset($this->model)) {
329 329
             $this->model = (new $this->class([], $this->parentModel))->setClient($this->client);
330 330
         }
331 331
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         $id = Arr::pull($w, $this->getModel()->getKeyName());
344 344
 
345 345
         return $this->getModel()
346
-            ->getPath($extra.(is_null($id) ? null : '/'.$id), $w);
346
+            ->getPath($extra . (is_null($id) ? null : '/' . $id), $w);
347 347
     }
348 348
 
349 349
     /**
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      * @throws NoClientException
355 355
      * @throws TokenException
356 356
      */
357
-    public function find(int|string $id, array|string $properties = ['*']): Model
357
+    public function find(int | string $id, array | string $properties = ['*']): Model
358 358
     {
359 359
         return $this->whereId($id)
360 360
             ->get($properties)
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
      *
377 377
      * @throws InvalidRelationshipException
378 378
      */
379
-    public function limit(int|string $count): self
379
+    public function limit(int | string $count): self
380 380
     {
381 381
         return $this->where('count', (int) $count);
382 382
     }
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
      *
462 462
      * @throws InvalidRelationshipException
463 463
      */
464
-    public function page(int|string $number, int|string|null $size = null): self
464
+    public function page(int | string $number, int | string | null $size = null): self
465 465
     {
466 466
         return $this->where('page_no', (int) $number)
467 467
             ->when($size, fn (self $b): self => $b->paginate($size));
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      *
473 473
      * @throws InvalidRelationshipException
474 474
      */
475
-    public function pageinate(int|string|null $size = null): self
475
+    public function pageinate(int | string | null $size = null): self
476 476
     {
477 477
         return $this->paginate($size);
478 478
     }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
      *
483 483
      * @throws InvalidRelationshipException
484 484
      */
485
-    public function paginate(int|string|null $size = null): self
485
+    public function paginate(int | string | null $size = null): self
486 486
     {
487 487
         return $this->unless($size, fn (self $b): self => $b->where('pageinate', false))
488 488
             ->when($size, fn (self $b): self => $b->where('pageinate', true)->where('page_size', (int) $size));
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
      */
529 529
     public function setClass(string $class): self
530 530
     {
531
-        if (! class_exists($class)) {
531
+        if (!class_exists($class)) {
532 532
             throw new ModelNotFoundException(sprintf('The model [%s] not found.', $class));
533 533
         }
534 534
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
      *
553 553
      * @throws InvalidRelationshipException
554 554
      */
555
-    public function take(int|string $count): self
555
+    public function take(int | string $count): self
556 556
     {
557 557
         return $this->limit($count);
558 558
     }
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
      *
563 563
      * @throws InvalidRelationshipException
564 564
      */
565
-    public function where(iterable|string $property, $value = true): self
565
+    public function where(iterable | string $property, $value = true): self
566 566
     {
567 567
         is_iterable($property)
568 568
             // Given multiple properties to set, so recursively call self
569 569
             ? Collection::wrap($property)->each(
570
-                fn ($v, string $p): self => is_numeric($p)
570
+                fn ($v, string $p) : self => is_numeric($p)
571 571
                     // No value given, so use default value
572 572
                     ? $this->where($v, $value)
573 573
                     // Pass property & value
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
      *
587 587
      * @throws InvalidRelationshipException
588 588
      */
589
-    public function whereId(int|string|null $id): self
589
+    public function whereId(int | string | null $id): self
590 590
     {
591 591
         return $this->where($this->getModel()->getKeyName(), $id);
592 592
     }
Please login to merge, or discard this patch.