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.

SharedAppClientService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A share() 0 10 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