4
4
5
5
namespace gapple \StructuredFields ;
6
6
7
- /**
8
- * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
9
- */
10
7
class Parser
11
8
{
12
9
public static function parseDictionary (string $ string ): Dictionary
@@ -290,7 +287,6 @@ private static function parseString(ParsingInput $input): string
290
287
291
288
/**
292
289
* @phpstan-impure
293
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
294
290
*/
295
291
private static function parseDisplayString (ParsingInput $ string ): DisplayString
296
292
{
@@ -301,7 +297,7 @@ private static function parseDisplayString(ParsingInput $string): DisplayString
301
297
throw new ParseException ('Invalid start of display string at position ' . $ startPosition );
302
298
}
303
299
304
- $ encoded_string = '' ;
300
+ $ encodedString = '' ;
305
301
while (!$ string ->empty ()) {
306
302
$ char = $ string ->consumeChar ();
307
303
@@ -311,22 +307,22 @@ private static function parseDisplayString(ParsingInput $string): DisplayString
311
307
);
312
308
} elseif ($ char === '% ' ) {
313
309
try {
314
- $ encoded_string .= '% ' . $ string ->consumeRegex ('/^[0-9a-f]{2}/ ' );
310
+ $ encodedString .= '% ' . $ string ->consumeRegex ('/^[0-9a-f]{2}/ ' );
315
311
} catch (\RuntimeException ) {
316
312
throw new ParseException (
317
313
'Invalid hex values in display string at position ' . ($ string ->position () - 1 )
318
314
);
319
315
}
320
316
} elseif ($ char === '" ' ) {
321
- $ display_string = new DisplayString (rawurldecode ($ encoded_string ));
317
+ $ displayString = new DisplayString (rawurldecode ($ encodedString ));
322
318
// An invalid UTF-8 subject will cause the preg_* function to match nothing.
323
319
// @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 )) {
325
321
throw new ParseException ('Invalid byte sequence in display string at position ' . $ startPosition );
326
322
}
327
- return $ display_string ;
323
+ return $ displayString ;
328
324
} else {
329
- $ encoded_string .= $ char ;
325
+ $ encodedString .= $ char ;
330
326
}
331
327
}
332
328
0 commit comments