@@ -385,32 +385,20 @@ private function parseNumericValue($bForColor = false) {
385
385
}
386
386
}
387
387
$ fSize = floatval ($ sSize );
388
+
388
389
$ sUnit = null ;
389
- if ($ this ->comes ('% ' )) {
390
- $ sUnit = $ this ->consume ('% ' );
391
- } else if ($ this ->comes ('em ' )) {
392
- $ sUnit = $ this ->consume ('em ' );
393
- } else if ($ this ->comes ('ex ' )) {
394
- $ sUnit = $ this ->consume ('ex ' );
395
- } else if ($ this ->comes ('px ' )) {
396
- $ sUnit = $ this ->consume ('px ' );
397
- } else if ($ this ->comes ('deg ' )) {
398
- $ sUnit = $ this ->consume ('deg ' );
399
- } else if ($ this ->comes ('s ' )) {
400
- $ sUnit = $ this ->consume ('s ' );
401
- } else if ($ this ->comes ('cm ' )) {
402
- $ sUnit = $ this ->consume ('cm ' );
403
- } else if ($ this ->comes ('pt ' )) {
404
- $ sUnit = $ this ->consume ('pt ' );
405
- } else if ($ this ->comes ('in ' )) {
406
- $ sUnit = $ this ->consume ('in ' );
407
- } else if ($ this ->comes ('pc ' )) {
408
- $ sUnit = $ this ->consume ('pc ' );
409
- } else if ($ this ->comes ('cm ' )) {
410
- $ sUnit = $ this ->consume ('cm ' );
411
- } else if ($ this ->comes ('mm ' )) {
412
- $ sUnit = $ this ->consume ('mm ' );
390
+ $ units = array (
391
+ '% ' , 'em ' , 'ex ' , 'px ' , 'deg ' , 's ' , 'cm ' , 'pt ' , 'in ' , 'pc ' , 'cm ' ,
392
+ 'mm '
393
+ );
394
+
395
+ foreach ($ units as $ val ) {
396
+ if ($ this ->comes ($ val )) {
397
+ $ sUnit = $ this ->consume ($ val );
398
+ break ;
399
+ }
413
400
}
401
+
414
402
return new Size ($ fSize , $ sUnit , $ bForColor );
415
403
}
416
404
0 commit comments