Further refactoring
This commit is contained in:
@@ -45,7 +45,8 @@ final class IconRuntime implements RuntimeExtensionInterface
|
||||
$options = $this->mergeWithDefaultOptions($userOptions);
|
||||
|
||||
$svg = $this->getSvg($options['icon']);
|
||||
$svg = $this->sanitiseSvg($svg);
|
||||
|
||||
$this->sanitiseSvg($svg);
|
||||
|
||||
$colourClasses = $this->getColourClasses($options['colour'], $options['hover']);
|
||||
$extraClasses = $this->getExtraClasses($options['classes']);
|
||||
@@ -93,13 +94,12 @@ final class IconRuntime implements RuntimeExtensionInterface
|
||||
return file_get_contents($iconFilepath);
|
||||
}
|
||||
|
||||
private function sanitiseSvg(string &$svg): string
|
||||
private function sanitiseSvg(string &$svg): void
|
||||
{
|
||||
$this->removeExistingTitleElement($svg);
|
||||
$this->removeBlackStrokeAttributes($svg);
|
||||
$this->removeStrokeCurrentColor($svg);
|
||||
|
||||
return $this->removeBlackFillAttributes($svg);
|
||||
$this->removeBlackFillAttributes($svg);
|
||||
}
|
||||
|
||||
private function findSvgFilepath(string $iconName): string
|
||||
@@ -130,9 +130,9 @@ final class IconRuntime implements RuntimeExtensionInterface
|
||||
$svg = \preg_replace('/stroke=(\'|")currentColor(\'|")/', '', $svg);
|
||||
}
|
||||
|
||||
private function removeBlackFillAttributes(string $content): string
|
||||
private function removeBlackFillAttributes(string &$svg): void
|
||||
{
|
||||
return preg_replace('/fill(=|:)"?\s*(#0{6}|#000|rgb\(\s*0,\s*0,\s*0\s*\)|black)\s*"?/', '', $content);
|
||||
$svg = preg_replace('/fill(=|:)"?\s*(#0{6}|#000|rgb\(\s*0,\s*0,\s*0\s*\)|black)\s*"?/', '', $svg);
|
||||
}
|
||||
|
||||
private function getColourClasses(string $primaryColour, ?string $hoverColour): string
|
||||
|
||||
Reference in New Issue
Block a user