| Conditions | 4 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 39 |
| 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 namespace Anomaly\Streams\Platform\Assignment\Form; |
||
| 18 | public function handle(AssignmentFormBuilder $builder) |
||
| 19 | { |
||
| 20 | $builder->setFields( |
||
| 21 | [ |
||
| 22 | 'label' => [ |
||
| 23 | 'label' => 'streams::assignment.label.name', |
||
| 24 | 'instructions' => 'streams::assignment.label.instructions', |
||
| 25 | 'type' => 'anomaly.field_type.text', |
||
| 26 | ], |
||
| 27 | 'placeholder' => [ |
||
| 28 | 'label' => 'streams::assignment.placeholder.name', |
||
| 29 | 'instructions' => 'streams::assignment.placeholder.instructions', |
||
| 30 | 'type' => 'anomaly.field_type.text', |
||
| 31 | ], |
||
| 32 | 'instructions' => [ |
||
| 33 | 'label' => 'streams::assignment.instructions.name', |
||
| 34 | 'instructions' => 'streams::assignment.instructions.instructions', |
||
| 35 | 'type' => 'anomaly.field_type.textarea', |
||
| 36 | ], |
||
| 37 | 'warning' => [ |
||
| 38 | 'label' => 'streams::assignment.warning.name', |
||
| 39 | 'instructions' => 'streams::assignment.warning.instructions', |
||
| 40 | 'type' => 'anomaly.field_type.text', |
||
| 41 | ], |
||
| 42 | 'required' => [ |
||
| 43 | 'label' => 'streams::assignment.required.label', |
||
| 44 | 'instructions' => 'streams::assignment.required.instructions', |
||
| 45 | 'type' => 'anomaly.field_type.boolean', |
||
| 46 | ], |
||
| 47 | 'unique' => [ |
||
| 48 | 'label' => 'streams::assignment.unique.label', |
||
| 49 | 'instructions' => 'streams::assignment.unique.instructions', |
||
| 50 | 'type' => 'anomaly.field_type.boolean', |
||
| 51 | ], |
||
| 52 | 'translatable' => [ |
||
| 53 | 'label' => 'streams::assignment.translatable.label', |
||
| 54 | 'instructions' => 'streams::assignment.translatable.instructions', |
||
| 55 | 'type' => 'anomaly.field_type.boolean', |
||
| 56 | 'warning' => function (AssignmentFormBuilder $builder) { |
||
| 57 | |||
| 58 | $type = $builder->getFieldType(); |
||
| 59 | |||
| 60 | return (!$type->getColumnType()) ? 'streams::assignment.translatable.warning' : null; |
||
| 61 | }, |
||
| 62 | 'disabled' => function (AssignmentFormBuilder $builder) { |
||
| 63 | |||
| 64 | $stream = $builder->getStream(); |
||
| 65 | |||
| 66 | if ($stream && !$stream->isTranslatable()) { |
||
| 67 | return true; |
||
| 68 | } |
||
| 69 | |||
| 70 | $type = $builder->getFieldType(); |
||
| 71 | |||
| 72 | return (!$type->getColumnType()); |
||
| 73 | }, |
||
| 74 | ], |
||
| 75 | ] |
||
| 76 | ); |
||
| 77 | } |
||
| 78 | } |
||
| 79 |