1 | <?php |
||
25 | class ServiceAdapter extends AbstractServiceAdapter |
||
26 | { |
||
27 | /** @var resource */ |
||
28 | private $connectionId = null; |
||
29 | |||
30 | /** |
||
31 | * Disconnected by garbage collection. |
||
32 | */ |
||
33 | public function __destruct() |
||
37 | |||
38 | /** |
||
39 | * Connect and login to remote host. |
||
40 | * |
||
41 | * @return ServiceInterface |
||
42 | */ |
||
43 | public function connect() : ServiceInterface |
||
66 | |||
67 | /** |
||
68 | * Disconnect from remote host. |
||
69 | * |
||
70 | * @return ServiceInterface |
||
71 | */ |
||
72 | public function disconnect() : ServiceInterface |
||
79 | |||
80 | /** |
||
81 | * Toggles connection security level. |
||
82 | * |
||
83 | * @param bool $state |
||
84 | * @return ServiceInterface |
||
85 | */ |
||
86 | public function setSecureConnection(bool $state) : ServiceInterface |
||
98 | |||
99 | /** |
||
100 | * Toggles connection passive mode. |
||
101 | * |
||
102 | * @param bool $state |
||
103 | * @return ServiceInterface |
||
104 | */ |
||
105 | public function setPassiveMode(bool $state) : ServiceInterface |
||
110 | |||
111 | /** |
||
112 | * Sets remote path. |
||
113 | * |
||
114 | * @param string $path |
||
115 | * @return ServiceInterface |
||
116 | */ |
||
117 | public function setRemotePath(string $path) : ServiceInterface |
||
135 | |||
136 | /** |
||
137 | * Gets remote path. |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getRemotePath() : string |
||
145 | |||
146 | /** |
||
147 | * Lists remote path. |
||
148 | * |
||
149 | * @param null|string $path |
||
150 | * @param bool|null $changeToDirectory |
||
151 | * @return array |
||
152 | */ |
||
153 | public function getRemoteFileList(? string $path, ? bool $changeToDirectory) : array |
||
196 | |||
197 | /** |
||
198 | * @param string $fileData |
||
199 | * @return string |
||
200 | */ |
||
201 | private function getFileType(string $fileData) : string |
||
218 | |||
219 | /** |
||
220 | * @param array $fileData |
||
221 | * @return string |
||
222 | */ |
||
223 | private function getFileDate(array $fileData) : string |
||
235 | |||
236 | /** |
||
237 | * Uploads file to remote host. |
||
238 | * |
||
239 | * @see self::setRemotePath |
||
240 | * @see self::setLocalPath |
||
241 | * |
||
242 | * @param string $sourceFileName |
||
243 | * @param string $destinationFileName |
||
244 | * @param int $fileMode |
||
245 | * @return mixed |
||
246 | */ |
||
247 | public function upload( |
||
272 | |||
273 | /** |
||
274 | * Downloads file from remote host. |
||
275 | * |
||
276 | * @see self::setRemotePath |
||
277 | * @see self::setLocalPath |
||
278 | * |
||
279 | * @param string $remoteFileName |
||
280 | * @param string $localFileName |
||
281 | * @param int $fileMode |
||
282 | * @return mixed |
||
283 | */ |
||
284 | public function download( |
||
308 | |||
309 | /** |
||
310 | * Check remote file name. |
||
311 | * |
||
312 | * @param string $remoteFileName |
||
313 | */ |
||
314 | protected function checkRemoteFile(string&$remoteFileName) : void |
||
323 | |||
324 | /** |
||
325 | * Moves file on remote host. |
||
326 | * |
||
327 | * @param string $currentPath |
||
328 | * @param string $newPath |
||
329 | * @return ServiceInterface |
||
330 | */ |
||
331 | public function moveRemoteFile(string $currentPath, string $newPath) : ServiceInterface |
||
344 | |||
345 | /** |
||
346 | * Deletes file on remote host. |
||
347 | * |
||
348 | * @param string $path |
||
349 | * @return ServiceInterface |
||
350 | */ |
||
351 | public function deleteRemoteFile(string $path) : ServiceInterface |
||
361 | } |
||
362 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.