diff --git a/src/IamSignerTrait.php b/src/IamSignerTrait.php index 9035177f9..da3c90903 100644 --- a/src/IamSignerTrait.php +++ b/src/IamSignerTrait.php @@ -27,7 +27,7 @@ trait IamSignerTrait /** * @var Iam|null */ - private ?Iam $iam; + private $iam; /** * Sign a string using the default service account private key. @@ -51,8 +51,9 @@ public function signBlob($stringToSign, $forceOpenSsl = false, $accessToken = nu // Providing a signer is useful for testing, but it's undocumented // because it's not something a user would generally need to do. - if (!isset($this->iam)) { - $this->iam = $this instanceof GetUniverseDomainInterface + $signer = $this->iam; + if (!$signer) { + $signer = $this instanceof GetUniverseDomainInterface ? new Iam($httpHandler, $this->getUniverseDomain()) : new Iam($httpHandler); } @@ -66,6 +67,6 @@ public function signBlob($stringToSign, $forceOpenSsl = false, $accessToken = nu : $this->fetchAuthToken($httpHandler)['access_token']; } - return $this->iam->signBlob($email, $accessToken, $stringToSign); + return $signer->signBlob($email, $accessToken, $stringToSign); } }