| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | * @template P as array{error?: string, error_description?: string, error_uri?: string, response?: string}&array<string, mixed> |
||
| 19 | * @psalm-return P |
||
| 20 | */ |
||
| 21 | function parse_callback_params(ServerRequestInterface $serverRequest): array |
||
| 22 | { |
||
| 23 | 4 | $method = strtoupper($serverRequest->getMethod()); |
|
| 24 | |||
| 25 | 4 | if (! in_array($method, ['GET', 'POST'], true)) { |
|
| 26 | 1 | throw new RuntimeException('Invalid callback method'); |
|
| 27 | } |
||
| 28 | |||
| 29 | 3 | if ('POST' === $method) { |
|
| 30 | 1 | parse_str((string) $serverRequest->getBody(), $params); |
|
| 31 | 2 | } elseif ('' !== $serverRequest->getUri()->getFragment()) { |
|
| 32 | 1 | parse_str($serverRequest->getUri()->getFragment(), $params); |
|
| 33 | } else { |
||
| 34 | 1 | parse_str($serverRequest->getUri()->getQuery(), $params); |
|
| 35 | } |
||
| 36 | |||
| 40 |