| Conditions | 5 |
| Paths | 5 |
| Total Lines | 25 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | function parse_callback_params(ServerRequestInterface $serverRequest): array |
||
| 16 | { |
||
| 17 | $method = \strtoupper($serverRequest->getMethod()); |
||
| 18 | |||
| 19 | if ('POST' === $method) { |
||
| 20 | $params = $serverRequest->getParsedBody(); |
||
| 21 | |||
| 22 | if (! \is_array($params)) { |
||
| 23 | throw new RuntimeException('Invalid parsed body'); |
||
| 24 | } |
||
| 25 | |||
| 26 | return $params; |
||
| 27 | } |
||
| 28 | |||
| 29 | if ('GET' !== $method) { |
||
| 30 | throw new RuntimeException('Invalid callback method'); |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($serverRequest->getUri()->getFragment()) { |
||
| 34 | \parse_str($serverRequest->getUri()->getFragment(), $params); |
||
| 35 | |||
| 36 | return $params; |
||
| 37 | } |
||
| 38 | |||
| 39 | return $serverRequest->getQueryParams(); |
||
| 40 | } |
||
| 41 |