@@ -186,7 +186,7 @@ public static function fromString($strValue, $scale = null)
186
186
if (preg_match ('/^([+\-]?)0*(([1-9][0-9]*|[0-9])(\.[0-9]+)?)$/ ' , $ strValue , $ captures ) === 1 ) {
187
187
188
188
// Now it's time to strip leading zeros in order to normalize inner values
189
- $ sign = $ captures [1 ];
189
+ $ sign = self :: normalizeSign ( $ captures [1 ]) ;
190
190
$ value = $ sign . $ captures [2 ];
191
191
192
192
$ dec_scale = $ scale !== null ?
@@ -196,15 +196,14 @@ public static function fromString($strValue, $scale = null)
196
196
} elseif (preg_match ('/([+\-]?)([0-9](\.[0-9]+)?)[eE]([+\-]?)([1-9][0-9]*)/ ' , $ strValue , $ captures ) === 1 ) {
197
197
198
198
// Now it's time to "unroll" the exponential notation to basic positional notation
199
- $ sign = $ captures [1 ];
199
+ $ sign = self :: normalizeSign ( $ captures [1 ]) ;
200
200
$ mantissa = $ captures [2 ];
201
201
202
202
$ mantissa_scale = strlen ($ captures [3 ]) > 0 ? strlen ($ captures [3 ])-1 : 0 ;
203
203
204
- $ exp_sign = ($ captures [4 ]==='' ) ? '+ ' : $ captures [4 ];
205
204
$ exp_val = (int )$ captures [5 ];
206
205
207
- if ($ exp_sign === '+ ' ) {
206
+ if (self :: normalizeSign ( $ captures [ 4 ]) === '' ) {
208
207
$ min_scale = ($ mantissa_scale -$ exp_val > 0 ) ? $ mantissa_scale -$ exp_val : 0 ;
209
208
$ tmp_multiplier = bcpow (10 , $ exp_val );
210
209
} else {
@@ -804,6 +803,15 @@ private static function paramsValidation($value, $scale)
804
803
}
805
804
}
806
805
806
+ private static function normalizeSign ($ sign )
807
+ {
808
+ if ($ sign ==='+ ' ) {
809
+ return '' ;
810
+ }
811
+
812
+ return $ sign ;
813
+ }
814
+
807
815
/**
808
816
* @return string
809
817
*/
0 commit comments