| Conditions | 12 |
| Paths | 12 |
| Total Lines | 38 |
| Code Lines | 25 |
| 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 |
||
| 70 | private function makeFieldConfig(array $keys): array |
||
| 71 | { |
||
| 72 | $config = []; |
||
| 73 | foreach ($keys as $key) { |
||
| 74 | switch ($key) { |
||
| 75 | case 'template()': |
||
| 76 | if ($this->template !== null) { |
||
| 77 | $config[$key] = [$this->template]; |
||
| 78 | } |
||
| 79 | break; |
||
| 80 | |||
| 81 | case 'setInputIdAttribute()': |
||
| 82 | if ($this->setInputIdAttribute !== null) { |
||
| 83 | $config[$key] = [$this->setInputIdAttribute]; |
||
| 84 | } |
||
| 85 | break; |
||
| 86 | |||
| 87 | case 'labelConfig()': |
||
| 88 | $labelConfig = $this->makeLabelConfig(); |
||
| 89 | if ($labelConfig !== []) { |
||
| 90 | $config[$key] = [$labelConfig]; |
||
| 91 | } |
||
| 92 | break; |
||
| 93 | |||
| 94 | case 'hintConfig()': |
||
| 95 | if ($this->hintConfig !== []) { |
||
| 96 | $config[$key] = [$this->hintConfig]; |
||
| 97 | } |
||
| 98 | break; |
||
| 99 | |||
| 100 | case 'errorConfig()': |
||
| 101 | if ($this->errorConfig !== []) { |
||
| 102 | $config[$key] = [$this->errorConfig]; |
||
| 103 | } |
||
| 104 | break; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | return $config; |
||
| 108 | } |
||
| 121 |