GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#2)
by Cees-Jan
21:06 queued 11:04
created

BufferedSinkMiddleware::post()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport\Middleware;
4
5
use ApiClients\Foundation\Middleware\DefaultPriorityTrait;
6
use ApiClients\Foundation\Middleware\MiddlewareInterface;
7
use ApiClients\Foundation\Middleware\PreTrait;
8
use Psr\Http\Message\ResponseInterface;
9
use React\Promise\CancellablePromiseInterface;
10
use function React\Promise\resolve;
11
use React\Stream\BufferedSink;
12
use React\Stream\ReadableStreamInterface;
13
use RingCentral\Psr7\BufferStream;
14
15
class BufferedSinkMiddleware implements MiddlewareInterface
16
{
17
    use DefaultPriorityTrait;
18
    use PreTrait;
19
20
    /**
21
     * @param ResponseInterface $response
22
     * @param array $options
23
     * @return CancellablePromiseInterface
24
     */
25 View Code Duplication
    public function post(ResponseInterface $response, array $options = []): CancellablePromiseInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        if (!($response->getBody() instanceof ReadableStreamInterface)) {
28
            return resolve($response);
29
        }
30
31
        return BufferedSink::createPromise($response->getBody())->then(function (string $body) use ($response) {
32
            $stream = new BufferStream(strlen($body));
33
            $stream->write($body);
34
            return resolve($response->withBody($stream));
35
        });
36
    }
37
}
38