Conditions | 10 |
Paths | 10 |
Total Lines | 32 |
Code Lines | 21 |
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 |
||
61 | private function makeFieldConfig(array $keys): array |
||
62 | { |
||
63 | $config = []; |
||
64 | foreach ($keys as $key) { |
||
65 | switch ($key) { |
||
66 | case 'template()': |
||
67 | if ($this->template !== null) { |
||
68 | $config[$key] = [$this->template]; |
||
69 | } |
||
70 | break; |
||
71 | |||
72 | case 'setInputIdAttribute()': |
||
73 | if ($this->setInputIdAttribute !== null) { |
||
74 | $config[$key] = [$this->setInputIdAttribute]; |
||
75 | } |
||
76 | break; |
||
77 | |||
78 | case 'labelConfig()': |
||
79 | $labelConfig = $this->makeLabelConfig(); |
||
80 | if ($labelConfig !== []) { |
||
81 | $config[$key] = [$labelConfig]; |
||
82 | } |
||
83 | break; |
||
84 | |||
85 | case 'hintConfig()': |
||
86 | if ($this->hintConfig !== []) { |
||
87 | $config[$key] = [$this->hintConfig]; |
||
88 | } |
||
89 | break; |
||
90 | } |
||
91 | } |
||
92 | return $config; |
||
93 | } |
||
106 |