44
55namespace gapple \StructuredFields ;
66
7- /**
8- * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
9- */
107class Parser
118{
129 public static function parseDictionary (string $ string ): Dictionary
@@ -290,7 +287,6 @@ private static function parseString(ParsingInput $input): string
290287
291288 /**
292289 * @phpstan-impure
293- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
294290 */
295291 private static function parseDisplayString (ParsingInput $ string ): DisplayString
296292 {
@@ -301,7 +297,7 @@ private static function parseDisplayString(ParsingInput $string): DisplayString
301297 throw new ParseException ('Invalid start of display string at position ' . $ startPosition );
302298 }
303299
304- $ encoded_string = '' ;
300+ $ encodedString = '' ;
305301 while (!$ string ->empty ()) {
306302 $ char = $ string ->consumeChar ();
307303
@@ -311,22 +307,22 @@ private static function parseDisplayString(ParsingInput $string): DisplayString
311307 );
312308 } elseif ($ char === '% ' ) {
313309 try {
314- $ encoded_string .= '% ' . $ string ->consumeRegex ('/^[0-9a-f]{2}/ ' );
310+ $ encodedString .= '% ' . $ string ->consumeRegex ('/^[0-9a-f]{2}/ ' );
315311 } catch (\RuntimeException ) {
316312 throw new ParseException (
317313 'Invalid hex values in display string at position ' . ($ string ->position () - 1 )
318314 );
319315 }
320316 } elseif ($ char === '" ' ) {
321- $ display_string = new DisplayString (rawurldecode ($ encoded_string ));
317+ $ displayString = new DisplayString (rawurldecode ($ encodedString ));
322318 // An invalid UTF-8 subject will cause the preg_* function to match nothing.
323319 // @see https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
324- if (!preg_match ('/^\X*$/u ' , (string ) $ display_string )) {
320+ if (!preg_match ('/^\X*$/u ' , (string ) $ displayString )) {
325321 throw new ParseException ('Invalid byte sequence in display string at position ' . $ startPosition );
326322 }
327- return $ display_string ;
323+ return $ displayString ;
328324 } else {
329- $ encoded_string .= $ char ;
325+ $ encodedString .= $ char ;
330326 }
331327 }
332328
0 commit comments