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 ( e126b8...d9d099 )
by Cees-Jan
05:34
created

Client::APIVersion()   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 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiClients\Client\Supervisord;
6
7
use ApiClients\Foundation\Factory as FoundationClientFactory;
8
use React\EventLoop\Factory;
9
use React\EventLoop\LoopInterface;
10
use Rx\React\Promise;
11
use function ApiClients\Tools\Rx\setAsyncScheduler;
12
use function Clue\React\Block\await;
13
14
final class Client implements ClientInterface
15
{
16
    /**
17
     * @var LoopInterface
18
     */
19
    private $loop;
20
    /**
21
     * @var AsyncClient
22
     */
23
    private $client;
24
25
    /**
26
     * @param LoopInterface $loop
27
     * @param AsyncClient   $client
28
     */
29
    private function __construct(LoopInterface $loop, AsyncClient $client)
30
    {
31
        $this->loop = $loop;
32
        $this->client = $client;
33
    }
34
35
    /**
36
     * @param  array  $options
37
     * @return Client
38
     */
39
    public static function create(string $host, array $options = []): self
40
    {
41
        $loop = Factory::create();
42
        $options = ApiSettings::getOptions($host, $options, 'Sync');
43
        $client = FoundationClientFactory::create($loop, $options);
44
        setAsyncScheduler($loop);
45
        $asyncClient = AsyncClient::createFromClient($client);
46
47
        return new self($loop, $asyncClient);
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function APIVersion(): string
54
    {
55
        return await(
56
            $this->client->APIVersion(),
57
            $this->loop
58
        );
59
    }
60
61
    /**
62
     * @return int
63
     */
64
    public function pid(): int
65
    {
66
        return await(
67
            $this->client->pid(),
68
            $this->loop
69
        );
70
    }
71
72
    /**
73
     * @return bool
74
     */
75
    public function restart(): bool
76
    {
77
        return await(
78
            $this->client->restart(),
79
            $this->loop
80
        );
81
    }
82
83
    /**
84
     * @return bool
85
     */
86
    public function shutdown(): bool
87
    {
88
        return await(
89
            $this->client->shutdown(),
90
            $this->loop
91
        );
92
    }
93
94
    /**
95
     * @return array
96
     */
97
    public function programs(): array
98
    {
99
        return await(
100
            Promise::fromObservable(
101
                $this->client->programs()->toArray()
102
            ),
103
            $this->loop
104
        );
105
    }
106
}
107