| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 17 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
| 18 | { |
||
| 19 | // see: https://symfonycasts.com/screencast/symfony-forms/form-type-class |
||
| 20 | $builder |
||
| 21 | ->add( |
||
| 22 | 'content_SELECT', ChoiceType::class, [ |
||
| 23 | 'choices' => ['SELECT' => 'SELECT'], |
||
| 24 | 'attr' => [ |
||
| 25 | 'style' => 'width: 180px;' |
||
| 26 | ], |
||
| 27 | 'disabled' => true, |
||
| 28 | 'label' => false, |
||
| 29 | 'trim' => true |
||
| 30 | ] |
||
| 31 | ) |
||
| 32 | ->add( |
||
| 33 | 'content_WHAT', null, [ |
||
| 34 | 'required' => true, |
||
| 35 | 'data' => '*', |
||
| 36 | 'attr' => [ |
||
| 37 | 'style' => 'width: 180px;' |
||
| 38 | ], |
||
| 39 | 'disabled' => false, |
||
| 40 | 'label' => false, |
||
| 41 | 'trim' => true |
||
| 42 | ] |
||
| 43 | ) |
||
| 44 | ->add( |
||
| 45 | 'content_FROM', ChoiceType::class, [ |
||
| 46 | 'choices' => ['FROM' => 'FROM'], |
||
| 47 | 'attr' => [ |
||
| 48 | 'style' => 'width: 180px;' |
||
| 49 | ], |
||
| 50 | 'disabled' => true, |
||
| 51 | 'label' => false, |
||
| 52 | 'trim' => true |
||
| 53 | ] |
||
| 54 | ) |
||
| 55 | ->add( |
||
| 56 | 'content_TABLE', ChoiceType::class, [ |
||
| 57 | 'choices' => ['caches' => 'caches', 'user' => 'user'], |
||
| 58 | 'attr' => [ |
||
| 59 | 'style' => 'width: 180px;' |
||
| 60 | ], |
||
| 61 | 'disabled' => false, |
||
| 62 | 'label' => false, |
||
| 63 | 'trim' => true |
||
| 64 | ] |
||
| 65 | ) |
||
| 66 | ->add( |
||
| 67 | 'Suchen', SubmitType::class, [ |
||
| 68 | 'attr' => ['class' => 'btn btn-primary'], |
||
| 69 | 'label' => '🔍' |
||
| 70 | ] |
||
| 71 | ); |
||
| 72 | } |
||
| 73 | } |
||
| 74 |