Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
46 | 2 | public function pre(RequestInterface $request, array $options = []): CancellablePromiseInterface |
|
47 | { |
||
48 | 2 | if (!($request->getBody() instanceof JsonStream)) { |
|
49 | 1 | return resolve($request); |
|
50 | } |
||
51 | |||
52 | 1 | return $this->jsonEncodeService->encode($request->getBody()->getJson())->then(function ($json) use ($request) { |
|
53 | 1 | $body = new BufferStream(strlen($json)); |
|
54 | 1 | $body->write($json); |
|
55 | 1 | return resolve($request->withBody($body)->withAddedHeader('Content-Type', 'application/json')); |
|
56 | 1 | }); |
|
57 | } |
||
58 | } |
||
59 |