@@ -70,7 +70,7 @@ public function matches(string $accepts): array
7070 */
7171 private function parse (string $ header ): \Generator
7272 {
73- foreach (explode (', ' , $ header ) as $ header ) {
73+ foreach (\ explode (', ' , $ header ) as $ header ) {
7474 yield new class ($ header ) extends AcceptHeader {};
7575 }
7676 }
@@ -92,22 +92,22 @@ public function __construct(string $header)
9292 {
9393 $ this ->header = $ header ;
9494
95- $ header = preg_replace ('/[[:space:]]/ ' , '' , $ header );
96- $ bits = explode ('; ' , $ header );
97- $ type = array_shift ($ bits );
98- if (!empty ($ type ) && !preg_match ('~^(\*|[a-z0-9._]+)([/|_\-])?(\*|[a-z0-9.\-_+]+)?$~i ' , $ type , $ matches )) {
99- throw new \InvalidArgumentException (sprintf ('"%s" is not a valid Access header ' , $ header ),
95+ $ header = \ preg_replace ('/[[:space:]]/ ' , '' , $ header );
96+ $ bits = \ explode ('; ' , $ header );
97+ $ type = \ array_shift ($ bits );
98+ if (!empty ($ type ) && !\ preg_match ('~^(\*|[a-z0-9._]+)([/|_\-])?(\*|[a-z0-9.\-_+]+)?$~i ' , $ type , $ matches )) {
99+ throw new \InvalidArgumentException (\ sprintf ('"%s" is not a valid Access header ' , $ header ),
100100 HttpStatus::NOT_ACCEPTABLE );
101101 }
102102 $ this ->separator = $ matches [2 ] ?? '/ ' ;
103- [$ type , $ subtype ] = explode ($ this ->separator , $ type , 2 ) + [1 => '* ' ];
103+ [$ type , $ subtype ] = \ explode ($ this ->separator , $ type , 2 ) + [1 => '* ' ];
104104 if ('* ' === $ type && '* ' !== $ subtype ) {
105105 // @see https://tools.ietf.org/html/rfc7231#section-5.3.2
106- throw new \InvalidArgumentException (sprintf ('"%s" is not a valid Access header ' , $ header ),
106+ throw new \InvalidArgumentException (\ sprintf ('"%s" is not a valid Access header ' , $ header ),
107107 HttpStatus::NOT_ACCEPTABLE );
108108 }
109109 // @see https://tools.ietf.org/html/rfc7540#section-8.1.2
110- $ this ->type = trim (strtolower ($ type ));
110+ $ this ->type = \ trim (\ strtolower ($ type ));
111111 /*
112112 * Uses a simple heuristic to check if subtype is part of
113113 * some convoluted media type like "vnd.api-v1+json".
@@ -117,9 +117,9 @@ public function __construct(string $header)
117117 * type like "vnd.whatever". The web world is a big mess
118118 * but this module can handle the Dunning-Kruger effect.
119119 */
120- $ this ->subtype = trim (explode ('+ ' , $ subtype )[1 ] ?? $ subtype );
120+ $ this ->subtype = \ trim (\ explode ('+ ' , $ subtype )[1 ] ?? $ subtype );
121121 $ this ->catchAll = ('* ' === $ this ->type ) && ('* ' === $ this ->subtype );
122- parse_str (join ('& ' , $ bits ), $ this ->params );
122+ \ parse_str (\ join ('& ' , $ bits ), $ this ->params );
123123 $ this ->quality = (float )($ this ->params ['q ' ] ?? 1 );
124124 unset($ this ->params ['q ' ]);
125125 }
0 commit comments