Conditions | 5 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public function onKernelRequest(GetResponseEvent $event): void |
||
15 | { |
||
16 | $request = $event->getRequest(); |
||
17 | if ('json' !== $request->getContentType() || !$request->getContent()) { |
||
18 | return; |
||
19 | } |
||
20 | |||
21 | $data = json_decode((string) $request->getContent(), true); |
||
22 | if (JSON_ERROR_NONE !== json_last_error()) { |
||
23 | throw new BadRequestHttpException('invalid json body: '.json_last_error_msg()); |
||
24 | } |
||
25 | |||
26 | $request->request->replace(is_array($data) ? $data : []); |
||
27 | } |
||
36 |