Lines
100.00%
10 / 10
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| UserType | 100.00% | 10 / 10 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| buildForm | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 1 | |||||
| configureOptions | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Form; | |
| 6 | ||
| 7 | use App\Entity\User; | |
| 8 | use App\Enum\UserRole; | |
| 9 | use Symfony\Component\Form\AbstractType; | |
| 10 | use Symfony\Component\Form\Extension\Core\Type\EnumType; | |
| 11 | use Symfony\Component\Form\FormBuilderInterface; | |
| 12 | use Symfony\Component\OptionsResolver\OptionsResolver; | |
| 13 | ||
| 14 | class UserType extends AbstractType | |
| 15 | { | |
| 16 | public function buildForm(FormBuilderInterface $builder, array $options): void | |
| 17 | { | |
| 18 | $builder | |
| 19 | ->add('identifier') | |
| 20 | ->add('role', EnumType::class, [ | |
| 21 | 'class' => UserRole::class, | |
| 22 | 'choice_label' => fn (UserRole $role) => $role->label(), | |
| 23 | ]) | |
| 24 | ; | |
| 25 | } | |
| 26 | ||
| 27 | public function configureOptions(OptionsResolver $resolver): void | |
| 28 | { | |
| 29 | $resolver->setDefaults([ | |
| 30 | 'data_class' => User::class, | |
| 31 | ]); | |
| 32 | } | |
| 33 | } |