Autoformat
This commit is contained in:
@@ -15,5 +15,7 @@ final readonly class BadgePalette
|
||||
* @param string $backgroundColourClass Background colour Tailwind class
|
||||
*/
|
||||
public function __construct(public string $textColourClass, public string $borderColourClass, public string $backgroundColourClass)
|
||||
{}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use Pcm\BadgeBundle\Interface\BadgeableInterface;
|
||||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
|
||||
use TailwindMerge\TailwindMerge;
|
||||
|
||||
#[AsTwigComponent(name: 'Pcm:Badge', template: "@PcmBadge/Badge.html.twig")]
|
||||
#[AsTwigComponent(name: 'Pcm:Badge', template: '@PcmBadge/Badge.html.twig')]
|
||||
final class Badge
|
||||
{
|
||||
public string $finalClasses;
|
||||
@@ -19,21 +19,21 @@ final class Badge
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?BadgeableInterface $obj The object to be converted into a badge.
|
||||
* @param ?BadgeableInterface $obj the object to be converted into a badge
|
||||
* @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.
|
||||
* @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 = null, 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));
|
||||
throw new \RuntimeException(sprintf('You must specify either a colour an instance of "%s".', BadgeableInterface::class));
|
||||
}
|
||||
|
||||
if ($obj && $colour) {
|
||||
throw new \RuntimeException(sprintf("You have specified both the colour \"%s\" and an instance of \"%s\". Please use one or the other.", $colour, $obj::class));
|
||||
throw new \RuntimeException(sprintf('You have specified both the colour "%s" and an instance of "%s". Please use one or the other.', $colour, $obj::class));
|
||||
}
|
||||
|
||||
if ($obj) {
|
||||
@@ -41,14 +41,14 @@ final class Badge
|
||||
}
|
||||
|
||||
if ($colour) {
|
||||
$cases = array_map(fn(EnumBadge $b) => strtolower($b->name), EnumBadge::cases());
|
||||
$cases = array_map(fn (EnumBadge $b) => strtolower($b->name), EnumBadge::cases());
|
||||
|
||||
if (!in_array($colour, $cases)) {
|
||||
$formattedCases = implode(", ", array_map(fn(string $s) => '"'.$s.'"', $cases));
|
||||
$formattedCases = implode(', ', array_map(fn (string $s) => '"'.$s.'"', $cases));
|
||||
throw new \RuntimeException(sprintf('"%s" is not a valid Badge colour. Available options are: %s', $colour, $formattedCases));
|
||||
}
|
||||
|
||||
$colour = strtoupper($colour);
|
||||
$colour = strtoupper($colour);
|
||||
$palette = EnumBadge::{$colour}->getPalette();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user