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 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Pusher;
4
5
use function Clue\React\Block\await;
6
use React\EventLoop\Factory;
7
use React\EventLoop\LoopInterface;
8
use Rx\Observable;
9
10
final class Client
11
{
12
    /**
13
     * @var LoopInterface
14
     */
15
    private $loop;
16
17
    /**
18
     * @var AsyncClient
19
     */
20
    private $client;
21
22
    /**
23
     * @param string $app Application ID
24
     */
25
    public function __construct(string $app)
26
    {
27
        $this->loop = Factory::create();
28
        $this->client = AsyncClient::create($this->loop, $app);
29
    }
30
31
    /**
32
     * @param string   $channel  Channel to listen on
33
     * @param callable $listener Listener to call on new messages
34
     */
35
    public function channel(string $channel, callable $listener): void
36
    {
37
        $this->channels([$channel], $listener);
38
    }
39
40
    /**
41
     * @param string[] $channels Channels to listen on
42
     * @param callable $listener Listener to call on new messages
43
     */
44
    public function channels(array $channels, callable $listener): void
45
    {
46
        $promise = Observable::fromArray($channels)
47
            ->flatMap([$this->client, 'channel'])
48
            ->do($listener)
49
            ->count()
50
            ->toPromise();
51
52
        await($promise, $this->loop);
53
    }
54
}
55