Conditions | 3 |
Paths | 3 |
Total Lines | 51 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
83 | protected function configureFormFields(FormMapper $formMapper) |
||
84 | { |
||
85 | $container = $this->getConfigurationPool()->getContainer(); |
||
86 | |||
87 | $optionsRoles = [ |
||
88 | 'multiple' => true, |
||
89 | 'label' => 'Permissions', |
||
90 | ]; |
||
91 | |||
92 | if (\AppKernel::VERSION_ID >= 20700) { |
||
93 | $optionsRoles['choices'] = array_flip($container->getParameter('alpixel_user.role_descriptions')); |
||
94 | |||
95 | if (\AppKernel::VERSION_ID < 30000) { |
||
96 | $optionsRoles['choices_as_values'] = true; |
||
97 | } |
||
98 | } else { |
||
99 | $optionsRoles['choices'] = $container->getParameter('alpixel_user.role_descriptions'); |
||
100 | } |
||
101 | |||
102 | $formMapper |
||
103 | ->with('Informations personnelles', [ |
||
104 | 'description' => '', |
||
105 | 'class' => 'col-md-8', |
||
106 | ]) |
||
107 | ->add('username', null, [ |
||
108 | 'label' => 'Nom d\'utilisateur', |
||
109 | ]) |
||
110 | ->add('email', null, [ |
||
111 | 'label' => 'Email', |
||
112 | ]) |
||
113 | ->add('firstname', null, [ |
||
114 | 'label' => 'Prénom', |
||
115 | ]) |
||
116 | ->add('lastname', null, [ |
||
117 | 'label' => 'Nom', |
||
118 | ]) |
||
119 | ->end() |
||
120 | ->with('Paramétrage', [ |
||
121 | 'description' => '', |
||
122 | 'class' => 'col-md-4', |
||
123 | ]) |
||
124 | ->add('enabled', null, [ |
||
125 | 'label' => 'Compte actif', |
||
126 | ]) |
||
127 | ->add('roles', 'choice', $optionsRoles) |
||
128 | ->add('plainPassword', 'text', [ |
||
129 | 'label' => 'Changer le mot de passe', |
||
130 | 'required' => false, |
||
131 | ]) |
||
132 | ->end(); |
||
133 | } |
||
134 | |||
153 |