Change empty string to null

This commit is contained in:
2024-08-08 17:01:18 +01:00
parent e6b027c166
commit c09ee1c53d

View File

@@ -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));
}
}