From face976cd0f5c07ba72ad8c4fde2324e9fcd39e9 Mon Sep 17 00:00:00 2001 From: Bradley Date: Thu, 8 Aug 2024 15:37:07 +0100 Subject: [PATCH] Fix type error --- src/Twig/Component/Badge.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 {