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.

AsyncClient   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 8
dl 0
loc 33
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A projects() 0 10 1
A project() 0 6 1
A __construct() 0 10 2
1
<?php
2
declare(strict_types=1);
3
4
namespace WyriHaximus\AppVeyor;
5
6
use React\EventLoop\LoopInterface;
7
use React\Promise\PromiseInterface;
8
use Rx\Observable;
9
use Rx\ObservableInterface;
10
use Rx\React\Promise;
11
use WyriHaximus\ApiClient\Transport\Client as Transport;
12
use WyriHaximus\ApiClient\Transport\Factory;
13
use function React\Promise\resolve;
14
15
class AsyncClient
16
{
17
    protected $transport;
18
19
    public function __construct(LoopInterface $loop, string $token, array $options = [], Transport $transport = null)
20
    {
21
        if (!($transport instanceof Transport)) {
22
            $settings = [
23
                    'resource_namespace' => 'Async',
24
            ] + ApiSettings::transportOptionsWithToken($token) + $options;
25
            $transport = Factory::create($loop, $settings);
26
        }
27
        $this->transport = $transport;
28
    }
29
30
    public function projects(): ObservableInterface
31
    {
32
        return Promise::toObservable(
33
            $this->transport->request('projects')
34
        )->flatMap(function ($response) {
35
            return Observable::fromArray($response);
36
        })->map(function ($project) {
37
            return $this->transport->getHydrator()->hydrate('Project', $project);
38
        });
39
    }
40
41
    public function project(string $repository): PromiseInterface
42
    {
43
        return $this->transport->request('projects/' . $repository)->then(function ($json) {
44
            return resolve($this->transport->getHydrator()->hydrate('Project', $json['project']));
45
        });
46
    }
47
}
48