@@ -17,9 +17,10 @@ class LocalizedToNormalized implements FilterInterface
17
17
* @var array
18
18
*/
19
19
protected $ _options = [
20
- 'locale ' => null ,
21
- 'date_format ' => null ,
22
- 'precision ' => null
20
+ 'locale ' => null ,
21
+ 'date_format ' => null ,
22
+ 'precision ' => null ,
23
+ 'decimal_style ' => null ,
23
24
];
24
25
25
26
/**
@@ -60,14 +61,21 @@ public function setOptions(?array $options = null)
60
61
*
61
62
* Normalizes the given input
62
63
*
63
- * @param string $value Value to normalized
64
+ * @param string $value Value to normalized
64
65
* @return string|array The normalized value
65
66
*/
66
67
public function filter ($ value )
67
68
{
68
69
if (is_numeric ($ value )) {
69
- $ numberParse = new NumberParse ($ this ->_options ['locale ' ], NumberFormatter::PATTERN_DECIMAL );
70
- return (string ) $ numberParse ->filter ($ value );
70
+ $ decimalStyle = $ this ->_options ['decimal_style ' ] ?? null ;
71
+ if ($ decimalStyle === null ) {
72
+ $ numberParse = new NumberParse ($ this ->_options ['locale ' ], NumberFormatter::PATTERN_DECIMAL );
73
+ } elseif ($ decimalStyle === false ) {
74
+ $ numberParse = new NumberParse ($ this ->_options ['locale ' ], NumberFormatter::DECIMAL );
75
+ } else {
76
+ $ numberParse = new NumberParse ($ this ->_options ['locale ' ], $ decimalStyle );
77
+ }
78
+ return (string )$ numberParse ->filter ($ value );
71
79
} elseif ($ this ->_options ['date_format ' ] === null && strpos ($ value , ': ' ) !== false ) {
72
80
$ formatter = new IntlDateFormatter (
73
81
$ this ->_options ['locale ' ],
0 commit comments