Lines 100.00% 9 / 9
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ProfileVisibilityType 100.00% 9 / 9 100.00% 1 / 1 1 100.00% 1 / 1
 buildForm 100.00% 9 / 9 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Form;
6
7use App\Enum\ProfilePart;
8use Symfony\Component\Form\AbstractType;
9use Symfony\Component\Form\Extension\Core\Type\EnumType;
10use Symfony\Component\Form\FormBuilderInterface;
11
12/**
13 * The profile parts other users see, on /profile. Data: ['visibleParts' => list<ProfilePart>].
14 */
15class ProfileVisibilityType extends AbstractType
16{
17    public function buildForm(FormBuilderInterface $builder, array $options): void
18    {
19        $builder->add('visibleParts', EnumType::class, [
20            'class' => ProfilePart::class,
21            'multiple' => true,
22            'expanded' => true,
23            'required' => false,
24            'label' => 'profile.visibility.label',
25            'choice_label' => static fn (ProfilePart $part): string => $part->label(),
26            'help' => 'profile.visibility.help',
27        ]);
28    }
29}