1 | <?php |
||
18 | class UnitFormatter extends NumberFormatter |
||
19 | { |
||
20 | /** |
||
21 | * @var string|null |
||
22 | */ |
||
23 | protected $unit_column; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $default_params = [ |
||
29 | 'decimals' => 2, |
||
30 | 'locale' => null, |
||
31 | 'pattern' => null, |
||
32 | 'unit' => null, |
||
33 | 'disableUseOfNonBreakingSpaces' => false, |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @throws Exception\ExtensionNotLoadedException if ext/intl is not present |
||
38 | */ |
||
39 | 7 | public function __construct(array $params = []) |
|
43 | |||
44 | /** |
||
45 | * Currency format a number. |
||
46 | * |
||
47 | * @throws Exception\RuntimeException |
||
48 | * |
||
49 | * @param float|string|int $number |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | 3 | public function format($number, ArrayObject $row = null): string |
|
85 | |||
86 | /** |
||
87 | * @throws Exception\InvalidArgumentException |
||
88 | * |
||
89 | * @param string|RowColumn $unit |
||
90 | * |
||
91 | * @return UnitFormatter |
||
92 | */ |
||
93 | 4 | public function setUnit($unit) |
|
104 | |||
105 | /** |
||
106 | * @return string |
||
107 | */ |
||
108 | 1 | public function getUnit() |
|
112 | } |
||
113 |