ConnectionParameters::getConnectionTimeout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ccovey\RabbitMQ\Connection;
4
5
class ConnectionParameters
6
{
7
    const DEFAULT_PORT = 5672;
8
9
    const DEFAULT_USER = 'guest';
10
11
    const DEFAULT_PASSWORD = 'guest';
12
13
    const LOGIN_METHOD = 'AMQPLAIN';
14
15
    const LOCALE = 'en_US';
16
17
    const CONNECTION_TIMEOUT = 3.0;
18
19
    const READ_WRITE_TIMEOUT = 3.0;
20
21
    /**
22
     * @var string
23
     */
24
    private $host;
25
26
    /**
27
     * @var int
28
     */
29
    private $port;
30
31
    /**
32
     * @var string
33
     */
34
    private $user;
35
36
    /**
37
     * @var string
38
     */
39
    private $password;
40
41
    /**
42
     * @var string
43
     */
44
    private $vhost;
45
46
    /**
47
     * @var bool
48
     */
49
    private $insist;
50
51
    /**
52
     * @var string
53
     */
54
    private $loginMethod;
55
56
    private $loginResponse;
57
58
    /**
59
     * @var string
60
     */
61
    private $locale;
62
63
    /**
64
     * @var int
65
     */
66
    private $connectionTimeout;
67
68
    /**
69
     * @var int
70
     */
71
    private $readWriteTimeout;
72
73
    /**
74
     * @var null
75
     */
76
    private $context;
77
78
    /**
79
     * @var bool
80
     */
81
    private $keepalive;
82
83
    /**
84
     * @var int
85
     */
86
    private $heartbeat;
87
88 3
    public function __construct(
89
        string $host,
90
        int $port = self::DEFAULT_PORT,
91
        string $user = self::DEFAULT_USER,
92
        string $password = self::DEFAULT_PASSWORD,
93
        string $vhost = '/',
94
        bool $insist = false,
95
        string $loginMethod = self::LOGIN_METHOD,
96
        $loginResponse = null,
97
        string $locale = self::LOCALE,
98
        float $connectionTimeout = self::CONNECTION_TIMEOUT,
99
        float $readWriteTimeout = self::READ_WRITE_TIMEOUT,
100
        $context = null,
101
        bool $keepalive = false,
102
        int $heartbeat = 0
103
    )
104
    {
105 3
        $this->host = $host;
106 3
        $this->port = $port;
107 3
        $this->user = $user;
108 3
        $this->password = $password;
109 3
        $this->vhost = $vhost;
110 3
        $this->insist = $insist;
111 3
        $this->loginMethod = $loginMethod;
112 3
        $this->loginResponse = $loginResponse;
113 3
        $this->locale = $locale;
114 3
        $this->connectionTimeout = $connectionTimeout;
0 ignored issues
show
Documentation Bug introduced by
The property $connectionTimeout was declared of type integer, but $connectionTimeout is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
115 3
        $this->readWriteTimeout = $readWriteTimeout;
0 ignored issues
show
Documentation Bug introduced by
The property $readWriteTimeout was declared of type integer, but $readWriteTimeout is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
116 3
        $this->context = $context;
117 3
        $this->keepalive = $keepalive;
118 3
        $this->heartbeat = $heartbeat;
119 3
    }
120
121 1
    public function getHost() : string
122
    {
123 1
        return $this->host;
124
    }
125
126 1
    public function getPort() : int
127
    {
128 1
        return $this->port;
129
    }
130
131 1
    public function getUser() : string
132
    {
133 1
        return $this->user;
134
    }
135
136 1
    public function getPassword() : string
137
    {
138 1
        return $this->password;
139
    }
140
141 1
    public function getVhost() : string
142
    {
143 1
        return $this->vhost;
144
    }
145
146 1
    public function shouldInsist() : bool
147
    {
148 1
        return $this->insist;
149
    }
150
151 1
    public function getLoginMethod() : string
152
    {
153 1
        return $this->loginMethod;
154
    }
155
156 1
    public function getLoginResponse()
157
    {
158 1
        return $this->loginResponse;
159
    }
160
161 1
    public function getLocale() : string
162
    {
163 1
        return $this->locale;
164
    }
165
166 1
    public function getConnectionTimeout() : int
167
    {
168 1
        return $this->connectionTimeout;
169
    }
170
171 1
    public function getReadWriteTimeout() : int
172
    {
173 1
        return $this->readWriteTimeout;
174
    }
175
176 1
    public function getContext()
177
    {
178 1
        return $this->context;
179
    }
180
181 1
    public function shouldKeepalive() : bool
182
    {
183 1
        return $this->keepalive;
184
    }
185
186 1
    public function getHeartbeat() : int
187
    {
188 1
        return $this->heartbeat;
189
    }
190
}
191