Conditions | 10 |
Paths | 10 |
Total Lines | 31 |
Code Lines | 20 |
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 |
||
67 | private function makeWidgetConfig(array $keys): array |
||
68 | { |
||
69 | $config = []; |
||
70 | foreach ($keys as $key) { |
||
71 | switch ($key) { |
||
72 | case 'template()': |
||
73 | if ($this->template !== null) { |
||
74 | $config[$key] = [$this->template]; |
||
75 | } |
||
76 | break; |
||
77 | |||
78 | case 'setInputIdAttribute()': |
||
79 | if ($this->setInputIdAttribute !== null) { |
||
80 | $config[$key] = [$this->setInputIdAttribute]; |
||
81 | } |
||
82 | break; |
||
83 | |||
84 | case 'labelTag()': |
||
85 | if ($this->labelTag !== null) { |
||
86 | $config[$key] = [$this->labelTag]; |
||
87 | } |
||
88 | break; |
||
89 | |||
90 | case 'setLabelForAttribute()': |
||
91 | if ($this->setLabelForAttribute !== null) { |
||
92 | $config[$key] = [$this->setLabelForAttribute]; |
||
93 | } |
||
94 | break; |
||
95 | } |
||
96 | } |
||
97 | return $config; |
||
98 | } |
||
109 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.