@@ -223,23 +223,33 @@ private function parseRule() {
223
223
private function parseValue () {
224
224
$ aResult = array ();
225
225
do {
226
- $ this ->consumeWhiteSpace ();
227
- if (is_numeric ($ this ->peek ()) || $ this ->comes ('- ' ) || $ this ->comes ('. ' )) {
228
- $ aResult [] = $ this ->parseNumericValue ();
229
- } else if ($ this ->comes ('# ' ) || $ this ->comes ('rgb ' ) || $ this ->comes ('hsl ' )) {
230
- $ aResult [] = $ this ->parseColorValue ();
231
- } else if ($ this ->comes ('url ' )){
232
- $ aResult [] = $ this ->parseURLValue ();
233
- } else if ($ this ->comes ("' " ) || $ this ->comes ('" ' )){
234
- $ aResult [] = $ this ->parseStringValue ();
235
- } else {
236
- $ aResult [] = $ this ->parseIdentifier ();
237
- }
238
- $ this ->consumeWhiteSpace ();
226
+ $ aResult [] = $ this ->parseSingleValue ();
239
227
} while ($ this ->comes (', ' ) && is_string ($ this ->consume (', ' )));
240
228
241
229
return $ aResult ;
242
230
}
231
+
232
+ private function parseSingleValue () {
233
+ $ oValue = null ;
234
+ $ this ->consumeWhiteSpace ();
235
+ if (is_numeric ($ this ->peek ()) || (($ this ->comes ('- ' ) || $ this ->comes ('. ' )) && is_numeric ($ this ->peek (1 , 1 )))) {
236
+ $ oValue = $ this ->parseNumericValue ();
237
+ } else if ($ this ->comes ('# ' ) || $ this ->comes ('rgb ' ) || $ this ->comes ('hsl ' )) {
238
+ $ oValue = $ this ->parseColorValue ();
239
+ } else if ($ this ->comes ('url ' )){
240
+ $ oValue = $ this ->parseURLValue ();
241
+ } else if ($ this ->comes ("' " ) || $ this ->comes ('" ' )){
242
+ $ oValue = $ this ->parseStringValue ();
243
+ } else {
244
+ $ oValue = $ this ->parseIdentifier ();
245
+ }
246
+ $ this ->consumeWhiteSpace ();
247
+ if ($ this ->comes ('/ ' )) {
248
+ $ this ->consume ('/ ' );
249
+ $ oValue = new CSSSlashedValue ($ oValue , $ this ->parseSingleValue ());
250
+ }
251
+ return $ oValue ;
252
+ }
243
253
244
254
private function parseNumericValue () {
245
255
$ sSize = '' ;
@@ -990,3 +1000,33 @@ public function __toString() {
990
1000
return "url( {$ this ->oURL ->__toString ()}) " ;
991
1001
}
992
1002
}
1003
+
1004
+ class CSSSlashedValue extends CSSValue {
1005
+ private $ oValue1 ;
1006
+ private $ oValue2 ;
1007
+
1008
+ public function __construct ($ oValue1 , $ oValue2 ) {
1009
+ $ this ->oValue1 = $ oValue1 ;
1010
+ $ this ->oValue2 = $ oValue2 ;
1011
+ }
1012
+
1013
+ public function getValue1 () {
1014
+ return $ this ->oValue1 ;
1015
+ }
1016
+
1017
+ public function getValue2 () {
1018
+ return $ this ->oValue2 ;
1019
+ }
1020
+
1021
+ public function __toString () {
1022
+ $ oValue1 = $ this ->oValue1 ;
1023
+ $ oValue2 = $ this ->oValue2 ;
1024
+ if ($ oValue1 instanceof CSSValue) {
1025
+ $ oValue1 = $ oValue1 ->__toString ();
1026
+ }
1027
+ if ($ oValue2 instanceof CSSValue) {
1028
+ $ oValue2 = $ oValue2 ->__toString ();
1029
+ }
1030
+ return "$ oValue1/ $ oValue2 " ;
1031
+ }
1032
+ }
0 commit comments