refreshToken = $refreshToken; $this->clientId = $clientId; $this->clientSecret = $clientSecret; $this->registrationExpiresAt = $registrationExpiresAt; $this->region = $region; $this->startUrl = $startUrl; } /** * @return bool */ public function isExpired() { if (isset($this->registrationExpiresAt) && time() >= $this->registrationExpiresAt ) { return false; } return $this->expires !== null && time() >= $this->expires; } /** * @return string|null */ public function getRefreshToken() { return $this->refreshToken; } /** * @return string|null */ public function getClientId() { return $this->clientId; } /** * @return string|null */ public function getClientSecret() { return $this->clientSecret; } /** * @return int|null */ public function getRegistrationExpiresAt() { return $this->registrationExpiresAt; } /** * @return string|null */ public function getRegion() { return $this->region; } /** * @return string|null */ public function getStartUrl() { return $this->startUrl; } /** * Creates an instance of SsoToken from a token data. * * @param $tokenData * * @return SsoToken */ public static function fromTokenData($tokenData): SsoToken { return new SsoToken( $tokenData['accessToken'], \strtotime($tokenData['expiresAt']), isset($tokenData['refreshToken']) ? $tokenData['refreshToken'] : null, isset($tokenData['clientId']) ? $tokenData['clientId'] : null, isset($tokenData['clientSecret']) ? $tokenData['clientSecret'] : null, isset($tokenData['registrationExpiresAt']) ? $tokenData['registrationExpiresAt'] : null, isset($tokenData['region']) ? $tokenData['region'] : null, isset($tokenData['startUrl']) ? $tokenData['startUrl'] : null ); } }