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 — develop ( a0d7f6...1c3e27 )
by Baptiste
02:53
created

Client   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
dl 0
loc 47
c 0
b 0
f 0
wmc 6
lcom 1
cbo 5
ccs 20
cts 21
cp 0.9524
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A channel() 0 16 2
A closed() 0 4 1
A close() 0 11 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\Immutable\Map;
12
13
final class Client implements ClientInterface
14
{
15
    private $connection;
16
    private $channels;
17
    private $channel = 1;
18
    private $closed;
19
20 3
    public function __construct(Connection $connection)
21
    {
22 3
        $this->connection = $connection;
23 3
        $this->channels = new Map('int', Channel::class);
24 3
    }
25
26 1
    public function channel(): Channel
27
    {
28 1
        $pid = getmypid();
29
30 1
        if ($this->channels->contains($pid)) {
31 1
            return $this->channels->get($pid);
32
        }
33
34 1
        $channel = new Channel\Channel(
35 1
            $this->connection,
36 1
            new Number($this->channel++)
37
        );
38 1
        $this->channels = $this->channels->put($pid, $channel);
39
40 1
        return $channel;
41
    }
42
43 1
    public function closed(): bool
44
    {
45 1
        return !$this->connection->opened();
46
    }
47
48 1
    public function close(): void
49
    {
50 1
        if ($this->closed()) {
51 1
            return;
52
        }
53
54 1
        $this->channels->foreach(static function(Channel $channel): void {
55
            $channel->close();
56 1
        });
57
        $this->connection->close();
58
    }
59
}
60