35 lines
778 B
PHP
35 lines
778 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Exception;
|
|
|
|
class OAuthProtocolException extends Exception
|
|
{
|
|
public function __construct(
|
|
public string $oauthError,
|
|
public string $oauthDescription = '',
|
|
public int $httpStatus = 400,
|
|
public ?string $oauthErrorUri = null
|
|
) {
|
|
parent::__construct($oauthDescription);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function toResponsePayload(): array
|
|
{
|
|
$payload = [
|
|
'error' => $this->oauthError,
|
|
'error_description' => $this->oauthDescription,
|
|
];
|
|
|
|
if ($this->oauthErrorUri !== null && $this->oauthErrorUri !== '') {
|
|
$payload['error_uri'] = $this->oauthErrorUri;
|
|
}
|
|
|
|
return $payload;
|
|
}
|
|
}
|