@@ -39,10 +39,7 @@ public static function isReservedPrecededByDotCharacter($previous)
3939 */
4040 public static function getReservedTopLevelString ($ string , array &$ matches )
4141 {
42- return [
43- Tokenizer::TOKEN_TYPE => Tokenizer::TOKEN_TYPE_RESERVED_TOP_LEVEL ,
44- Tokenizer::TOKEN_VALUE => substr ($ string , 0 , strlen ($ matches [1 ]))
45- ];
42+ return self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED_TOP_LEVEL , $ string , $ matches );
4643 }
4744
4845
@@ -54,12 +51,7 @@ public static function getReservedTopLevelString($string, array &$matches)
5451 */
5552 public static function getReservedNewLineString ($ string , array &$ matches )
5653 {
57- $ string = strtoupper ($ string );
58-
59- return [
60- Tokenizer::TOKEN_TYPE => Tokenizer::TOKEN_TYPE_RESERVED_NEWLINE ,
61- Tokenizer::TOKEN_VALUE => substr ($ string , 0 , strlen ($ matches [1 ]))
62- ];
54+ return self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED_NEWLINE , strtoupper ($ string ), $ matches );
6355 }
6456
6557 /**
@@ -86,9 +78,21 @@ public static function isReservedString($upper, array &$matches, $regexReserved,
8678 * @return array
8779 */
8880 public static function getReservedString ($ string , array &$ matches )
81+ {
82+ return self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED , $ string , $ matches );
83+ }
84+
85+ /**
86+ * @param $type
87+ * @param $string
88+ * @param array $matches
89+ *
90+ * @return array
91+ */
92+ protected static function getStringTypeArray ($ type , $ string , array &$ matches )
8993 {
9094 return [
91- Tokenizer::TOKEN_TYPE => Tokenizer:: TOKEN_TYPE_RESERVED ,
95+ Tokenizer::TOKEN_TYPE => $ type ,
9296 Tokenizer::TOKEN_VALUE => substr ($ string , 0 , strlen ($ matches [1 ]))
9397 ];
9498 }
0 commit comments