File "FailedToSendActionLink.php"
Full path: /home/orbitecv/orbite-school.orbit.et/vendor/kreait/firebase-php/src/Firebase/Auth/SendActionLink/FailedToSendActionLink.php
File size: 1.18 KiB (1206 bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Edit Back
<?php
declare(strict_types=1);
namespace Kreait\Firebase\Auth\SendActionLink;
use Beste\Json;
use InvalidArgumentException;
use Kreait\Firebase\Auth\SendActionLink;
use Kreait\Firebase\Exception\AuthException;
use Kreait\Firebase\Exception\RuntimeException;
use Psr\Http\Message\ResponseInterface;
final class FailedToSendActionLink extends RuntimeException implements AuthException
{
private ?SendActionLink $action = null;
private ?ResponseInterface $response = null;
public static function withActionAndResponse(SendActionLink $action, ResponseInterface $response): self
{
$fallbackMessage = 'Failed to send action link';
try {
$message = Json::decode((string) $response->getBody(), true)['error']['message'] ?? $fallbackMessage;
} catch (InvalidArgumentException) {
$message = $fallbackMessage;
}
$error = new self($message);
$error->action = $action;
$error->response = $response;
return $error;
}
public function action(): ?SendActionLink
{
return $this->action;
}
public function response(): ?ResponseInterface
{
return $this->response;
}
}