Conditions | 10 |
Paths | 16 |
Total Lines | 29 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 10 |
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 |
||
12 | 36 | public function decorate(&$value, FieldMetadata $field, Constraint $configuration, ?string $group = null): bool |
|
13 | { |
||
14 | 36 | if (!is_null($value) && !is_numeric($value)) { |
|
15 | 6 | throw new \InvalidArgumentException('Non-numeric value supplied'); |
|
16 | } |
||
17 | |||
18 | 30 | $trailer = 0; |
|
19 | 30 | if ($this->useTrailer()) { |
|
20 | 15 | $trailer = $field->type instanceof Float_ ? 0.00001 : 1; |
|
21 | } |
||
22 | |||
23 | /* |
||
24 | * @var \Symfony\Component\Validator\Constraints\LessThan|\Symfony\Component\Validator\Constraints\LessThanOrEqual |
||
25 | */ |
||
26 | 30 | if ($configuration->value && $value >= $configuration->value) { |
|
27 | 12 | $value -= $value - $configuration->value + $trailer; |
|
28 | 18 | } elseif ($configuration->propertyPath) { |
|
29 | 18 | $compare = Accessor::getPropertyValue($field->object, $configuration->propertyPath); |
|
30 | |||
31 | 18 | if (!is_numeric($compare)) { |
|
32 | 6 | throw new \InvalidArgumentException('Non-numeric value supplied'); |
|
33 | } |
||
34 | |||
35 | 12 | if ($value >= $compare) { |
|
36 | 12 | $value -= $value - $compare + $trailer; |
|
37 | } |
||
38 | } |
||
39 | |||
40 | 24 | return true; |
|
41 | } |
||
48 |
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