Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
AbstractDigitsToWords | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
floatToWords | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Wikispeech\Segment\TextFilter; |
4 | |
5 | /** |
6 | * @file |
7 | * @ingroup Extensions |
8 | * @license GPL-2.0-or-later |
9 | */ |
10 | |
11 | /** |
12 | * @since 0.1.10 |
13 | */ |
14 | abstract class AbstractDigitsToWords implements DigitsToWords { |
15 | |
16 | /** |
17 | * Translate floating point to text value, e.g. 3.1415 -> 'three point one four one five'. |
18 | * There are limitations to this method due to PHP transforming 3.00 to 3. |
19 | * |
20 | * @see DigitsToWords::stringFloatToWords() To avoid limitations of PHP. |
21 | * @since 0.1.10 |
22 | * @param float $input |
23 | * @return string|null Null if input number is not supported |
24 | */ |
25 | public function floatToWords( float $input ): ?string { |
26 | $integerAndDecimals = explode( '.', strval( $input ) ); |
27 | return $this->stringFloatToWords( |
28 | intval( $integerAndDecimals[0] ), |
29 | count( $integerAndDecimals ) === 2 ? $integerAndDecimals[1] : null |
30 | ); |
31 | } |
32 | |
33 | } |