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.
Test Failed
Push — develop ( ffde21...960bdd )
by Baptiste
03:43
created

Client::close()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
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
19 3
    public function __construct(Connection $connection)
20
    {
21 3
        $this->connection = $connection;
22 3
        $this->channels = new Map('int', Channel::class);
23 3
    }
24
25 2
    public function channel(): Channel
26
    {
27 2
        $pid = getmypid();
28
29 2
        if ($this->channels->contains($pid)) {
30 1
            return $this->channels->get($pid);
31
        }
32
33 2
        $channel = new Channel\Channel(
34 2
            $this->connection,
35 2
            new Number($this->channel++)
36
        );
37 2
        $this->channels = $this->channels->put($pid, $channel);
38
39 2
        return $channel;
40
    }
41
42 1
    public function closed(): bool
43
    {
44 1
        return $this->connection->closed();
45
    }
46
47 1
    public function close(): void
48
    {
49 1
        if ($this->closed()) {
50 1
            return;
51
        }
52
53 1
        $this->channels->foreach(static function(int $pid, Channel $channel): void {
54 1
            $channel->close();
55 1
        });
56
        $this->connection->close();
57
    }
58
}
59