Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 33 |
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 declare(strict_types=1); |
||
30 | public function _editable($value, Field $field, HTMLNode $previous): HTMLNode |
||
|
|||
31 | { |
||
32 | $renderable = $field->getRenderables(); |
||
33 | $validators = $field->getValidators(); |
||
34 | |||
35 | $input = $previous->get('input')[0]; |
||
36 | $input->addAttribute('class', 'file-input'); |
||
37 | |||
38 | $content = HTMLNode::factory( |
||
39 | 'div', |
||
40 | ['class' => "file has-name"], |
||
41 | [ |
||
42 | HTMLNode::factory( |
||
43 | 'label', |
||
44 | ['class' => "file-label"], |
||
45 | [ |
||
46 | $input, |
||
47 | HTMLNode::factory( |
||
48 | 'span', |
||
49 | ['class' => "file-cta"], |
||
50 | [ |
||
51 | HTMLNode::factory( |
||
52 | 'span', |
||
53 | ['class' => "file-icon"], |
||
54 | HTMLNode::factory( |
||
55 | 'i', |
||
56 | [ 'class' => "fas fa-upload" ] |
||
57 | ) |
||
58 | ), |
||
59 | HTMLNode::factory( |
||
60 | 'span', |
||
61 | ['class' => "file-label"], |
||
62 | $renderable[Renderable::COMMENT] ?? 'Pick file or drag-drop' |
||
63 | ), |
||
64 | ] |
||
65 | ), |
||
66 | HTMLNode::factory( |
||
67 | 'span', |
||
68 | ['class' => "formularium-file-name file-name"], |
||
69 | '' // TODO |
||
70 | ) |
||
71 | ] |
||
72 | ), |
||
73 | HTMLNode::factory( |
||
74 | 'label', |
||
75 | ['class' => "formularium-label"], |
||
76 | $renderable[Renderable::LABEL] ?? '' |
||
77 | ) |
||
78 | ] |
||
79 | ); |
||
80 | |||
81 | return $content; |
||
82 | } |
||
84 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.