Skip to content

Commit

Permalink
refactor : wellknown implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Feb 12, 2024
1 parent ca4a7fd commit 8b74ba0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Provider/WellKnown.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ class WellKnown
/**
* @param array $infos
*/
public function __construct($infos)
public function __construct(array $infos = [])
{
$this->init($infos);
}

/**
* @param array $infos
*
* @return void
*/
public function init(array $infos)
{
foreach ($infos as $key => $value) {
if (property_exists($this, $key)) {
Expand All @@ -136,18 +146,18 @@ public function __construct($infos)
* @param string $url
* @param bool $secure
*
* @return WellKnown
* @return void
*
* @throws \Exception
*/
public static function fetch($url, $secure = true)
public function fetch($url, $secure = true)
{
$wellKnownUrl = $url;
if (strpos($wellKnownUrl, '/.well-known') === false) {
$wellKnownUrl = preg_replace('/\/?$/', '/.well-known/openid-configuration', $wellKnownUrl);
}

return new WellKnown(json_decode(file_get_contents($wellKnownUrl, false, stream_context_create([
$this->init(json_decode(file_get_contents($wellKnownUrl, false, stream_context_create([
'ssl' => [
'verify_peer' => $secure,
'verify_peer_name' => $secure,
Expand Down

0 comments on commit 8b74ba0

Please sign in to comment.