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.

Client::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 3
crap 6
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\AppVeyor;
5
6
use React\EventLoop\Factory as LoopFactory;
7
use Rx\React\Promise;
8
use WyriHaximus\AppVeyor\Resource\Sync\Project;
9
use WyriHaximus\ApiClient\Transport\Client as Transport;
10
use WyriHaximus\ApiClient\Transport\Factory;
11
use function Clue\React\Block\await;
12
use function React\Promise\resolve;
13
14
class Client
15
{
16
    protected $transport;
17
    protected $client;
18
19
    public function __construct(string $token, array $options = [], Transport $transport = null)
20
    {
21
        $loop = LoopFactory::create();
22
        if (!($transport instanceof Transport)) {
23
            $settings = [
24
                'resource_namespace' => 'Sync',
25
            ] + ApiSettings::transportOptionsWithToken($token) + $options;
26
            $transport = Factory::create($loop, $settings);
27
        }
28
        $this->transport = $transport;
29
        $this->client = new AsyncClient($loop, $token, $options, $this->transport);
30
    }
31
32
    public function projects(): array
33
    {
34
        return await(
35
            Promise::fromObservable(
36
                $this->client->projects()->toArray()
37
            ),
38
            $this->transport->getLoop()
39
        );
40
    }
41
42
    public function project(string $repository): Project
43
    {
44
        return await(
45
            $this->client->project($repository),
46
            $this->transport->getLoop()
47
        );
48
    }
49
}
50