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.
Passed
Push — master ( d35983...fc45f0 )
by Baptiste
03:46
created

SignalAware::register()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2.0011

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 0
dl 0
loc 21
ccs 14
cts 15
cp 0.9333
crap 2.0011
rs 9.3142
c 0
b 0
f 0
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 1
    public function channel(): Channel
19
    {
20 1
        $this->register();
21
22 1
        return $this->client->channel();
23
    }
24
25 1
    public function closed(): bool
26
    {
27 1
        return $this->client->closed();
28
    }
29
30 1
    public function close(): void
31
    {
32 1
        $this->client->close();
33 1
    }
34
35 1
    private function register(): void
36
    {
37 1
        if ($this->handlersRegistered === true) {
38
            return;
39
        }
40
41 1
        pcntl_async_signals(true);
42
43 1
        $softClose = function(): void {
44 1
            $this->close();
45 1
        };
46
47 1
        pcntl_signal(SIGHUP, static function() {
48
            //do nothing so it can run in background
49 1
        });
50 1
        pcntl_signal(SIGINT, $softClose);
51 1
        pcntl_signal(SIGABRT, $softClose);
52 1
        pcntl_signal(SIGTERM, $softClose);
53 1
        pcntl_signal(SIGTSTP, $softClose);
54 1
        pcntl_signal(SIGALRM, $softClose);
55 1
        $this->handlersRegistered = true;
56 1
    }
57
}
58