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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 46
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A close() 0 10 2
A closed() 0 3 1
A channel() 0 15 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Client;
5
6
use Innmind\AMQP\{
7
    Client as ClientInterface,
8
    Transport\Connection,
9
    Transport\Frame\Channel as Number,
10
};
11
use Innmind\OperatingSystem\CurrentProcess;
12
use Innmind\Immutable\Map;
13
14
final class Client implements ClientInterface
15
{
16
    private $connection;
17
    private $process;
18
    private $channels;
19
    private $channel = 1;
20
21 8
    public function __construct(Connection $connection, CurrentProcess $process)
22
    {
23 8
        $this->connection = $connection;
24 8
        $this->process = $process;
25 8
        $this->channels = new Map('int', Channel::class);
26 8
    }
27
28 4
    public function channel(): Channel
29
    {
30 4
        $pid = $this->process->id()->toInt();
31
32 4
        if ($this->channels->contains($pid)) {
33 2
            return $this->channels->get($pid);
34
        }
35
36 4
        $channel = new Channel\Channel(
37 4
            $this->connection,
38 4
            new Number($this->channel++)
39
        );
40 4
        $this->channels = $this->channels->put($pid, $channel);
41
42 4
        return $channel;
43
    }
44
45 2
    public function closed(): bool
46
    {
47 2
        return $this->connection->closed();
48
    }
49
50 2
    public function close(): void
51
    {
52 2
        if ($this->closed()) {
53 2
            return;
54
        }
55
56
        $this->channels->foreach(static function(int $pid, Channel $channel): void {
57 2
            $channel->close();
58 2
        });
59 2
        $this->connection->close();
60 2
    }
61
}
62