| Conditions | 13 |
| Paths | 8 |
| Total Lines | 40 |
| Code Lines | 22 |
| 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 |
||
| 25 | public function validate(mixed $value, Constraint $constraint): void |
||
| 26 | { |
||
| 27 | if (!$constraint instanceof VatNumber) { |
||
| 28 | throw new UnexpectedTypeException($constraint, VatNumber::class); |
||
| 29 | } |
||
| 30 | |||
| 31 | if (!$value instanceof VatNumberAddressInterface) { |
||
| 32 | throw new UnexpectedValueException($value, VatNumberAddressInterface::class); |
||
| 33 | } |
||
| 34 | |||
| 35 | if ($this->hasVatNumberForCompany($value, $constraint) === false || |
||
| 36 | $this->hasVatNumberForCountry($value, $constraint) === false || |
||
| 37 | $this->validatorConfig->validateFormat === false || |
||
| 38 | !$value->getVatNumber() || |
||
| 39 | !$value->getCountryCode() |
||
| 40 | ) { |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | $vatNumberValidator = $this->validatorProvider->getValidator($value->getCountryCode()); |
||
| 45 | if (null === $vatNumberValidator) { |
||
| 46 | return; |
||
| 47 | } |
||
| 48 | |||
| 49 | if ($vatNumberValidator->validateFormat($value->getVatNumber()) === false) { |
||
| 50 | $this->addViolation($constraint->messageInvalidFormat, $constraint->vatNumberPath); |
||
| 51 | |||
| 52 | return; |
||
| 53 | } |
||
| 54 | |||
| 55 | if ($this->validatorConfig->validateCountry && |
||
| 56 | $vatNumberValidator->validateCountry($value->getVatNumber(), $value->getCountryCode()) === false |
||
| 57 | ) { |
||
| 58 | $this->addViolation($constraint->messageInvalidCountry, $constraint->vatNumberPath); |
||
| 59 | |||
| 60 | return; |
||
| 61 | } |
||
| 62 | |||
| 63 | if ($this->validatorConfig->validateRegistration) { |
||
| 64 | $this->validateRegistration($value, $vatNumberValidator, $constraint); |
||
| 65 | } |
||
| 124 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths