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

Client::project()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\AppVeyor;
4
5
use ApiClients\Client\AppVeyor\Resource\Sync\Project;
6
use ApiClients\Foundation\Factory as FoundationClientFactory;
7
use ApiClients\Foundation\Transport\Client as Transport;
8
use ApiClients\Foundation\Transport\Factory;
9
use React\EventLoop\Factory as LoopFactory;
10
use React\EventLoop\LoopInterface;
11
use Rx\React\Promise;
12
use function Clue\React\Block\await;
13
use Rx\Scheduler;
14
15
class Client
16
{
17
    /**
18
     * @var LoopInterface
19
     */
20
    private $loop;
21
22
    /**
23
     * @var AsyncClient
24
     */
25
    private $client;
26
27
    /**
28
     * @param string $token
29
     * @param array $options
30
     * @return Client
31
     */
32
    public static function create(
33
        string $token,
34
        array $options = []
35
    ): self {
36
        $loop = LoopFactory::create();
37
        $options = ApiSettings::getOptions($token,$options, 'Sync');
38
        $client = FoundationClientFactory::create($loop, $options);
39
40
        try {
41
            Scheduler::setAsyncFactory(function () use ($loop) {
42
                return new Scheduler\EventLoopScheduler($loop);
43
            });
44
        } catch (\Throwable $t) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
45
        }
46
47
        $asyncClient = AsyncClient::createFromClient($client);
48
49
        return new self($loop, $asyncClient);
50
    }
51
52
    /**
53
     * @param LoopInterface $loop
54
     * @param AsyncClient $client
55
     */
56
    private function __construct(LoopInterface $loop, AsyncClient $client)
57
    {
58
        $this->loop = $loop;
59
        $this->client = $client;
60
    }
61
62
    public function projects(): array
63
    {
64
        return await(
65
            Promise::fromObservable(
66
                $this->client->projects()->toArray()
67
            ),
68
            $this->loop
69
        );
70
    }
71
72
    public function project(string $repository): Project
73
    {
74
        return await(
75
            $this->client->project($repository),
76
            $this->loop
77
        );
78
    }
79
}
80