Conditions | 3 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
45 | 59 | protected function isPrecise(float $number): bool |
|
46 | { |
||
47 | 59 | $numberAsString = str($number); |
|
48 | |||
49 | 59 | $afterFloatingPoint = $numberAsString |
|
50 | 59 | ->explode('.') |
|
51 | 59 | ->get(1, ''); |
|
52 | |||
53 | 59 | $precisionPosition = str($afterFloatingPoint)->length(); |
|
54 | |||
55 | 59 | $roundedNumber = round($number, $precisionPosition); |
|
56 | |||
57 | 59 | if ($roundedNumber === $number && $numberAsString->length() <= PHP_FLOAT_DIG) { |
|
58 | 46 | return true; |
|
59 | } |
||
60 | |||
61 | 13 | return false; |
|
62 | } |
||
64 |