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 |
||
12 | trait S3ContentsFileControllerTrait |
||
13 | { |
||
14 | /** |
||
15 | * s3Loader |
||
16 | * S3用のファイルローダー |
||
17 | * @author hagiwara |
||
18 | * @param string $filename |
||
19 | * @param string $filepath |
||
20 | * @return void |
||
21 | */ |
||
22 | private function s3Loader(string $filename, string $filepath): void |
||
44 | |||
45 | /** |
||
46 | * s3TmpFilePath |
||
47 | * S3のtmpのパス作成 |
||
48 | * @author hagiwara |
||
49 | * @param string $filename |
||
50 | * @return string |
||
51 | */ |
||
52 | private function s3TmpFilePath($filename): string |
||
56 | |||
57 | /** |
||
58 | * s3FilePath |
||
59 | * S3のファイルのパス作成 |
||
60 | * @author hagiwara |
||
61 | * @param Entity $attachmentData |
||
62 | * @return string |
||
63 | */ |
||
64 | View Code Duplication | private function s3FilePath(Entity $attachmentData): string |
|
76 | |||
77 | |||
78 | /** |
||
79 | * s3ResizeSet |
||
80 | * S3のリサイズ処理 |
||
81 | * @author hagiwara |
||
82 | * @param string $filepath |
||
83 | * @param array $resize |
||
84 | * @param string |
||
85 | */ |
||
86 | private function s3ResizeSet(string $filepath, array $resize): string |
||
108 | } |
||
109 |