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