@@ -385,32 +385,22 @@ private function parseNumericValue($bForColor = false) {
385385 }
386386 }
387387 $ fSize = floatval ($ sSize );
388+
388389 $ 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+ // These are non "size" values, but they are still numeric
394+ 'deg ' , 'grad ' , 'rad ' , 'turns ' , 's ' , 'ms ' , 'Hz ' , 'kHz '
395+ );
396+
397+ foreach ($ units as $ val ) {
398+ if ($ this ->comes ($ val )) {
399+ $ sUnit = $ this ->consume ($ val );
400+ break ;
401+ }
413402 }
403+
414404 return new Size ($ fSize , $ sUnit , $ bForColor );
415405 }
416406
0 commit comments