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 | * Setup the Ftp sync. |
||
| 22 | * |
||
| 23 | * @param array $config |
||
| 24 | * @throws \phpbu\App\Backup\Sync\Exception |
||
| 25 | */ |
||
| 26 | 6 | public function setup(array $config) |
|
| 34 | |||
| 35 | /** |
||
| 36 | * Check for required loaded libraries or extensions. |
||
| 37 | * |
||
| 38 | * @throws \phpbu\App\Backup\Sync\Exception |
||
| 39 | */ |
||
| 40 | 5 | protected function checkRequirements() |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Return implemented (*)TP protocol name. |
||
| 49 | * |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | 1 | protected function getProtocolName() |
|
| 56 | |||
| 57 | /** |
||
| 58 | * (non-PHPDoc) |
||
| 59 | * |
||
| 60 | * @see \phpbu\App\Backup\Sync::sync() |
||
| 61 | * @param \phpbu\App\Backup\Target $target |
||
| 62 | * @param \phpbu\App\Result $result |
||
| 63 | * @throws \phpbu\App\Backup\Sync\Exception |
||
| 64 | */ |
||
| 65 | public function sync(Target $target, Result $result) |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Execute the remote clean up if needed |
||
| 118 | * |
||
| 119 | * @param \phpbu\App\Backup\Target $target |
||
| 120 | * @param \phpbu\App\Result $result |
||
| 121 | */ |
||
| 122 | public function cleanup(Target $target, Result $result) |
||
| 126 | } |
||
| 127 |