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
Push — master ( f21656...1ff9d3 )
by Cees-Jan
07:23
created

StreamingRequestService::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Transport\Service;
4
5
use ApiClients\Foundation\Service\ServiceInterface;
6
use ApiClients\Foundation\Transport\Client;
7
use ApiClients\Foundation\Transport\StreamingResponse;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
use React\Promise\CancellablePromiseInterface;
11
use function React\Promise\resolve;
12
13
final class StreamingRequestService implements ServiceInterface
14
{
15
    /**
16
     * @var Client
17
     */
18
    private $client;
19
20
    /**
21
     * @param Client $client
22
     */
23
    public function __construct(Client $client)
24
    {
25
        $this->client = $client;
26
    }
27
28
    /**
29
     * @param RequestInterface $request
30
     * @param array $options
31
     * @return CancellablePromiseInterface
32
     */
33
    public function handle(RequestInterface $request = null, array $options = []): CancellablePromiseInterface
34
    {
35
        return $this->client->request(
36
            $request,
0 ignored issues
show
Bug introduced by
It seems like $request defined by parameter $request on line 33 can be null; however, ApiClients\Foundation\Transport\Client::request() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
37
            $options
38
        )->then(function (ResponseInterface $response) {
39
            return resolve(new StreamingResponse($response));
40
        });
41
    }
42
}
43