Skip to content

Commit

Permalink
fix: 🐛 Delete null values from config
Browse files Browse the repository at this point in the history
  • Loading branch information
maicol07 committed Oct 28, 2021
1 parent f28d81a commit deeec3d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ class Client
*/
public function __construct(array $user_config)
{
$user_config = array_filter($user_config, static fn ($value) => !is_null($value));

$this->http_client = (new Factory())->withOptions([
'connect_timeout' => Arr::get($user_config, 'timeout', 0) ?? 0,
'connect_timeout' => Arr::get($user_config, 'timeout', 0),
'proxy' => Arr::get($user_config, 'http_proxy'),
'verify' => (Arr::get($user_config, 'verify', true) ?? true) ?: (Arr::get($user_config, 'cert_path', false) ?? false)
'verify' => Arr::get($user_config, 'verify', true) ?: Arr::get($user_config, 'cert_path', false)
]);

// Auto discovery
Expand All @@ -125,6 +127,7 @@ public function __construct(array $user_config)
"$provider_url/.well-known/openid-configuration",
Arr::get($user_config, 'well_known_request_params')
);

if ($response->ok()) {
$config = $response->collect()->merge($user_config);
}
Expand Down Expand Up @@ -158,7 +161,7 @@ public function __construct(array $user_config)
'jwt_plain_key' => false
];
foreach ($props as $prop => $default) {
$this->{$prop} = $config->get($prop, $default) ?? $default;
$this->{$prop} = $config->get($prop, $default);
}

if (empty($this->code_challenge_method)) {
Expand Down

0 comments on commit deeec3d

Please sign in to comment.