Conditions | 4 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 8 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
42 | private function is_good_float(int|string|float|null $number): bool |
||
43 | { |
||
44 | if (is_float($number)) { |
||
45 | $separate = str($number)->explode('.')->sep; |
||
46 | |||
47 | $precision_position = str($separate->get(1, ''))->length(); |
||
48 | |||
49 | $round_number = round($number, $precision_position); |
||
50 | |||
51 | $sum_digits = $separate->sum(function ($item) { |
||
52 | return str($item)->length(); |
||
53 | }); |
||
54 | |||
55 | if (($round_number == $number && $sum_digits <= PHP_FLOAT_DIG - 1)) { |
||
56 | return true; |
||
57 | } |
||
58 | } |
||
59 | |||
60 | return false; |
||
61 | } |
||
63 |