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
Pull Request — master (#3)
by Cees-Jan
01:52
created

SharedAppClientService::share()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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