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 |
||
| 21 | class Ftp extends Xtp implements Simulator |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Setup the Ftp sync. |
||
| 25 | * |
||
| 26 | * @param array $config |
||
| 27 | * @throws \phpbu\App\Backup\Sync\Exception |
||
| 28 | */ |
||
| 29 | 6 | public function setup(array $config) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Check for required loaded libraries or extensions. |
||
| 40 | * |
||
| 41 | * @throws \phpbu\App\Backup\Sync\Exception |
||
| 42 | */ |
||
| 43 | 5 | protected function checkRequirements() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Return implemented (*)TP protocol name. |
||
| 52 | * |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | 1 | protected function getProtocolName() |
|
| 59 | |||
| 60 | /** |
||
| 61 | * (non-PHPDoc) |
||
| 62 | * |
||
| 63 | * @see \phpbu\App\Backup\Sync::sync() |
||
| 64 | * @param \phpbu\App\Backup\Target $target |
||
| 65 | * @param \phpbu\App\Result $result |
||
| 66 | * @throws \phpbu\App\Backup\Sync\Exception |
||
| 67 | */ |
||
| 68 | public function sync(Target $target, Result $result) |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Execute the remote clean up if needed |
||
| 121 | * |
||
| 122 | * @param \phpbu\App\Backup\Target $target |
||
| 123 | * @param \phpbu\App\Result $result |
||
| 124 | */ |
||
| 125 | public function cleanup(Target $target, Result $result) |
||
| 129 | } |
||
| 130 |