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 ( b42dfd...ebd3a0 )
by Cees-Jan
13s
created

SharedAppClientService::share()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Pusher\Service;
4
5
use ApiClients\Client\Pusher\AsyncClient;
6
use React\EventLoop\LoopInterface;
7
use React\Promise\CancellablePromiseInterface;
8
use function React\Promise\resolve;
9
10
final class SharedAppClientService
11
{
12
    /**
13
     * @var LoopInterface
14
     */
15
    private $loop;
16
17
    /**
18
     * @var array
19
     */
20
    private $apps = [];
21
22
    /**
23
     * SharedAppClientHandler constructor.
24
     * @param LoopInterface $loop
25
     */
26 2
    public function __construct(LoopInterface $loop)
27
    {
28 2
        $this->loop = $loop;
29 2
    }
30
31
    /**
32
     * @param  string|null                 $appId
33
     * @return CancellablePromiseInterface
34
     */
35 2
    public function share(string $appId): CancellablePromiseInterface
36
    {
37 2
        if (isset($this->apps[$appId])) {
38 2
            return resolve($this->apps[$appId]);
39
        }
40
41 2
        $this->apps[$appId] = AsyncClient::create($this->loop, $appId);
42
43 2
        return resolve($this->apps[$appId]);
44
    }
45
}
46