diff --git a/app/View/Enums/Variant.php b/app/View/Enums/Variant.php index 121d284f..91ae3b66 100644 --- a/app/View/Enums/Variant.php +++ b/app/View/Enums/Variant.php @@ -2,6 +2,9 @@ namespace App\View\Enums; +use Illuminate\Support\Collection; +use InvalidArgumentException; + enum Variant: string { @@ -63,6 +66,12 @@ enum Variant: string public static function fromString(string $input): self { return collect(static::cases()) - ->first(fn ($variant) => $variant->value === $input); + ->first(fn ($variant) => $variant->value === $input) + ?: throw new InvalidArgumentException("Unknown variant: {$input} - Available Variants: " . self::values()->implode(', ')); + } + + public static function values(): Collection + { + return collect(static::cases())->map(fn ($variant) => $variant->value); } }