Conditions | 5 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | public function floatingPointValidator(string $value) |
||
10 | { |
||
11 | if (is_float($value + 0)) { |
||
|
|||
12 | // if less than zero and doesn't start with a zero |
||
13 | if ($value + 0 < 1 && ! str_starts_with($value, '0')) { |
||
14 | throw new BadRequestException('Region values less than one require a leading zero.'); |
||
15 | } |
||
16 | // option should not have an extra trailing zero |
||
17 | if (str_ends_with($value, '0')) { |
||
18 | throw new BadRequestException('Region values should not contain a trailing zero.'); |
||
19 | } |
||
20 | } |
||
21 | |||
22 | return true; |
||
23 | } |
||
25 |