Conditions | 4 |
Paths | 4 |
Total Lines | 161 |
Code Lines | 127 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
271 | public function configureFields(string $pageName): iterable |
||
272 | { |
||
273 | //Documents |
||
274 | $documentsPanel = FormField::addPanel('payment_order.group.documents'); |
||
275 | $printed_form = VichyFileField::new('printed_form_file', 'payment_order.printed_form.label'); |
||
276 | $references = VichyFileField::new('references_file', 'payment_order.references.label'); |
||
277 | |||
278 | //Basic informations |
||
279 | $infoPanel = FormField::addPanel('payment_order.group.info'); |
||
280 | $id = IntegerField::new('id', 'payment_order.id.label'); |
||
281 | $firstName = TextField::new('first_name', 'payment_order.first_name.label'); |
||
282 | $lastName = TextField::new('last_name', 'payment_order.last_name.label'); |
||
283 | $contact_email = EmailField::new('contact_email', 'payment_order.contact_email.label') |
||
284 | ->setFormTypeOption('empty_data', '') |
||
285 | ->setRequired(false); |
||
286 | $department = AssociationField::new('department', 'payment_order.department.label') |
||
287 | ->setFormTypeOption('attr', [ |
||
288 | 'data-widget' => 'select2', |
||
289 | ]); |
||
290 | $departmentName = TextareaField::new('department.name', 'payment_order.department.label_short'); |
||
291 | $amount = MoneyField::new('amount', 'payment_order.amount.label') |
||
292 | ->setCurrency('EUR') |
||
293 | ->setStoredAsCents(true); |
||
294 | $projectName = TextField::new('project_name', 'payment_order.project_name.label'); |
||
295 | $funding_id = TextField::new('funding_id', 'payment_order.funding_id.label') |
||
296 | ->setRequired(false) |
||
297 | ->setFormTypeOption('empty_data', ''); |
||
298 | //Use short name for index |
||
299 | $funding_id_index = TextField::new('funding_id', 'payment_order.funding_id.label_short') |
||
300 | ->setHelp('payment_order.funding_id.label'); |
||
301 | $fsr_kom = BooleanField::new('fsr_kom_resolution', 'payment_order.fsr_kom.label') |
||
302 | ->setRequired(false); |
||
303 | $resolution_date = DateField::new('resolution_date', 'payment_order.resolution_date.label') |
||
304 | ->setRequired(false); |
||
305 | $comment = TextEditorField::new('comment', 'payment_order.comment.label') |
||
306 | ->setRequired(false) |
||
307 | ->setFormTypeOption('empty_data', ''); |
||
308 | $lastModified = DateTimeField::new('last_modified', 'last_modified'); |
||
309 | $creationDate = DateTimeField::new('creation_date', 'creation_date'); |
||
310 | |||
311 | //Status informations |
||
312 | $statusPanel = FormField::addPanel('payment_order.group.status'); |
||
313 | $mathematicallyCorrect = BooleanField::new('mathematically_correct', 'payment_order.mathematically_correct.label') |
||
314 | ->setHelp('payment_order.mathematically_correct.help') |
||
315 | //Disable fields (and show coloumns as read only tags) if user does not have proper permissions to change |
||
316 | //factually and mathematically correct status |
||
317 | ->setFormTypeOption('disabled', !$this->isGranted('ROLE_PO_MATHEMATICALLY')) |
||
318 | ->renderAsSwitch($this->isGranted('ROLE_PO_MATHEMATICALLY')); |
||
319 | $exported = BooleanField::new('exported', 'payment_order.exported.label') |
||
320 | ->setHelp('payment_order.exported.help'); |
||
321 | $factuallyCorrect = BooleanField::new('factually_correct', 'payment_order.factually_correct.label') |
||
322 | ->setHelp('payment_order.factually_correct.help') |
||
323 | ->setFormTypeOption('disabled', !$this->isGranted('ROLE_PO_FACTUALLY')) |
||
324 | ->renderAsSwitch($this->isGranted('ROLE_PO_FACTUALLY')); |
||
325 | $confirmed_1 = DateTimeField::new('confirm1_timestamp', 'payment_order.confirmed_1.label'); |
||
326 | $confirmed_2 = DateTimeField::new('confirm2_timestamp', 'payment_order.confirmed_2.label'); |
||
327 | |||
328 | //Payee informations |
||
329 | $payeePanel = FormField::addPanel('payment_order.group.receiver'); |
||
330 | $bankInfoAccountOwner = TextField::new('bank_info.account_owner', 'bank_info.account_owner.label'); |
||
331 | $bankInfoStreet = TextField::new('bank_info.street', 'bank_info.street.label'); |
||
332 | $bankInfoZipCode = TextField::new('bank_info.zip_code', 'bank_info.zip_code.label'); |
||
333 | $bankInfoCity = TextField::new('bank_info.city', 'bank_info.city.label'); |
||
334 | |||
335 | //Payee bank account infos |
||
336 | $bankInfoPanel = FormField::addPanel('payment_order.group.bank_info'); |
||
337 | $bankInfoIban = TextField::new('bank_info.iban', 'bank_info.iban.label'); |
||
338 | $bankInfoBic = TextField::new('bank_info.bic', 'bank_info.bic.label') |
||
339 | ->setRequired(false) |
||
340 | ->setFormTypeOption('empty_data', ''); |
||
341 | $bankInfoBankName = TextField::new('bank_info.bank_name', 'bank_info.bank_name.label'); |
||
342 | $bankInfoReference = TextField::new('bank_info.reference', 'bank_info.reference.label') |
||
343 | ->setRequired(false) |
||
344 | ->setFormTypeOption('empty_data', ''); |
||
345 | |||
346 | if (Crud::PAGE_INDEX === $pageName) { |
||
347 | return [$id, $projectName, $departmentName, $amount, $mathematicallyCorrect, $factuallyCorrect, $funding_id_index, $creationDate]; |
||
348 | } |
||
349 | |||
350 | if (Crud::PAGE_DETAIL === $pageName) { |
||
351 | return [ |
||
352 | //Documents section |
||
353 | $documentsPanel, |
||
354 | $printed_form, |
||
355 | $references, |
||
356 | //Basic informations |
||
357 | $infoPanel, |
||
358 | $id, |
||
359 | $firstName, |
||
360 | $lastName, |
||
361 | $contact_email, |
||
362 | $projectName, |
||
363 | $department, |
||
364 | $amount, |
||
365 | $funding_id, |
||
366 | $resolution_date, |
||
367 | $fsr_kom, |
||
368 | $comment, |
||
369 | $lastModified, |
||
370 | $creationDate, |
||
371 | //Status infos |
||
372 | $statusPanel, |
||
373 | $mathematicallyCorrect, |
||
374 | $exported, |
||
375 | $factuallyCorrect, |
||
376 | $confirmed_1, |
||
377 | $confirmed_2, |
||
378 | //Payee informations |
||
379 | $payeePanel, |
||
380 | $bankInfoAccountOwner, |
||
381 | $bankInfoStreet, |
||
382 | $bankInfoZipCode, |
||
383 | $bankInfoCity, |
||
384 | //Banking informations |
||
385 | $bankInfoPanel, |
||
386 | $bankInfoIban, |
||
387 | $bankInfoBic, |
||
388 | $bankInfoBankName, |
||
389 | $bankInfoReference, |
||
390 | ]; |
||
391 | } |
||
392 | |||
393 | if (Crud::PAGE_EDIT === $pageName) { |
||
394 | return [ |
||
395 | //Documents section |
||
396 | $documentsPanel, |
||
397 | $printed_form, |
||
398 | $references, |
||
399 | //Basic informations |
||
400 | $infoPanel, |
||
401 | $firstName, |
||
402 | $lastName, |
||
403 | $contact_email, |
||
404 | $projectName, |
||
405 | $department, |
||
406 | $amount, |
||
407 | $funding_id, |
||
408 | $resolution_date, |
||
409 | $fsr_kom, |
||
410 | $comment, |
||
411 | //Status infos |
||
412 | $statusPanel, |
||
413 | $mathematicallyCorrect, |
||
414 | $exported, |
||
415 | $factuallyCorrect, |
||
416 | //Payee informations |
||
417 | $payeePanel, |
||
418 | $bankInfoAccountOwner, |
||
419 | $bankInfoStreet, |
||
420 | $bankInfoZipCode, |
||
421 | $bankInfoCity, |
||
422 | //Banking informations |
||
423 | $bankInfoPanel, |
||
424 | $bankInfoIban, |
||
425 | $bankInfoBic, |
||
426 | $bankInfoBankName, |
||
427 | $bankInfoReference, |
||
428 | ]; |
||
429 | } |
||
430 | |||
431 | throw new RuntimeException('It should not be possible to reach this point...'); |
||
432 | } |
||
449 |