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.

RequestService::request()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.7666
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 3
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport\Service;
4
5
use ApiClients\Foundation\Transport\ClientInterface;
6
use ApiClients\Foundation\Transport\Middleware\BufferedSinkMiddleware;
7
use ApiClients\Foundation\Transport\Options;
8
use Psr\Http\Message\RequestInterface;
9
use React\Promise\CancellablePromiseInterface;
10
11
class RequestService
12
{
13
    /**
14
     * @var ClientInterface
15
     */
16
    private $client;
17
18
    /**
19
     * @param ClientInterface $client
20
     */
21 1
    public function __construct(ClientInterface $client)
22
    {
23 1
        $this->client = $client;
24 1
    }
25
26
    /**
27
     * @param  RequestInterface            $request
28
     * @param  array                       $options
29
     * @return CancellablePromiseInterface
30
     */
31 1
    public function request(RequestInterface $request, array $options = []): CancellablePromiseInterface
32
    {
33 1
        if (!isset($options[Options::MIDDLEWARE])) {
34 1
            $options[Options::MIDDLEWARE] = [];
35
        }
36
37 1
        if (!in_array(BufferedSinkMiddleware::class, $options[Options::MIDDLEWARE], true)) {
38 1
            $options[Options::MIDDLEWARE][] = BufferedSinkMiddleware::class;
39
        }
40
41 1
        return $this->client->request(
42 1
            $request,
43 1
            $options
44
        );
45
    }
46
}
47