$responseData */ public function __construct( public readonly string $endpoint, public readonly int $statusCode, public readonly ?string $oauthError, public readonly ?string $oauthErrorDescription, public readonly array $responseData, public readonly ?string $grantType = NULL, ) { $message = \sprintf('OAuth %s request failed with HTTP %d.', $endpoint, $statusCode); if ($oauthError !== NULL) { $message .= ' ' . $oauthError; if ($oauthErrorDescription !== NULL && $oauthErrorDescription !== '') { $message .= ': ' . $oauthErrorDescription; } } parent::__construct($message); } /** * Returns whether the response proves that the refresh token is unusable. */ public function definitivelyRejectsRefreshToken(): bool { return ( \in_array($this->endpoint, ['token'], TRUE) && \in_array($this->grantType, ['refresh_token'], TRUE) && $this->statusCode === 400 && \in_array($this->oauthError, ['invalid_grant'], TRUE) ); } }