1 | <?php |
||
11 | abstract class GameapAbstractAdapter extends AbstractAdapter |
||
12 | { |
||
13 | /** |
||
14 | * @var GdaemonFiles |
||
15 | */ |
||
16 | protected $connection; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $host; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $port = 31717; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | protected $timeout = 10; |
||
32 | |||
33 | /** |
||
34 | * @var SafeStorage |
||
35 | */ |
||
36 | protected $safeStorage; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $privateKey; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $serverCertificate; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $localCertificate; |
||
52 | |||
53 | /** |
||
54 | * @var int |
||
55 | */ |
||
56 | protected $permPublic = 0744; |
||
57 | |||
58 | /** |
||
59 | * @var int |
||
60 | */ |
||
61 | protected $permPrivate = 0700; |
||
62 | |||
63 | /** |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $configurable = []; |
||
67 | |||
68 | /** |
||
69 | * Connect to the server. |
||
70 | */ |
||
71 | 3 | public function connect() |
|
72 | { |
||
73 | 3 | $this->connection = new GdaemonFiles([ |
|
74 | 3 | 'host' => $this->getHost(), |
|
75 | 3 | 'port' => $this->getPort(), |
|
76 | 3 | 'username' => $this->getUsername(), |
|
77 | 3 | 'password' => $this->getPassword(), |
|
78 | 3 | 'localCertificate' => $this->getLocalCertificate(), |
|
79 | 3 | 'serverCertificate' => $this->getServerCertificate(), |
|
80 | 3 | 'privateKey' => $this->getPrivateKey(), |
|
81 | 3 | 'privateKeyPass' => $this->getPrivateKeyPass(), |
|
82 | 3 | 'timeout' => $this->getTimeout(), |
|
83 | 2 | ]); |
|
84 | 1 | } |
|
85 | |||
86 | /** |
||
87 | * Disconnect |
||
88 | */ |
||
89 | 6 | public function disconnect() |
|
95 | |||
96 | /** |
||
97 | * @return GDaemonFiles |
||
98 | */ |
||
99 | 70 | public function getConnection() |
|
100 | { |
||
101 | 70 | $tries = 0; |
|
102 | |||
103 | 70 | while ( ! $this->isConnected() && $tries < 3) { |
|
104 | 3 | $tries++; |
|
105 | 3 | $this->disconnect(); |
|
106 | 3 | $this->connect(); |
|
107 | 2 | } |
|
108 | |||
109 | 70 | return $this->connection; |
|
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param GdaemonFiles $connection |
||
114 | */ |
||
115 | 3 | public function setConnection($connection) |
|
119 | |||
120 | /** |
||
121 | * Constructor. |
||
122 | * |
||
123 | * @param array $config |
||
124 | */ |
||
125 | 3 | public function __construct(array $config) |
|
126 | { |
||
127 | 3 | $this->safeStorage = new SafeStorage(); |
|
128 | 3 | $this->setConfig($config); |
|
129 | 3 | } |
|
130 | |||
131 | /** |
||
132 | * Set the config. |
||
133 | * |
||
134 | * @param array $config |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | 6 | public function setConfig(array $config) |
|
154 | |||
155 | /** |
||
156 | * Disconnect on destruction. |
||
157 | */ |
||
158 | 3 | public function __destruct() |
|
159 | { |
||
160 | 3 | $this->disconnect(); |
|
161 | 3 | } |
|
162 | |||
163 | /** |
||
164 | * Returns the username. |
||
165 | * |
||
166 | * @return string username |
||
167 | */ |
||
168 | 12 | public function getUsername() |
|
174 | |||
175 | /** |
||
176 | * Set username. |
||
177 | * |
||
178 | * @param string $username |
||
179 | * |
||
180 | * @return $this |
||
181 | */ |
||
182 | 9 | public function setUsername($username) |
|
188 | |||
189 | /** |
||
190 | * Returns the password. |
||
191 | * |
||
192 | * @return string password |
||
193 | */ |
||
194 | 12 | public function getPassword() |
|
198 | |||
199 | /** |
||
200 | * Set the password. |
||
201 | * |
||
202 | * @param string $password |
||
203 | * |
||
204 | * @return $this |
||
205 | */ |
||
206 | 9 | public function setPassword($password) |
|
212 | |||
213 | /** |
||
214 | * Returns the password. |
||
215 | * |
||
216 | * @return string password |
||
217 | */ |
||
218 | 12 | public function getPrivateKey() |
|
222 | |||
223 | /** |
||
224 | * Set the private key (string or path to local file). |
||
225 | * |
||
226 | * @param string $key |
||
227 | * |
||
228 | * @return $this |
||
229 | */ |
||
230 | 9 | public function setPrivateKey($key) |
|
236 | |||
237 | /** |
||
238 | * Returns the password. |
||
239 | * |
||
240 | * @return string password |
||
241 | */ |
||
242 | 12 | public function getPrivateKeyPass() |
|
246 | |||
247 | /** |
||
248 | * Set the password. |
||
249 | * |
||
250 | * @param string $password |
||
|
|||
251 | * |
||
252 | * @return $this |
||
253 | */ |
||
254 | 9 | public function setPrivateKeyPass($privateKeyPass) |
|
260 | |||
261 | /** |
||
262 | * Returns the host. |
||
263 | * |
||
264 | * @return string |
||
265 | */ |
||
266 | 9 | public function getHost() |
|
270 | |||
271 | /** |
||
272 | * Set the host. |
||
273 | * |
||
274 | * @param string $host |
||
275 | * |
||
276 | * @return $this |
||
277 | */ |
||
278 | 9 | public function setHost($host) |
|
284 | |||
285 | /** |
||
286 | * Returns the port. |
||
287 | * |
||
288 | * @return int |
||
289 | */ |
||
290 | 9 | public function getPort() |
|
294 | |||
295 | /** |
||
296 | * Set the port. |
||
297 | * |
||
298 | * @param int|string $port |
||
299 | * |
||
300 | * @return $this |
||
301 | */ |
||
302 | 9 | public function setPort($port) |
|
308 | |||
309 | /** |
||
310 | * Returns the amount of seconds before the connection will timeout. |
||
311 | * |
||
312 | * @return int |
||
313 | */ |
||
314 | 9 | public function getTimeout() |
|
318 | |||
319 | /** |
||
320 | * Set the amount of seconds before the connection should timeout. |
||
321 | * |
||
322 | * @param int $timeout |
||
323 | * |
||
324 | * @return $this |
||
325 | */ |
||
326 | 3 | public function setTimeout($timeout) |
|
332 | |||
333 | /** |
||
334 | * Returns the root folder to work from. |
||
335 | * |
||
336 | * @return string |
||
337 | */ |
||
338 | 6 | public function getRoot() |
|
342 | |||
343 | /** |
||
344 | * Set the root folder to work from. |
||
345 | * |
||
346 | * @param string $root |
||
347 | * |
||
348 | * @return $this |
||
349 | */ |
||
350 | 6 | public function setRoot($root) |
|
355 | |||
356 | /** |
||
357 | * @return string |
||
358 | */ |
||
359 | 6 | public function getLocalCertificate() |
|
363 | |||
364 | /** |
||
365 | * @param $localCertificate |
||
366 | * @return $this |
||
367 | */ |
||
368 | 3 | public function setLocalCertificate($localCertificate) |
|
373 | |||
374 | /** |
||
375 | * @return string |
||
376 | */ |
||
377 | 6 | public function getServerCertificate() |
|
381 | |||
382 | /** |
||
383 | * @param $serverCertificate |
||
384 | * @return $this |
||
385 | */ |
||
386 | 3 | public function setServerCertificate($serverCertificate) |
|
391 | |||
392 | /** |
||
393 | * Normalize a listing response. |
||
394 | * |
||
395 | * @param string $path |
||
396 | * @param array $object |
||
397 | * |
||
398 | * @return array |
||
399 | */ |
||
400 | 6 | protected function normalizeListingObject($path, array $object) |
|
417 | |||
418 | /** |
||
419 | * Check if a connection is active. |
||
420 | * |
||
421 | * @return bool |
||
422 | */ |
||
423 | abstract public function isConnected(); |
||
424 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.