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 |
||
18 | class Ftp extends Xtp implements Simulator |
||
19 | { |
||
20 | /** |
||
21 | * Determine should ftp connects via passive mode. |
||
22 | * |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $passiveMode; |
||
26 | |||
27 | /** |
||
28 | 6 | * Setup the Ftp sync. |
|
29 | * |
||
30 | 6 | * @param array $config |
|
31 | 6 | * @throws \phpbu\App\Backup\Sync\Exception |
|
32 | 1 | */ |
|
33 | public function setup(array $config) |
||
43 | |||
44 | 5 | /** |
|
45 | * Check for required loaded libraries or extensions. |
||
46 | * |
||
47 | 5 | * @throws \phpbu\App\Backup\Sync\Exception |
|
48 | */ |
||
49 | protected function checkRequirements() |
||
55 | |||
56 | 1 | /** |
|
57 | * Return implemented (*)TP protocol name. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | protected function getProtocolName() |
||
65 | |||
66 | /** |
||
67 | * (non-PHPDoc) |
||
68 | * |
||
69 | * @see \phpbu\App\Backup\Sync::sync() |
||
70 | * @param \phpbu\App\Backup\Target $target |
||
71 | * @param \phpbu\App\Result $result |
||
72 | * @throws \phpbu\App\Backup\Sync\Exception |
||
73 | */ |
||
74 | public function sync(Target $target, Result $result) |
||
127 | |||
128 | /** |
||
129 | * Execute the remote clean up if needed |
||
130 | * |
||
131 | * @param \phpbu\App\Backup\Target $target |
||
132 | * @param \phpbu\App\Result $result |
||
133 | */ |
||
134 | public function cleanup(Target $target, Result $result) |
||
138 | } |
||
139 |