1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PamiModule\Options; |
4
|
|
|
|
5
|
|
|
use Zend\Stdlib\AbstractOptions; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Connection. |
9
|
|
|
*/ |
10
|
|
|
class Connection extends AbstractOptions |
11
|
|
|
{ |
12
|
|
|
const SCHEME_TCP = 'tcp://'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Hostname. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $host; |
20
|
|
|
/** |
21
|
|
|
* Connection scheme. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $scheme = 'tcp://'; |
26
|
|
|
/** |
27
|
|
|
* Connection port. |
28
|
|
|
* |
29
|
|
|
* @var int |
30
|
|
|
*/ |
31
|
|
|
protected $port = 5038; |
32
|
|
|
/** |
33
|
|
|
* Username. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
protected $username; |
38
|
|
|
/** |
39
|
|
|
* Password. |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $secret; |
44
|
|
|
/** |
45
|
|
|
* Connection timeout. |
46
|
|
|
* |
47
|
|
|
* @var int |
48
|
|
|
*/ |
49
|
|
|
protected $connectTimeout = 10000; |
50
|
|
|
/** |
51
|
|
|
* Read timeout. |
52
|
|
|
* |
53
|
|
|
* @var int |
54
|
|
|
*/ |
55
|
|
|
protected $readTimeout = 10000; |
56
|
|
|
/** |
57
|
|
|
* @var null|string[] |
58
|
|
|
*/ |
59
|
|
|
protected $eventMask; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Return the host. |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
3 |
|
public function getHost() |
67
|
|
|
{ |
68
|
3 |
|
return $this->host; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Set the host. |
73
|
|
|
* |
74
|
|
|
* @param string $host IP address or hostname |
75
|
|
|
* |
76
|
|
|
* @return $this |
77
|
|
|
*/ |
78
|
3 |
|
public function setHost($host) |
79
|
|
|
{ |
80
|
3 |
|
$this->host = $host; |
81
|
|
|
|
82
|
3 |
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Return the connection scheme. |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
3 |
|
public function getScheme() |
91
|
|
|
{ |
92
|
3 |
|
return $this->scheme; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Set the connection scheme. |
97
|
|
|
* |
98
|
|
|
* @param string $scheme Connection scheme |
99
|
|
|
* |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
3 |
|
public function setScheme($scheme) |
103
|
|
|
{ |
104
|
3 |
|
$this->scheme = $scheme; |
105
|
|
|
|
106
|
3 |
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Return the connection port. |
111
|
|
|
* |
112
|
|
|
* @return int |
113
|
|
|
*/ |
114
|
3 |
|
public function getPort() |
115
|
|
|
{ |
116
|
3 |
|
return $this->port; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Set the connection port. |
121
|
|
|
* |
122
|
|
|
* @param int $port Connection port |
123
|
|
|
* |
124
|
|
|
* @return $this |
125
|
|
|
*/ |
126
|
3 |
|
public function setPort($port) |
127
|
|
|
{ |
128
|
3 |
|
$this->port = $port; |
129
|
|
|
|
130
|
3 |
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Get the username. |
135
|
|
|
* |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
3 |
|
public function getUsername() |
139
|
|
|
{ |
140
|
3 |
|
return $this->username; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Set the username. |
145
|
|
|
* |
146
|
|
|
* @param string $username Username |
147
|
|
|
* |
148
|
|
|
* @return $this |
149
|
|
|
*/ |
150
|
3 |
|
public function setUsername($username) |
151
|
|
|
{ |
152
|
3 |
|
$this->username = $username; |
153
|
|
|
|
154
|
3 |
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Return the password. |
159
|
|
|
* |
160
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
3 |
|
public function getSecret() |
163
|
|
|
{ |
164
|
3 |
|
return $this->secret; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Set the password. |
169
|
|
|
* |
170
|
|
|
* @param string $secret Password |
171
|
|
|
* |
172
|
|
|
* @return $this |
173
|
|
|
*/ |
174
|
3 |
|
public function setSecret($secret) |
175
|
|
|
{ |
176
|
3 |
|
$this->secret = $secret; |
177
|
|
|
|
178
|
3 |
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Get the connection timeout in ms. |
183
|
|
|
* |
184
|
|
|
* @return int |
185
|
|
|
*/ |
186
|
3 |
|
public function getConnectTimeout() |
187
|
|
|
{ |
188
|
3 |
|
return $this->connectTimeout; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Set the connection timeout. |
193
|
|
|
* |
194
|
|
|
* @param int $connectTimeout Connection timeout in ms |
195
|
|
|
* |
196
|
|
|
* @return $this |
197
|
|
|
*/ |
198
|
3 |
|
public function setConnectTimeout($connectTimeout) |
199
|
|
|
{ |
200
|
3 |
|
$this->connectTimeout = (int) $connectTimeout; |
201
|
|
|
|
202
|
3 |
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Return the read timeout in ms. |
207
|
|
|
* |
208
|
|
|
* @return int |
209
|
|
|
*/ |
210
|
3 |
|
public function getReadTimeout() |
211
|
|
|
{ |
212
|
3 |
|
return $this->readTimeout; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Set the read timeout. |
217
|
|
|
* |
218
|
|
|
* @param int $readTimeout Read timeout in ms |
219
|
|
|
* |
220
|
|
|
* @return $this |
221
|
|
|
*/ |
222
|
3 |
|
public function setReadTimeout($readTimeout) |
223
|
|
|
{ |
224
|
3 |
|
$this->readTimeout = (int) $readTimeout; |
225
|
|
|
|
226
|
3 |
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @return null|string[] |
231
|
|
|
*/ |
232
|
3 |
|
public function getEventMask() |
233
|
|
|
{ |
234
|
3 |
|
return $this->eventMask; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @param null|string[] $eventMask |
239
|
|
|
*/ |
240
|
|
|
public function setEventMask(array $eventMask = null) |
241
|
|
|
{ |
242
|
|
|
$this->eventMask = $eventMask; |
243
|
|
|
} |
244
|
|
|
} |
245
|
|
|
|