Skip to content

Commit

Permalink
remove constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
JoMessina committed Nov 9, 2023
1 parent 9b6b87a commit 2e25ac1
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/Client/SharedAuthenticationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,7 @@

class SharedAuthenticationMiddleware
{
private static ?AuthenticationMiddleware $client = null;
private function __construct(
private readonly ClientInterface $decorated,
private readonly RequestFactoryInterface $requestFactory,
private readonly UriFactoryInterface $uriFactory,
private readonly string $oauthBaseUri,
private readonly string $clientId,
private readonly string $clientSecret,
private readonly string $accessToken,
private readonly string $refreshToken,
) {
self::$client = new AuthenticationMiddleware(
$this->decorated, $this->requestFactory,
$this->uriFactory, $this->oauthBaseUri,
$this->clientId, $this->clientSecret,
$this->accessToken, $this->refreshToken
);
}
private static ?AuthenticationMiddleware $instance = null;

public static function getInstance(
ClientInterface $decorated,
Expand All @@ -42,9 +25,9 @@ public static function getInstance(
string $refreshToken,
): AuthenticationMiddleware
{
if (self::$client === null) {
new SharedAuthenticationMiddleware($decorated, $requestFactory, $uriFactory, $oauthBaseUri, $clientId, $clientSecret, $accessToken, $refreshToken);
if (self::$instance === null) {
self::$instance = new AuthenticationMiddleware($decorated, $requestFactory, $uriFactory, $oauthBaseUri, $clientId, $clientSecret, $accessToken, $refreshToken);
}
return self::$client;
return self::$instance;
}
}

0 comments on commit 2e25ac1

Please sign in to comment.