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 | protected $privateKey; |
||
39 | |||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $permPublic = 0744; |
||
44 | |||
45 | /** |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $permPrivate = 0700; |
||
49 | |||
50 | /** |
||
51 | * Connect to the server. |
||
52 | */ |
||
53 | public function connect() |
||
65 | |||
66 | /** |
||
67 | * Disconnect |
||
68 | */ |
||
69 | 3 | public function disconnect() |
|
75 | |||
76 | /** |
||
77 | * @return GDaemonFiles |
||
78 | */ |
||
79 | 63 | public function getConnection() |
|
91 | |||
92 | /** |
||
93 | * @param GdaemonFiles $connection |
||
94 | */ |
||
95 | 3 | public function setConnection($connection) |
|
99 | |||
100 | /** |
||
101 | * Constructor. |
||
102 | * |
||
103 | * @param array $config |
||
104 | */ |
||
105 | public function __construct(array $config) |
||
110 | |||
111 | /** |
||
112 | * Set the config. |
||
113 | * |
||
114 | * @param array $config |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | 3 | public function setConfig(array $config) |
|
134 | |||
135 | /** |
||
136 | * Disconnect on destruction. |
||
137 | */ |
||
138 | public function __destruct() |
||
142 | |||
143 | /** |
||
144 | * Returns the username. |
||
145 | * |
||
146 | * @return string username |
||
147 | */ |
||
148 | 6 | public function getUsername() |
|
154 | |||
155 | /** |
||
156 | * Set username. |
||
157 | * |
||
158 | * @param string $username |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | 6 | public function setUsername($username) |
|
168 | |||
169 | /** |
||
170 | * Returns the password. |
||
171 | * |
||
172 | * @return string password |
||
173 | */ |
||
174 | 6 | public function getPassword() |
|
178 | |||
179 | /** |
||
180 | * Set the password. |
||
181 | * |
||
182 | * @param string $password |
||
183 | * |
||
184 | * @return $this |
||
185 | */ |
||
186 | 6 | public function setPassword($password) |
|
192 | |||
193 | /** |
||
194 | * Returns the password. |
||
195 | * |
||
196 | * @return string password |
||
197 | */ |
||
198 | 6 | public function getPrivateKey() |
|
202 | |||
203 | /** |
||
204 | * Set the private key (string or path to local file). |
||
205 | * |
||
206 | * @param string $key |
||
207 | * |
||
208 | * @return $this |
||
209 | */ |
||
210 | 6 | public function setPrivateKey($key) |
|
216 | |||
217 | /** |
||
218 | * Returns the password. |
||
219 | * |
||
220 | * @return string password |
||
221 | */ |
||
222 | 6 | public function getPrivateKeyPass() |
|
226 | |||
227 | /** |
||
228 | * Set the password. |
||
229 | * |
||
230 | * @param string $password |
||
231 | * |
||
232 | * @return $this |
||
233 | */ |
||
234 | 6 | public function setPrivateKeyPass($privateKeyPass) |
|
240 | |||
241 | /** |
||
242 | * Returns the host. |
||
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | 6 | public function getHost() |
|
250 | |||
251 | /** |
||
252 | * Set the host. |
||
253 | * |
||
254 | * @param string $host |
||
255 | * |
||
256 | * @return $this |
||
257 | */ |
||
258 | 6 | public function setHost($host) |
|
264 | |||
265 | /** |
||
266 | * Returns the port. |
||
267 | * |
||
268 | * @return int |
||
269 | */ |
||
270 | 6 | public function getPort() |
|
274 | |||
275 | /** |
||
276 | * Set the port. |
||
277 | * |
||
278 | * @param int|string $port |
||
279 | * |
||
280 | * @return $this |
||
281 | */ |
||
282 | 6 | public function setPort($port) |
|
288 | |||
289 | /** |
||
290 | * Returns the amount of seconds before the connection will timeout. |
||
291 | * |
||
292 | * @return int |
||
293 | */ |
||
294 | 6 | public function getTimeout() |
|
298 | |||
299 | /** |
||
300 | * Set the amount of seconds before the connection should timeout. |
||
301 | * |
||
302 | * @param int $timeout |
||
303 | * |
||
304 | * @return $this |
||
305 | */ |
||
306 | 3 | public function setTimeout($timeout) |
|
312 | |||
313 | /** |
||
314 | * Returns the root folder to work from. |
||
315 | * |
||
316 | * @return string |
||
317 | */ |
||
318 | 3 | public function getRoot() |
|
322 | |||
323 | /** |
||
324 | * Set the root folder to work from. |
||
325 | * |
||
326 | * @param string $root |
||
327 | * |
||
328 | * @return $this |
||
329 | */ |
||
330 | 3 | public function setRoot($root) |
|
335 | |||
336 | /** |
||
337 | * Normalize a listing response. |
||
338 | * |
||
339 | * @param string $path |
||
340 | * @param array $object |
||
341 | * |
||
342 | * @return array |
||
343 | */ |
||
344 | 3 | protected function normalizeListingObject($path, array $object) |
|
361 | |||
362 | /** |
||
363 | * Check if a connection is active. |
||
364 | * |
||
365 | * @return bool |
||
366 | */ |
||
367 | abstract public function isConnected(); |
||
368 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: