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   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 52.17 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 6
dl 12
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A post() 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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