| Conditions | 6 |
| Paths | 4 |
| Total Lines | 35 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 6.0702 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function mustBeFloat($value, string $propertyPath = null, UIValidatorInterface $parentValidator = null, string $exceptionMessage = null): float |
||
| 24 | { |
||
| 25 | 1 | if (is_numeric($value)) { |
|
| 26 | 1 | $value = (float) $value; |
|
| 27 | } |
||
| 28 | |||
| 29 | 1 | $this->validationEngine->validateFieldValue( |
|
| 30 | 1 | $parentValidator ?: $this, |
|
| 31 | 1 | function() use ($value, $propertyPath, $exceptionMessage) { |
|
| 32 | 1 | if (is_float($value)) { |
|
| 33 | 1 | return; |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | if (null === $exceptionMessage) { |
|
| 37 | $exceptionMessage = sprintf( |
||
|
|
|||
| 38 | 'Value "%s" is not a float.', |
||
| 39 | $value |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | |||
| 43 | 1 | throw new InvalidArgumentException( |
|
| 44 | $exceptionMessage, |
||
| 45 | 1 | 0, |
|
| 46 | $propertyPath, |
||
| 47 | $value |
||
| 48 | ); |
||
| 49 | 1 | } |
|
| 50 | ); |
||
| 51 | |||
| 52 | 1 | if (!is_float($value)) { |
|
| 53 | 1 | return -1; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | return $value; |
|
| 57 | } |
||
| 58 | } |
||
| 59 |
It seems like you are assigning to a variable which was imported through a
usestatement which was not imported by reference.For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.
Change not visible in outer-scope
Change visible in outer-scope