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 ( 4cbc06...07baac )
by Baptiste
02:19
created

SignalAware::channel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Client;
5
6
use Innmind\AMQP\Client as ClientInterface;
7
8
final class SignalAware implements ClientInterface
9
{
10
    private $client;
11
    private $handlersRegistered = false;
12
13 2
    public function __construct(ClientInterface $client)
14
    {
15 2
        $this->client = $client;
16 2
    }
17
18 2
    public function channel(): Channel
19
    {
20 2
        $this->register();
21
22 2
        return $this->client->channel();
23
    }
24
25 2
    public function closed(): bool
26
    {
27 2
        return $this->client->closed();
28
    }
29
30 2
    public function close(): void
31
    {
32 2
        $this->client->close();
33 2
    }
34
35 2
    private function register(): void
36
    {
37 2
        if ($this->handlersRegistered === true) {
38
            return;
39
        }
40
41 2
        pcntl_async_signals(true);
42
43 2
        $softClose = function(): void {
44 2
            $this->close();
45 2
        };
46
47 2
        pcntl_signal(SIGHUP, static function() {
48
            //do nothing so it can run in background
49 2
        });
50
        pcntl_signal(SIGINT, $softClose);
51
        pcntl_signal(SIGABRT, $softClose);
52
        pcntl_signal(SIGTERM, $softClose);
53
        pcntl_signal(SIGTSTP, $softClose);
54
        pcntl_signal(SIGALRM, $softClose);
55
        $this->handlersRegistered = true;
56
    }
57
}
58