Skip to content

Commit 7251a87

Browse files
committed
Parse query parameters
1 parent 48771b6 commit 7251a87

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/VerifierServer/Endpoints/HeaderParserTrait.php renamed to src/VerifierServer/Endpoints/ResponseParserTrait.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace 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,10 @@ static function parseHeaders(string $request): array
3232
: $carry,
3333
[]);
3434
}
35+
36+
public static function parseQueryParams(string $request): array
37+
{
38+
parse_str(parse_url($request, PHP_URL_QUERY), $params);
39+
return $params;
40+
}
3541
}

src/VerifierServer/Endpoints/VerifiedEndpoint.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
*/
4747
class VerifiedEndpoint implements EndpointInterface
4848
{
49-
use HeaderParserTrait;
49+
use ResponseParserTrait;
50+
5051
public function __construct(private PersistentState &$state)
5152
{}
5253

0 commit comments

Comments
 (0)