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 ( 1177c8...d9fbae )
by Cees-Jan
10:32
created

AsyncClient::projects()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\AppVeyor;
4
5
use ApiClients\Client\AppVeyor\CommandBus\Command\ProjectCommand;
6
use ApiClients\Client\AppVeyor\CommandBus\Command\ProjectsCommand;
7
use ApiClients\Foundation\ClientInterface;
8
use ApiClients\Foundation\Factory;
9
use React\EventLoop\LoopInterface;
10
use React\Promise\PromiseInterface;
11
use Rx\Observable;
12
use Rx\ObservableInterface;
13
use Rx\React\Promise;
14
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
15
use function React\Promise\resolve;
16
use Rx\Scheduler;
17
18
class AsyncClient
19
{
20
    /**
21
     * @var ClientInterface
22
     */
23
    private $client;
24
25
    /**
26
     * @param LoopInterface $loop
27
     * @param string $token
28
     * @param array $options
29
     * @return AsyncClient
30
     */
31
    public static function create(
32
        LoopInterface $loop,
33
        string $token,
34
        array $options = []
35
    ): self {
36
        $options = ApiSettings::getOptions($token, $options, 'Async');
37
        $client = Factory::create($loop, $options);
38
39
        try {
40
            Scheduler::setAsyncFactory(function () use ($loop) {
41
                return new Scheduler\EventLoopScheduler($loop);
0 ignored issues
show
Documentation introduced by
$loop is of type object<React\EventLoop\LoopInterface>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
            });
43
        } catch (\Throwable $t) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
44
        }
45
46
        return new self($client);
47
    }
48
49
    /**
50
     * @internal
51
     * @param ClientInterface $client
52
     * @return AsyncClient
53
     */
54
    public static function createFromClient(ClientInterface $client): self
55
    {
56
        return new self($client);
57
    }
58
59
    /**
60
     * @param ClientInterface $client
61
     */
62
    private function __construct(ClientInterface $client)
63
    {
64
        $this->client = $client;
65
    }
66
67
    public function projects(): ObservableInterface
68
    {
69
        return unwrapObservableFromPromise($this->client->handle(new ProjectsCommand()));
70
    }
71
72
    public function project(string $repository): PromiseInterface
73
    {
74
        return $this->client->handle(new ProjectCommand($repository));
75
    }
76
}
77