| Conditions | 10 |
| Paths | 37 |
| Total Lines | 32 |
| Code Lines | 17 |
| 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 setAutocomplete(array $fields): array |
||
| 40 | { |
||
| 41 | foreach ($fields as $key => $data) { |
||
| 42 | if (in_array('config', $fields[$key])) { |
||
| 43 | if ($fields[$key]['config']) { |
||
| 44 | $autocomplete = $this->config->getAutocompleteForField($key); |
||
| 45 | if ($autocomplete) { |
||
| 46 | $fields[$key]['config']['autocomplete'] = $autocomplete; |
||
| 47 | if ($fields[$key]['config']['elementTmpl'] === 'ui/form/element/input') { |
||
| 48 | $fields[$key]['config']['elementTmpl'] = 'O2TI_AdvancedFieldsCheckout/form/element/input'; |
||
| 49 | } |
||
| 50 | if ($fields[$key]['config']['elementTmpl'] === 'ui/form/element/select') { |
||
| 51 | $fields[$key]['config']['elementTmpl'] = 'O2TI_AdvancedFieldsCheckout/form/element/select'; |
||
| 52 | } |
||
| 53 | if ($fields[$key]['config']['elementTmpl'] === 'ui/form/element/password') { |
||
| 54 | // phpcs:ignore |
||
| 55 | $fields[$key]['config']['elementTmpl'] = 'O2TI_AdvancedFieldsCheckout/form/element/password'; |
||
| 56 | } |
||
| 57 | // phpcs:ignore |
||
| 58 | if ($fields[$key]['config']['elementTmpl'] === 'O2TI_CheckoutIdentificationStep/form/element/password') { |
||
| 59 | // phpcs:ignore |
||
| 60 | $fields[$key]['config']['elementTmpl'] = 'O2TI_AdvancedFieldsCheckout/form/element/O2TI/password'; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | if ($key === 'street') { |
||
| 64 | $fields = $this->setAutocompleteOfStreetLine($fields, $key); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | return $fields; |
||
| 71 | } |
||
| 104 |