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 |
||
22 | class YandexDisk extends Remote implements Collector |
||
23 | { |
||
24 | /** |
||
25 | * @var Disk |
||
26 | */ |
||
27 | protected $disk; |
||
28 | |||
29 | /** |
||
30 | * OpenStack constructor. |
||
31 | * |
||
32 | * @param Target $target |
||
33 | * @param Path $path |
||
34 | * @param Disk $disk |
||
35 | */ |
||
36 | 2 | public function __construct(Target $target, Path $path, Disk $disk) |
|
41 | |||
42 | /** |
||
43 | * Collect all created backups. |
||
44 | */ |
||
45 | 2 | protected function collectBackups() |
|
56 | } |
||
57 |