value; } return collect(self::cases())->map(function ($enum) use ($attributes, $selectedValue) { $defaultAttrs = [ 'value' => $enum->value, ]; if ($selectedValue !== '@none@' && $enum->value === $selectedValue) { $defaultAttrs['selected'] = true; } $processedAttributes = self::processAttributes($attributes, $enum); return sprintf( '', self::buildAttributes($defaultAttrs, $processedAttributes), $enum->label() ); })->implode($separator); } private static function processAttributes(array $attributes, $enum): array { return Arr::map($attributes, static function ($value, $key) use ($enum) { return str_replace( ['%value%', '%label%'], [$enum->value, $enum->label()], $value ); }); } private static function buildAttributes(array $defaultAttrs, array $attributes): ComponentAttributeBag { return (new ComponentAttributeBag($defaultAttrs))->merge($attributes); } }