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 ( 063be6...e2c735 )
by Cees-Jan
05:46
created

Client::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Skeleton;
4
5
use ApiClients\Client\Skeleton\Resource\ExampleInterface;
6
use ApiClients\Foundation\Factory as FoundationClientFactory;
7
use React\EventLoop\Factory;
8
use React\EventLoop\LoopInterface;
9
use Rx\React\Promise;
10
use function ApiClients\Tools\Rx\setAsyncScheduler;
11
use function Clue\React\Block\await;
12
13
final class Client implements ClientInterface
14
{
15
    /**
16
     * @var LoopInterface
17
     */
18
    private $loop;
19
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(
40
        array $options = []
41
    ): self {
42
        $loop = Factory::create();
43
        $options = ApiSettings::getOptions($options, 'Sync');
44
        $client = FoundationClientFactory::create($loop, $options);
45
46
        setAsyncScheduler($loop);
47
48
        $asyncClient = AsyncClient::createFromClient($client);
49
50
        return new self($loop, $asyncClient);
51
    }
52
53
    /**
54
     * @param  string           $input
55
     * @return ExampleInterface
56
     */
57
    public function method(string $input): ExampleInterface
58
    {
59
        return await(
60
            $this->client->method($input),
61
            $this->loop
62
        );
63
    }
64
65
    /**
66
     * @return array
67
     */
68
    public function stream(string $input): array
69
    {
70
        return await(
71
            Promise::fromObservable(
72
                $this->client->stream($input)->toArray()
73
            ),
74
            $this->loop
75
        );
76
    }
77
}
78