33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+
67namespace Magento \Framework \Filter ;
78
89use Exception ;
@@ -17,9 +18,9 @@ class LocalizedToNormalized implements FilterInterface
1718 * @var array
1819 */
1920 protected $ _options = [
20- 'locale ' => null ,
21- 'date_format ' => null ,
22- 'precision ' => null ,
21+ 'locale ' => null ,
22+ 'date_format ' => null ,
23+ 'precision ' => null ,
2324 'decimal_style ' => null ,
2425 ];
2526
@@ -67,14 +68,10 @@ public function setOptions(?array $options = null)
6768 public function filter ($ value )
6869 {
6970 if (is_numeric ($ 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- }
71+ $ numberParse = new NumberParse (
72+ $ this ->_options ['locale ' ],
73+ empty ($ this ->_options ['decimal_style ' ]) ? NumberFormatter::PATTERN_DECIMAL : $ this ->_options ['decimal_style ' ]
74+ );
7875 return (string )$ numberParse ->filter ($ value );
7976 } elseif ($ this ->_options ['date_format ' ] === null && strpos ($ value , ': ' ) !== false ) {
8077 $ formatter = new IntlDateFormatter (
@@ -152,7 +149,7 @@ private function parseDate($date)
152149 $ parse [$ month ] = 'M ' ;
153150 }
154151 if ($ year !== false ) {
155- $ parse [$ year ] = 'y ' ;
152+ $ parse [$ year ] = 'y ' ;
156153 }
157154 preg_match_all ('/\d+/u ' , $ date , $ splitted );
158155 $ split = false ;
@@ -192,7 +189,7 @@ private function parseDate($date)
192189 }
193190 if ($ split === false ) {
194191 if (count ($ splitted [0 ]) > $ cnt ) {
195- $ result ['year ' ] = $ splitted [0 ][$ cnt ];
192+ $ result ['year ' ] = $ splitted [0 ][$ cnt ];
196193 }
197194 } else {
198195 $ result ['year ' ] = iconv_substr ($ splitted [0 ][0 ], $ split , $ length );
0 commit comments