Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
19 | class Sftp extends Xtp implements Simulator |
||
20 | { |
||
21 | /** |
||
22 | * Check for required loaded libraries or extensions. |
||
23 | * |
||
24 | * @throws \phpbu\App\Backup\Sync\Exception |
||
25 | */ |
||
26 | protected function checkRequirements() |
||
32 | |||
33 | /** |
||
34 | * Return implemented (*)TP protocol name. |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | protected function getProtocolName() |
||
42 | |||
43 | /** |
||
44 | * (non-PHPDoc) |
||
45 | * |
||
46 | * @see \phpbu\App\Backup\Sync::sync() |
||
47 | * @param \phpbu\App\Backup\Target $target |
||
48 | * @param \phpbu\App\Result $result |
||
49 | * @throws \phpbu\App\Backup\Sync\Exception |
||
50 | */ |
||
51 | public function sync(Target $target, Result $result) |
||
73 | 1 | ||
74 | 1 | /** |
|
75 | * Create a sftp handle. |
||
76 | * |
||
77 | 1 | * @return \phpseclib\Net\SFTP |
|
78 | 1 | * @throws \phpbu\App\Backup\Sync\Exception |
|
79 | 1 | */ |
|
80 | 1 | private function login() : phpseclib\Net\SFTP |
|
101 | |||
102 | /** |
||
103 | * Return list of remote directories to travers. |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | private function getRemoteDirectoryList() : array |
||
115 | } |
||
116 |