Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public static function normalize($value): string |
||
21 | { |
||
22 | /** @psalm-suppress DocblockTypeContradiction */ |
||
23 | if (!is_scalar($value)) { |
||
|
|||
24 | $type = gettype($value); |
||
25 | throw new InvalidArgumentException("Value must be scalar. $type given."); |
||
26 | } |
||
27 | |||
28 | if (is_bool($value)) { |
||
29 | $value = $value ? '1' : '0'; |
||
30 | } else { |
||
31 | $value = (string)$value; |
||
32 | } |
||
33 | $value = str_replace([' ', ','], ['', '.'], $value); |
||
34 | return preg_replace('/\.(?=.*\.)/', '', $value); |
||
35 | } |
||
37 |