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 ( c4abea...b78911 )
by Cees-Jan
01:38
created

SharedAppClientHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Pusher\CommandBus\Handler;
4
5
use ApiClients\Client\Pusher\AsyncClient;
6
use ApiClients\Client\Pusher\CommandBus\Command\SharedAppClientCommand;
7
use React\EventLoop\LoopInterface;
8
use React\Promise\PromiseInterface;
9
use function React\Promise\resolve;
10
use function WyriHaximus\React\futureFunctionPromise;
11
12
final class SharedAppClientHandler
13
{
14
    /**
15
     * @var LoopInterface
16
     */
17
    private $loop;
18
19
    /**
20
     * @var array
21
     */
22
    private $apps = [];
23
24
    /**
25
     * SharedAppClientHandler constructor.
26
     * @param LoopInterface $loop
27
     */
28 1
    public function __construct(LoopInterface $loop)
29
    {
30 1
        $this->loop = $loop;
31 1
    }
32
33
    /**
34
     * @param SharedAppClientCommand $command
35
     * @return PromiseInterface
36
     */
37 1
    public function handle(SharedAppClientCommand $command): PromiseInterface
38
    {
39 1
        if (isset($this->apps[$command->getAppId()])) {
40 1
            return resolve($this->apps[$command->getAppId()]);
41
        }
42
43 1
        $this->apps[$command->getAppId()] = new AsyncClient($this->loop, $command->getAppId());
44 1
        return resolve($this->apps[$command->getAppId()]);
45
    }
46
}
47