Remove uses, rename method

This commit is contained in:
Brabli
2022-08-06 17:25:24 +01:00
parent a0522a6700
commit d833ae95de

View File

@@ -4,11 +4,8 @@ declare(strict_types=1);
namespace Pcm\IconBundle\Twig\Functions;
use Exception;
use InvalidArgumentException;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use TypeError;
final class IconExtension extends AbstractExtension
{
@@ -42,7 +39,7 @@ final class IconExtension extends AbstractExtension
$rawSvgMarkup = $this->getSvgMarkup($iconFilepath);
$cleanSvgMarkup = $this->cleanSvgMarkup($rawSvgMarkup);
if ($this->titleIsANonEmptyString($options['title'])) {
if ($this->isNonEmptyString($options['title'])) {
$markup = $this->addTitleToMarkup($cleanSvgMarkup, $options['title']);
}
@@ -76,14 +73,14 @@ final class IconExtension extends AbstractExtension
return preg_replace('/<title>.*<\/title>/', '', $markup);
}
private function titleIsANonEmptyString(mixed $title): bool
private function isNonEmptyString(mixed $title): bool
{
if (!is_string($title) && null !== $title)
throw new TypeError('Title must be a string!');
throw new \TypeError('Title must be a string!');
if ('' === $title)
throw new InvalidArgumentException('Title string must not be empty!');
throw new \InvalidArgumentException('Title string must not be empty!');
return true;
}
@@ -98,4 +95,4 @@ final class IconExtension extends AbstractExtension
}
}
class IconNotFound extends Exception {};
class IconNotFound extends \Exception {};