| Total Complexity | 5 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 10 | class IntFormatter implements Formatter |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param int|float|string|null $value The value to format. |
||
| 14 | * @param string|null $decimal_separator The decimal separator to use for formatting. |
||
| 15 | */ |
||
| 16 | 5 | public function __construct( |
|
| 20 | 5 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * Get the valid decimal separator or null. |
||
| 24 | * |
||
| 25 | * @param string|null $decimal_separator The decimal separator to convert. |
||
| 26 | * @return string|null The valid decimal separator or null. |
||
| 27 | */ |
||
| 28 | 5 | private function getDecimalSeparator(?string $decimal_separator): ?string |
|
| 29 | { |
||
| 30 | switch ($decimal_separator) { |
||
| 31 | 5 | case '.': |
|
| 32 | 1 | return '.'; |
|
| 33 | 4 | case ',': |
|
| 34 | 1 | return ','; |
|
| 35 | default: |
||
| 36 | 3 | return null; |
|
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Format the value as an integer using the specified decimal separator. |
||
| 42 | * |
||
| 43 | * @return int The formatted integer value. |
||
| 44 | */ |
||
| 45 | 5 | public function format(): int |
|
| 48 | } |
||
| 49 | } |
||
| 50 |