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
Pull Request — master (#18)
by Cees-Jan
03:24 queued 01:27
created

Client::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 2
b 1
f 0
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\Travis;
5
6
use WyriHaximus\Travis\Resource\Sync\Repository;
7
use WyriHaximus\Travis\Transport\Client as Transport;
8
use WyriHaximus\Travis\Transport\Factory;
9
use function Clue\React\Block\await;
10
use function React\Promise\resolve;
11
12
class Client
13
{
14
    protected $transport;
15
    protected $client;
16
17
    public function __construct(Transport $transport = null)
18
    {
19
        if (!($transport instanceof Transport)) {
20
            $transport = Factory::create();
21
        }
22
        $this->transport = $transport;
23
        $this->client = new AsyncClient($this->transport);
24
    }
25
26
    public function repository(string $repository): Repository
27
    {
28
        return await(
29
            $this->transport->request('repos/' . $repository)->then(function ($json) {
30
                return resolve($this->transport->hydrate(Repository::class, $json['repo']));
31
            }),
32
            $this->transport->getLoop()
33
        );
34
    }
35
}
36