diff --git a/src/Twig/Component/Badge.php b/src/Twig/Component/Badge.php index 3baf22a..6fa0ea5 100644 --- a/src/Twig/Component/Badge.php +++ b/src/Twig/Component/Badge.php @@ -28,8 +28,10 @@ final class Badge { if (null !== $colour) { - if (!in_array($colour, EnumBadge::cases())) { - throw new \RuntimeException(sprintf('"%s" is not a valid Badge colour. Available options are: %s', $colour, implode(", ", EnumBadge::cases()))); + $cases = array_map(fn(EnumBadge $b) => $b->name, EnumBadge::cases()); + + if (!in_array($colour, $cases)) { + throw new \RuntimeException(sprintf('"%s" is not a valid Badge colour. Available options are: %s', $colour, implode(", ", $cases))); } } else {