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 |
||
| 14 | trait NormalContentsFileBehaviorTrait |
||
| 15 | { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * normalParamCheck |
||
| 19 | * 通常の設定値チェック |
||
| 20 | * @author hagiwara |
||
| 21 | */ |
||
| 22 | private function normalParamCheck() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * normalFileSave |
||
| 37 | * ファイルを保存 |
||
| 38 | * @author hagiwara |
||
| 39 | * @param array $fileInfo |
||
| 40 | * @param array $fieldSettings |
||
| 41 | * @param array $attachmentSaveData |
||
| 42 | */ |
||
| 43 | private function normalFileSave($fileInfo, $fieldSettings, $attachmentSaveData) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * normalFileDelete |
||
| 71 | * 通常のファイル削除 |
||
| 72 | * @author hagiwara |
||
| 73 | * @param string $modelName |
||
| 74 | * @param integer $modelId |
||
| 75 | * @param string $field |
||
| 76 | */ |
||
| 77 | private function normalFileDelete($modelName, $modelId, $field) |
||
| 95 | |||
| 96 | /** |
||
| 97 | * normalImageResize |
||
| 98 | * 通常のファイルのリサイズ |
||
| 99 | * @author hagiwara |
||
| 100 | * @param string $newFilepath |
||
| 101 | * @param array $resizeSettings |
||
| 102 | */ |
||
| 103 | private function normalImageResize($newFilepath, $resizeSettings) |
||
| 107 | } |
||
| 108 |