Total Complexity | 3 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | final class NumberUtil |
||
6 | { |
||
7 | /** |
||
8 | * @param mixed $number |
||
9 | * |
||
10 | * @return float |
||
11 | */ |
||
12 | public function convertToDouble($number) |
||
13 | { |
||
14 | $number = str_replace(',', '.', (string) $number); |
||
15 | |||
16 | if (!is_numeric($number)) { |
||
17 | throw new \UnexpectedValueException("{$number} não é um número válido"); |
||
18 | } |
||
19 | |||
20 | return (float) number_format($number, 2, '.', ''); |
||
|
|||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @param string $string |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | public function getOnlyNumbers($string) |
||
31 | } |
||
32 | } |
||
33 |