| Conditions | 12 |
| Paths | 10 |
| Total Lines | 38 |
| Code Lines | 24 |
| 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 |
||
| 92 | public function addTooltip(array $fields): array |
||
| 93 | { |
||
| 94 | foreach ($fields as $key => $data) { |
||
| 95 | if ($key === 'vat_id') { |
||
| 96 | if ($this->config->getConfigByVatId('enabled_cpf') && $this->config->getConfigByVatId('enabled_cnpj')) { |
||
| 97 | $fields[$key]['config']['tooltip'] = [ |
||
| 98 | 'description' => __('O CPF ou CNPJ é utilizado para envio e emissão de nota fiscal.'), |
||
| 99 | ]; |
||
| 100 | } elseif ($this->config->getConfigByVatId('enabled_cpf')) { |
||
| 101 | $fields[$key]['config']['tooltip'] = [ |
||
| 102 | 'description' => __('O CPF é utilizado para envio e emissão de nota fiscal.'), |
||
| 103 | ]; |
||
| 104 | } elseif ($this->config->getConfigByVatId('enabled_cnpj')) { |
||
| 105 | $fields[$key]['config']['tooltip'] = [ |
||
| 106 | 'description' => __('O CNPJ é utilizado para envio e emissão de nota fiscal.'), |
||
| 107 | ]; |
||
| 108 | } |
||
| 109 | } elseif ($key === 'taxvat') { |
||
| 110 | if ($this->config->getConfigByTaxvat('enabled_cpf') |
||
| 111 | && $this->config->getConfigByTaxvat('enabled_cnpj') |
||
| 112 | ) { |
||
| 113 | $fields[$key]['config']['tooltip'] = [ |
||
| 114 | 'description' => __('O CPF ou CNPJ é utilizado para envio e emissão de nota fiscal.'), |
||
| 115 | ]; |
||
| 116 | } elseif ($this->config->getConfigByTaxvat('enabled_cpf')) { |
||
| 117 | $fields[$key]['config']['tooltip'] = [ |
||
| 118 | 'description' => __('O CPF é utilizado para envio e emissão de nota fiscal.'), |
||
| 119 | ]; |
||
| 120 | } elseif ($this->config->getConfigByTaxvat('enabled_cnpj')) { |
||
| 121 | $fields[$key]['config']['tooltip'] = [ |
||
| 122 | 'description' => __('O CNPJ é utilizado para envio e emissão de nota fiscal.'), |
||
| 123 | ]; |
||
| 124 | } |
||
| 125 | } |
||
| 126 | continue; |
||
| 127 | } |
||
| 128 | |||
| 129 | return $fields; |
||
| 130 | } |
||
| 132 |