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::channel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 9.4285
cc 2
eloc 9
nc 2
nop 0
crap 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