| Conditions | 12 |
| Paths | 10 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 44 | public function aroundGetAttributeValidationClass(Address $subject, callable $proceed, string $args): string |
||
|
|
|||
| 45 | { |
||
| 46 | $result = $proceed($args); |
||
| 47 | if ($args == 'vat_id') { |
||
| 48 | if ($this->config->isEnabled()) { |
||
| 49 | $add = 'required-entry '; |
||
| 50 | if ($this->config->getConfigByVatId('enabled_cpf') && $this->config->getConfigByVatId('enabled_cnpj')) { |
||
| 51 | $add .= Config::VAT_CPF_OR_CNPJ; |
||
| 52 | } elseif ($this->config->getConfigByVatId('enabled_cpf')) { |
||
| 53 | $add .= Config::VAT_ONLY_CPF; |
||
| 54 | } elseif ($this->config->getConfigByVatId('enabled_cnpj')) { |
||
| 55 | $add .= Config::VAT_ONLY_CNPJ; |
||
| 56 | } |
||
| 57 | |||
| 58 | $result .= $add; |
||
| 59 | } |
||
| 60 | } elseif ($args == 'taxvat') { |
||
| 61 | if ($this->config->getConfigByTaxvat('enabled_cpf') && $this->config->getConfigByTaxvat('enabled_cnpj')) { |
||
| 62 | $add = Config::VAT_CPF_OR_CNPJ; |
||
| 63 | } elseif ($this->config->getConfigByTaxvat('enabled_cpf')) { |
||
| 64 | $add = Config::VAT_ONLY_CPF; |
||
| 65 | } elseif ($this->config->getConfigByTaxvat('enabled_cnpj')) { |
||
| 66 | $add = Config::VAT_ONLY_CNPJ; |
||
| 67 | } |
||
| 68 | |||
| 69 | $result .= $add; |
||
| 70 | } |
||
| 71 | |||
| 72 | return $result; |
||
| 75 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.