src/ParseJsonRequestBodyModifier.php 1 location
|
@@ 26-35 (lines=10) @@
|
| 23 |
|
$this->asAssociativeArray = $asAssociativeArray; |
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
public function modify(ServerRequestInterface $request) : ServerRequestInterface |
| 27 |
|
{ |
| 28 |
|
if (false === strpos($request->getHeaderLine('Content-Type'), 'application/json')) { |
| 29 |
|
return $request; |
| 30 |
|
} |
| 31 |
|
|
| 32 |
|
// TODO: Implement broken json handling |
| 33 |
|
|
| 34 |
|
return $request->withParsedBody(json_decode($request->getBody()->getContents(), $this->asAssociativeArray)); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
} |
| 38 |
|
|
src/ParseURLEncodedBodyModifier.php 1 location
|
@@ 16-25 (lines=10) @@
|
| 13 |
|
*/ |
| 14 |
|
class ParseURLEncodedBodyModifier implements ServerRequestModifierInterface |
| 15 |
|
{ |
| 16 |
|
public function modify(ServerRequestInterface $request) : ServerRequestInterface |
| 17 |
|
{ |
| 18 |
|
if (false === strpos($request->getHeaderLine('Content-Type'), 'application/x-www-form-urlencoded')) { |
| 19 |
|
return $request; |
| 20 |
|
} |
| 21 |
|
|
| 22 |
|
parse_str($request->getBody()->getContents(), $parsedBody); |
| 23 |
|
|
| 24 |
|
return $request->withParsedBody($parsedBody); |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
} |
| 28 |
|
|