@@ -5,4 +5,4 @@ |
||
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'); |
@@ -27,16 +27,16 @@ discard block |
||
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 |
||
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 |
@@ -256,7 +256,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |