Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
39 | 2 | public function post( |
|
40 | ResponseInterface $response, |
||
41 | string $transactionId, |
||
42 | array $options = [] |
||
43 | ): CancellablePromiseInterface { |
||
44 | 2 | if (!($response->getBody() instanceof ReadableStreamInterface)) { |
|
45 | 1 | return resolve($response); |
|
46 | } |
||
47 | |||
48 | 1 | $body = $response->getBody(); |
|
49 | 1 | $this->loop->futureTick(function () use ($body) { |
|
50 | 1 | $body->resume(); |
|
51 | 1 | }); |
|
52 | |||
53 | 1 | return buffer($response->getBody())->then(function (string $body) use ($response) { |
|
54 | 1 | $stream = new BufferStream(strlen($body)); |
|
55 | 1 | $stream->write($body); |
|
56 | |||
57 | 1 | return resolve($response->withBody($stream)); |
|
58 | 1 | }); |
|
59 | } |
||
60 | } |
||
61 |