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 |
||
| 10 | class OpenStack extends Collector |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Container |
||
| 14 | */ |
||
| 15 | protected $container; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Path where to search for backup files |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $path; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * OpenStack constructor. |
||
| 26 | * |
||
| 27 | * @param \phpbu\App\Backup\Target $target |
||
| 28 | * @param Container $container |
||
| 29 | * @param string $path |
||
| 30 | */ |
||
| 31 | public function __construct(Target $target, Container $container, string $path) |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get all created backups. |
||
| 40 | * |
||
| 41 | * @return \phpbu\App\Backup\File[] |
||
| 42 | */ |
||
| 43 | public function getBackupFiles(): array |
||
| 64 | } |
||
| 65 |