TagNotFoundException.php 885 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. namespace Shlinkio\Shlink\Core\Exception;
  4. use Fig\Http\Message\StatusCodeInterface;
  5. use Mezzio\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
  6. use Mezzio\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
  7. use function sprintf;
  8. class TagNotFoundException extends DomainException implements ProblemDetailsExceptionInterface
  9. {
  10. use CommonProblemDetailsExceptionTrait;
  11. private const TITLE = 'Tag not found';
  12. private const TYPE = 'TAG_NOT_FOUND';
  13. public static function fromTag(string $tag): self
  14. {
  15. $e = new self(sprintf('Tag with name "%s" could not be found', $tag));
  16. $e->detail = $e->getMessage();
  17. $e->title = self::TITLE;
  18. $e->type = self::TYPE;
  19. $e->status = StatusCodeInterface::STATUS_NOT_FOUND;
  20. $e->additional = ['tag' => $tag];
  21. return $e;
  22. }
  23. }