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