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 |
||
20 | class Ftp extends Xtp implements Simulator |
||
21 | { |
||
22 | /** |
||
23 | * Setup the Ftp sync. |
||
24 | * |
||
25 | * @param array $config |
||
26 | * @throws \phpbu\App\Backup\Sync\Exception |
||
27 | */ |
||
28 | public function setup(array $config) |
||
36 | |||
37 | /** |
||
38 | * Check for required loaded libraries or extensions. |
||
39 | * |
||
40 | * @throws \phpbu\App\Backup\Sync\Exception |
||
41 | */ |
||
42 | protected function checkRequirements() |
||
48 | |||
49 | /** |
||
50 | 5 | * Return implemented (*)TP protocol name. |
|
51 | * |
||
52 | 5 | * @return string |
|
53 | */ |
||
54 | protected function getProtocolName() |
||
58 | 4 | ||
59 | 1 | /** |
|
60 | * (non-PHPDoc) |
||
61 | 3 | * |
|
62 | 1 | * @see \phpbu\App\Backup\Sync::sync() |
|
63 | * @param \phpbu\App\Backup\Target $target |
||
64 | 2 | * @param \phpbu\App\Result $result |
|
65 | 2 | * @throws \phpbu\App\Backup\Sync\Exception |
|
66 | 1 | */ |
|
67 | public function sync(Target $target, Result $result) |
||
117 | } |
||
118 |