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