| Conditions | 5 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 42 | public static function parseFormUrlEncoded(ServerRequestInterface $request): array |
||
| 43 | { |
||
| 44 | if (!$request->hasHeader('Content-Type') || !\in_array('application/x-www-form-urlencoded', $request->getHeader('Content-Type'), true)) { |
||
| 45 | throw new InvalidArgumentException('Unsupported request body content type.'); |
||
| 46 | } |
||
| 47 | $parsedBody = $request->getParsedBody(); |
||
| 48 | if (\is_array($parsedBody) && 0 !== \count($parsedBody)) { |
||
| 49 | return $parsedBody; |
||
| 50 | } |
||
| 51 | |||
| 52 | $body = $request->getBody()->getContents(); |
||
| 53 | |||
| 54 | return (new QueryParser())->parse($body, '&', QueryParser::RFC1738_ENCODING); |
||
| 55 | } |
||
| 57 |