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 AmazonS3v3 extends Collector |
||
23 | { |
||
24 | /** |
||
25 | * @var \Aws\S3\S3Client |
||
26 | */ |
||
27 | protected $client; |
||
28 | |||
29 | /** |
||
30 | * Amazon S3 bucket name |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $bucket; |
||
35 | |||
36 | /** |
||
37 | * Amazon S3 constructor. |
||
38 | * |
||
39 | * @param \phpbu\App\Backup\Target $target |
||
40 | * @param S3Client $client |
||
41 | * @param string $bucket |
||
42 | * @param string $path |
||
43 | * @param int $time |
||
44 | */ |
||
45 | 1 | public function __construct(Target $target, S3Client $client, string $bucket, string $path, int $time) |
|
52 | |||
53 | /** |
||
54 | * Get all created backups. |
||
55 | * |
||
56 | * @return \phpbu\App\Backup\File[] |
||
57 | */ |
||
58 | 1 | public function getBackupFiles() : array |
|
81 | |||
82 | /** |
||
83 | * Return prefix for querying remote files and folders |
||
84 | * |
||
85 | * @param string|null $path |
||
86 | * @return string |
||
87 | */ |
||
88 | 1 | protected function getPrefix($path = null): string |
|
95 | } |
||
96 |