@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 45 | 45 | { |
| 46 | - if ($this->isJsonPayload($request)) { |
|
| 46 | + if ($this->isJsonPayload($request)){ |
|
| 47 | 47 | $body = (string)$request->getBody(); |
| 48 | - if ($body !== '') { |
|
| 48 | + if ($body !== ''){ |
|
| 49 | 49 | $request = $request->withParsedBody(json_decode($body, true)); |
| 50 | - if (json_last_error() !== 0) { |
|
| 50 | + if (json_last_error() !== 0){ |
|
| 51 | 51 | throw new ClientException(400, 'invalid json payload'); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $contentType = $request->getHeaderLine('Content-Type'); |
| 66 | 66 | |
| 67 | - foreach ($this->config->getContentTypes() as $allowedType) { |
|
| 68 | - if (stripos($contentType, $allowedType) === 0) { |
|
| 67 | + foreach ($this->config->getContentTypes() as $allowedType){ |
|
| 68 | + if (stripos($contentType, $allowedType) === 0){ |
|
| 69 | 69 | return true; |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -43,11 +43,14 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 45 | 45 | { |
| 46 | - if ($this->isJsonPayload($request)) { |
|
| 46 | + if ($this->isJsonPayload($request)) |
|
| 47 | + { |
|
| 47 | 48 | $body = (string)$request->getBody(); |
| 48 | - if ($body !== '') { |
|
| 49 | + if ($body !== '') |
|
| 50 | + { |
|
| 49 | 51 | $request = $request->withParsedBody(json_decode($body, true)); |
| 50 | - if (json_last_error() !== 0) { |
|
| 52 | + if (json_last_error() !== 0) |
|
| 53 | + { |
|
| 51 | 54 | throw new ClientException(400, 'invalid json payload'); |
| 52 | 55 | } |
| 53 | 56 | } |
@@ -64,8 +67,10 @@ discard block |
||
| 64 | 67 | { |
| 65 | 68 | $contentType = $request->getHeaderLine('Content-Type'); |
| 66 | 69 | |
| 67 | - foreach ($this->config->getContentTypes() as $allowedType) { |
|
| 68 | - if (stripos($contentType, $allowedType) === 0) { |
|
| 70 | + foreach ($this->config->getContentTypes() as $allowedType) |
|
| 71 | + { |
|
| 72 | + if (stripos($contentType, $allowedType) === 0) |
|
| 73 | + { |
|
| 69 | 74 | return true; |
| 70 | 75 | } |
| 71 | 76 | } |