33namespace VerifierServer \Endpoints ;
44
55/**
6- * Trait HeaderParserTrait
6+ * Trait ResponseParserTrait
77 *
8- * Provides functionality to parse HTTP request headers from a raw HTTP request string.
8+ * Provides functionality to parse data from a raw HTTP request string.
99 *
1010 * @package VerifierServer\Endpoints
1111 */
12- trait HeaderParserTrait
12+ trait ResponseParserTrait
1313{
1414 /**
1515 * Parses the headers from a raw HTTP request string.
@@ -23,7 +23,7 @@ trait HeaderParserTrait
2323 * @return array An associative array of headers, where the keys are
2424 * header names and the values are header values.
2525 */
26- static function parseHeaders (string $ request ): array
26+ public static function parseHeaders (string $ request ): array
2727 {
2828 return array_reduce (
2929 explode (PHP_EOL , $ request ), fn ($ carry , $ line ) =>
@@ -32,4 +32,19 @@ static function parseHeaders(string $request): array
3232 : $ carry ,
3333 []);
3434 }
35+
36+ /**
37+ * Parses the query parameters from a given request URL string.
38+ *
39+ * This method extracts the query string from the provided URL,
40+ * parses it into an associative array, and returns the result.
41+ *
42+ * @param string $request The full URL string containing the query parameters.
43+ * @return array An associative array of query parameters.
44+ */
45+ public static function parseQueryParams (string $ request ): array
46+ {
47+ parse_str (parse_url ($ request , PHP_URL_QUERY ), $ params );
48+ return $ params ;
49+ }
3550}
0 commit comments