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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 50
ccs 19
cts 20
cp 0.95
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A channel() 0 6 1
A closed() 0 4 1
A close() 0 4 1
A register() 0 22 2
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