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 |
||
| 23 | class MysqlDumper extends BaseDumper implements DumperInterface |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Path to mysqldump binary file. |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | public $mysqldumpPath = 'mysqldump'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Path to mysql binary file. |
||
| 34 | * |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | public $mysqlPath = 'mysql'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Path to store temporary defaults file. |
||
| 41 | * |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | public $defaultsFilePath = '@app/runtime'; |
||
| 45 | |||
| 46 | 18 | public function __construct(array $dsn, $username, $password) |
|
| 54 | |||
| 55 | /** |
||
| 56 | * Create defaults file with auth and some other params for MySQL client. |
||
| 57 | * |
||
| 58 | * Auth params plus all supported options from DSN will be stored this file. |
||
| 59 | * File name is randomized. |
||
| 60 | * |
||
| 61 | * Returns absolute path to file. |
||
| 62 | * |
||
| 63 | * @return string |
||
|
|
|||
| 64 | */ |
||
| 65 | 15 | protected function createMysqlDefaultsFile() |
|
| 103 | |||
| 104 | 15 | protected function runCommand($cmd) |
|
| 110 | |||
| 111 | 9 | View Code Duplication | public function dump($file) |
| 128 | |||
| 129 | 9 | View Code Duplication | public function restore($file) |
| 146 | } |
||
| 147 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.