VerifyAuthenticationException.php 752 B

1234567891011121314151617181920212223242526
  1. <?php
  2. declare(strict_types=1);
  3. namespace Shlinkio\Shlink\Rest\Exception;
  4. use Fig\Http\Message\StatusCodeInterface;
  5. use Mezzio\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
  6. use Mezzio\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
  7. class VerifyAuthenticationException extends RuntimeException implements ProblemDetailsExceptionInterface
  8. {
  9. use CommonProblemDetailsExceptionTrait;
  10. public static function forInvalidApiKey(): self
  11. {
  12. $e = new self('Provided API key does not exist or is invalid.');
  13. $e->detail = $e->getMessage();
  14. $e->title = 'Invalid API key';
  15. $e->type = 'INVALID_API_KEY';
  16. $e->status = StatusCodeInterface::STATUS_UNAUTHORIZED;
  17. return $e;
  18. }
  19. }