| Total Complexity | 7 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 13 | final class JsonBodyParser implements MiddlewareInterface |
||
| 14 | { |
||
| 15 | private bool $assoc; |
||
| 16 | private int $depth; |
||
| 17 | private int $options; |
||
| 18 | |||
| 19 | public function __construct( |
||
| 27 | } |
||
| 28 | |||
| 29 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 30 | { |
||
| 31 | $contentType = $request->getHeaderLine(Header::CONTENT_TYPE); |
||
| 32 | |||
| 33 | if ($contentType && \strpos(\strtolower($contentType), 'application/json') !== false) { |
||
| 34 | $request = $request->withParsedBody( |
||
| 35 | $this->parse($request->getBody()->getContents()) |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | return $handler->handle($request); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return array|object|null |
||
| 44 | */ |
||
| 45 | private function parse(string $rawBody) |
||
| 52 | } |
||
| 53 | } |
||
| 54 |