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 ( 8cc0dc...800d8a )
by Baptiste
03:38
created

Lazy::maxFrameSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Connection;
5
6
use Innmind\AMQP\{
7
    Model\Connection\MaxFrameSize,
8
    Transport\Connection as ConnectionInterface,
9
    Transport\Protocol,
10
    Transport\Frame,
11
    Exception\ConnectionClosed,
12
};
13
use Innmind\Socket\Internet\Transport;
14
use Innmind\Url\UrlInterface;
15
use Innmind\TimeContinuum\{
16
    TimeContinuumInterface,
17
    ElapsedPeriod,
18
};
19
use Innmind\OperatingSystem\Remote;
20
21
final class Lazy implements ConnectionInterface
22
{
23
    private $transport;
24
    private $server;
25
    private $protocol;
26
    private $timeout;
27
    private $clock;
28
    private $remote;
29
    private $connection;
30
    private $closed = false;
31
32 9
    public function __construct(
33
        Transport $transport,
34
        UrlInterface $server,
35
        Protocol $protocol,
36
        ElapsedPeriod $timeout,
37
        TimeContinuumInterface $clock,
38
        Remote $remote
39
    ) {
40 9
        $this->transport = $transport;
41 9
        $this->server = $server;
42 9
        $this->protocol = $protocol;
43 9
        $this->timeout = $timeout;
44 9
        $this->clock = $clock;
45 9
        $this->remote = $remote;
46 9
    }
47
48 1
    public function protocol(): Protocol
49
    {
50 1
        return $this->connection()->protocol();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 2
    public function send(Frame $frame): ConnectionInterface
57
    {
58 2
        return $this->connection()->send($frame);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 1
    public function wait(string ...$names): Frame
65
    {
66 1
        return $this->connection()->wait(...$names);
67
    }
68
69 1
    public function maxFrameSize(): MaxFrameSize
70
    {
71 1
        return $this->connection()->maxFrameSize();
72
    }
73 2
    public function close(): void
74
    {
75 2
        if ($this->closed) {
76
            return;
77
        }
78
79 2
        if ($this->initialized()) {
80
            $this->connection()->close();
81
        }
82
83 2
        $this->closed = true;
84 2
    }
85
86 2
    public function closed(): bool
87
    {
88 2
        if ($this->initialized()) {
89
            return $this->connection()->closed();
90
        }
91
92 2
        return $this->closed;
93
    }
94
95 3
    private function initialized(): bool
96
    {
97 3
        return $this->connection instanceof Connection;
98
    }
99
100 5
    private function connection(): Connection
101
    {
102 5
        if ($this->closed) {
103 1
            throw new ConnectionClosed;
104
        }
105
106 4
        return $this->connection ?? $this->connection = new Connection(
107 4
            $this->transport,
108 4
            $this->server,
109 4
            $this->protocol,
110 4
            $this->timeout,
111 4
            $this->clock,
112 4
            $this->remote
113
        );
114
    }
115
}
116