diff --git a/src/Twig/Component/Badge.php b/src/Twig/Component/Badge.php index 840f06a..715d9f1 100644 --- a/src/Twig/Component/Badge.php +++ b/src/Twig/Component/Badge.php @@ -20,13 +20,13 @@ final class Badge /** * @param ?BadgeableInterface $obj The object to be converted into a badge. - * @param string $class Extra classes to add to the badge element. + * @param ?string $class Extra classes to add to the badge element. * These will override the base classes in case * of conflicts. * @param ?string $colour Specify the colour of an objectless badge. * @param bool $outline If the badge should be rendered as an outline. */ - public function mount(?BadgeableInterface $obj = null, string $class = '', string $colour = null, bool $outline = false): void + public function mount(?BadgeableInterface $obj = null, ?string $class = null, string $colour = null, bool $outline = false): void { if (!$obj && !$colour) { throw new \RuntimeException(sprintf("You must specify either a colour an instance of \"%s\".", BadgeableInterface::class)); @@ -60,7 +60,7 @@ final class Badge $classes = sprintf('text-white %s %s %s %s', $palette->borderColourClass, $palette->backgroundColourClass, $this->baseClasses, $class); } - $this->finalClasses = $merger->merge($classes); + $this->finalClasses = $merger->merge(trim($classes)); } }