Skip to content

Commit 4b89a8a

Browse files
committed
Use match instead of switch
1 parent b15bb4c commit 4b89a8a

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

extra/html-extra/HtmlExtension.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,12 @@ public static function htmlCva(array|string $base = [], array $variants = [], ar
138138
/** @internal */
139139
public static function htmlAttrType(mixed $value, string $type = 'sst'): AttributeValueInterface
140140
{
141-
switch ($type) {
142-
case 'sst':
143-
return new SeparatedTokenList($value, ' ');
144-
case 'cst':
145-
return new SeparatedTokenList($value, ', ');
146-
case 'style':
147-
return new InlineStyle($value);
148-
default:
149-
throw new RuntimeError(\sprintf('Unknown attribute type "%s" The only supported types are "sst", "cst" and "style".', $type));
150-
}
141+
return match ($type) {
142+
'sst' => new SeparatedTokenList($value, ' '),
143+
'cst' => new SeparatedTokenList($value, ', '),
144+
'style' => new InlineStyle($value),
145+
default => throw new RuntimeError(\sprintf('Unknown attribute type "%s" The only supported types are "sst", "cst" and "style".', $type)),
146+
};
151147
}
152148

153149
/** @internal */

0 commit comments

Comments
 (0)