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
|
|
|
/** |
58
|
|
|
* Return the host. |
59
|
|
|
* |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
3 |
|
public function getHost() |
63
|
|
|
{ |
64
|
3 |
|
return $this->host; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Set the host. |
69
|
|
|
* |
70
|
|
|
* @param string $host IP address or hostname |
71
|
|
|
* |
72
|
|
|
* @return $this |
73
|
|
|
*/ |
74
|
3 |
|
public function setHost($host) |
75
|
|
|
{ |
76
|
3 |
|
$this->host = $host; |
77
|
|
|
|
78
|
3 |
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Return the connection scheme. |
83
|
|
|
* |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
3 |
|
public function getScheme() |
87
|
|
|
{ |
88
|
3 |
|
return $this->scheme; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Set the connection scheme. |
93
|
|
|
* |
94
|
|
|
* @param string $scheme Connection scheme |
95
|
|
|
* |
96
|
|
|
* @return $this |
97
|
|
|
*/ |
98
|
3 |
|
public function setScheme($scheme) |
99
|
|
|
{ |
100
|
3 |
|
$this->scheme = $scheme; |
101
|
|
|
|
102
|
3 |
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Return the connection port. |
107
|
|
|
* |
108
|
|
|
* @return int |
109
|
|
|
*/ |
110
|
3 |
|
public function getPort() |
111
|
|
|
{ |
112
|
3 |
|
return $this->port; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Set the connection port. |
117
|
|
|
* |
118
|
|
|
* @param int $port Connection port |
119
|
|
|
* |
120
|
|
|
* @return $this |
121
|
|
|
*/ |
122
|
3 |
|
public function setPort($port) |
123
|
|
|
{ |
124
|
3 |
|
$this->port = $port; |
125
|
|
|
|
126
|
3 |
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get the username. |
131
|
|
|
* |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
3 |
|
public function getUsername() |
135
|
|
|
{ |
136
|
3 |
|
return $this->username; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set the username. |
141
|
|
|
* |
142
|
|
|
* @param string $username Username |
143
|
|
|
* |
144
|
|
|
* @return $this |
145
|
|
|
*/ |
146
|
3 |
|
public function setUsername($username) |
147
|
|
|
{ |
148
|
3 |
|
$this->username = $username; |
149
|
|
|
|
150
|
3 |
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Return the password. |
155
|
|
|
* |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
3 |
|
public function getSecret() |
159
|
|
|
{ |
160
|
3 |
|
return $this->secret; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Set the password. |
165
|
|
|
* |
166
|
|
|
* @param string $secret Password |
167
|
|
|
* |
168
|
|
|
* @return $this |
169
|
|
|
*/ |
170
|
3 |
|
public function setSecret($secret) |
171
|
|
|
{ |
172
|
3 |
|
$this->secret = $secret; |
173
|
|
|
|
174
|
3 |
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get the connection timeout in ms. |
179
|
|
|
* |
180
|
|
|
* @return int |
181
|
|
|
*/ |
182
|
3 |
|
public function getConnectTimeout() |
183
|
|
|
{ |
184
|
3 |
|
return $this->connectTimeout; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Set the connection timeout. |
189
|
|
|
* |
190
|
|
|
* @param int $connectTimeout Connection timeout in ms |
191
|
|
|
* |
192
|
|
|
* @return $this |
193
|
|
|
*/ |
194
|
3 |
|
public function setConnectTimeout($connectTimeout) |
195
|
|
|
{ |
196
|
3 |
|
$this->connectTimeout = (int) $connectTimeout; |
197
|
|
|
|
198
|
3 |
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Return the read timeout in ms. |
203
|
|
|
* |
204
|
|
|
* @return int |
205
|
|
|
*/ |
206
|
3 |
|
public function getReadTimeout() |
207
|
|
|
{ |
208
|
3 |
|
return $this->readTimeout; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Set the read timeout. |
213
|
|
|
* |
214
|
|
|
* @param int $readTimeout Read timeout in ms |
215
|
|
|
* |
216
|
|
|
* @return $this |
217
|
|
|
*/ |
218
|
3 |
|
public function setReadTimeout($readTimeout) |
219
|
|
|
{ |
220
|
3 |
|
$this->readTimeout = (int) $readTimeout; |
221
|
|
|
|
222
|
3 |
|
return $this; |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|