Conditions | 2 |
Paths | 2 |
Total Lines | 80 |
Code Lines | 67 |
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 |
||
113 | public function configureFields(string $pageName): iterable |
||
114 | { |
||
115 | $choices = []; |
||
116 | foreach (Department::ALLOWED_TYPES as $type) { |
||
117 | $choices['department.type.'.$type] = $type; |
||
118 | } |
||
119 | |||
120 | return [ |
||
121 | //Basic informations |
||
122 | TextField::new('name', 'department.name.label'), |
||
123 | ChoiceField::new('type', 'department.type.label') |
||
124 | ->setChoices($choices) |
||
125 | ->autocomplete(), |
||
126 | BooleanField::new('blocked', 'department.blocked.label') |
||
127 | ->renderAsSwitch(true) |
||
128 | ->setHelp('department.blocked.help'), |
||
129 | TextEditorField::new('comment', 'department.comment.label') |
||
130 | ->setRequired(false) |
||
131 | ->setFormTypeOption('empty_data', '') |
||
132 | ->hideOnIndex(), |
||
133 | IntegerField::new('id', 'department.id.label') |
||
134 | ->onlyOnDetail(), |
||
135 | DateTimeField::new('last_modified', 'last_modified') |
||
136 | ->onlyOnDetail(), |
||
137 | DateTimeField::new('creation_date', 'creation_date') |
||
138 | ->onlyOnDetail(), |
||
139 | |||
140 | AssociationField::new('bank_account', 'department.bank_account.label') |
||
141 | ->setHelp('department.bank_account.help') |
||
142 | ->setRequired(false) |
||
143 | ->hideOnDetail(), |
||
144 | |||
145 | CollectionField::new('contact_emails', 'department.contact_emails.label') |
||
146 | ->setHelp('department.contact_emails.help') |
||
147 | ->setTemplatePath('admin/field/email_collection.html.twig') |
||
148 | ->allowAdd() |
||
149 | ->allowDelete() |
||
150 | ->setFormTypeOption('delete_empty', true) |
||
151 | ->setFormTypeOption('entry_options.required', false) |
||
152 | ->setTemplatePath('admin/field/email_collection.html.twig') |
||
153 | ->setEntryType(EmailType::class), |
||
154 | |||
155 | TextField::new('references_export_prefix', 'department.references_export_prefix.label') |
||
156 | ->setHelp('department.references_export_prefix.help') |
||
157 | ->hideOnIndex(), |
||
158 | |||
159 | //FSR contact info panel |
||
160 | FormField::addPanel('department.fsr_email_panel.label') |
||
161 | ->setHelp('department.fsr_email_panel.help'), |
||
162 | CollectionField::new('email_hhv', 'department.email_hhv.label') |
||
163 | ->setHelp('department.email_hhv.help') |
||
164 | ->setTemplatePath('admin/field/email_collection.html.twig') |
||
165 | ->allowAdd() |
||
166 | ->allowDelete() |
||
167 | ->setFormTypeOption('delete_empty', true) |
||
168 | ->setFormTypeOption('entry_options.required', false) |
||
169 | ->setFormTypeOption('entry_options.empty_data', '') |
||
170 | ->setEntryType(EmailType::class) |
||
171 | ->hideOnIndex(), |
||
172 | |||
173 | CollectionField::new('email_treasurer', 'department.email_treasurer.label') |
||
174 | ->setHelp('department.email_hhv.help') |
||
175 | ->setTemplatePath('admin/field/email_collection.html.twig') |
||
176 | ->allowAdd() |
||
177 | ->allowDelete() |
||
178 | ->setFormTypeOption('delete_empty', true) |
||
179 | ->setFormTypeOption('entry_options.required', false) |
||
180 | ->setFormTypeOption('entry_options.empty_data', '') |
||
181 | ->setEntryType(EmailType::class) |
||
182 | ->hideOnIndex(), |
||
183 | |||
184 | FormField::addPanel('department.skip_blocked_validation_tokens.panel.label') |
||
185 | ->setHelp('department.skip_blocked_validation_tokens.panel.help'), |
||
186 | |||
187 | CollectionField::new('skip_blocked_validation_tokens', 'department.skip_blocked_validation_tokens.label') |
||
188 | ->allowDelete() |
||
189 | ->allowAdd(false) |
||
190 | ->setFormTypeOption('delete_empty', false) |
||
191 | ->setTemplatePath('admin/field/validation_token_collection.html.twig') |
||
192 | ->hideOnIndex(), |
||
193 | ]; |
||
196 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.