@@ -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 |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $foreignKey = $foreignKey ?? $this->assumeForeignKey($related); |
236 | 236 | |
237 | 237 | $builder = (new Builder())->setClass($related) |
238 | - ->setClient($this->getClient()); |
|
238 | + ->setClient($this->getClient()); |
|
239 | 239 | |
240 | 240 | return new BelongsTo($builder, $this, $foreignKey); |
241 | 241 | } |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | $foreignKey = $foreignKey ?? $this->assumeForeignKey($related); |
256 | 256 | |
257 | 257 | $builder = (new Builder())->setClass($related) |
258 | - ->setClient($this->getClient()) |
|
259 | - ->setParent($this); |
|
258 | + ->setClient($this->getClient()) |
|
259 | + ->setParent($this); |
|
260 | 260 | |
261 | 261 | return new ChildOf($builder, $this, $foreignKey); |
262 | 262 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | try { |
278 | 278 | $this->getClient() |
279 | - ->delete($this->getPath()); |
|
279 | + ->delete($this->getPath()); |
|
280 | 280 | |
281 | 281 | return true; |
282 | 282 | } catch (GuzzleException $e) { |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | public function givenOne($related, $attributes, $reset = false): Model |
450 | 450 | { |
451 | 451 | return (new $related([], $this->parentModel))->setClient($this->getClient()) |
452 | - ->newFromBuilder($reset ? reset($attributes) : $attributes); |
|
452 | + ->newFromBuilder($reset ? reset($attributes) : $attributes); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | public function hasMany($related): HasMany |
465 | 465 | { |
466 | 466 | $builder = (new Builder())->setClass($related) |
467 | - ->setClient($this->getClient()) |
|
468 | - ->setParent($this); |
|
467 | + ->setClient($this->getClient()) |
|
468 | + ->setParent($this); |
|
469 | 469 | |
470 | 470 | return new HasMany($builder, $this); |
471 | 471 | } |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | if ($this->exists) { |
624 | 624 | // TODO: If we get null from the PUT, throw/handle exception |
625 | 625 | $response = $this->getClient() |
626 | - ->put($this->getPath(), $this->getDirty()); |
|
626 | + ->put($this->getPath(), $this->getDirty()); |
|
627 | 627 | |
628 | 628 | // Record the changes |
629 | 629 | $this->syncChanges(); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | } |
636 | 636 | |
637 | 637 | $response = $this->getClient() |
638 | - ->post($this->getPath(), $this->toArray()); |
|
638 | + ->post($this->getPath(), $this->toArray()); |
|
639 | 639 | |
640 | 640 | $this->exists = true; |
641 | 641 |