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