| Conditions | 10 |
| Paths | 52 |
| Total Lines | 34 |
| Code Lines | 19 |
| 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 |
||
| 39 | public function changeComponentFields(array $fields): array |
||
| 40 | { |
||
| 41 | foreach ($fields as $key => $data) { |
||
| 42 | if ($key === 'postcode') { |
||
| 43 | $defaultPosition = (int) $fields[$key]['sortOrder']; |
||
| 44 | $fields[$key]['sortOrder'] = $defaultPosition; |
||
| 45 | $fields[$key]['component'] = 'O2TI_AutoCompleteAddressBr/js/view/form/element/postcode'; |
||
| 46 | if ($this->config->useInputMasking()) { |
||
| 47 | // phpcs:ignore |
||
| 48 | $fields[$key]['component'] = 'O2TI_AutoCompleteAddressBr/js/view/form/element/O2TI/InputMasking/postcode'; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | if ($this->config->isHideTargetFields()) { |
||
| 52 | if ($key === 'street') { |
||
| 53 | foreach ($fields[$key]['children'] as $arrayPosition => $streetLine) { |
||
| 54 | // phpcs:ignore |
||
| 55 | $fields[$key]['children'][$arrayPosition]['component'] = 'O2TI_AutoCompleteAddressBr/js/view/form/element/street-inline'; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | if ($key === 'city') { |
||
| 59 | $fields[$key]['component'] = 'O2TI_AutoCompleteAddressBr/js/view/form/element/city'; |
||
| 60 | } |
||
| 61 | if ($key === 'region_id') { |
||
| 62 | $fields[$key]['component'] = 'O2TI_AutoCompleteAddressBr/js/view/form/element/region'; |
||
| 63 | } |
||
| 64 | if ($key === 'country_id') { |
||
| 65 | $fields[$key]['component'] = 'O2TI_AutoCompleteAddressBr/js/view/form/element/country'; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | continue; |
||
| 70 | } |
||
| 71 | |||
| 72 | return $fields; |
||
| 73 | } |
||
| 75 |