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() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * normalFileSave |
||
| 44 | * ファイルを保存 |
||
| 45 | * @author hagiwara |
||
| 46 | * @param array $fileInfo |
||
| 47 | * @param array $fieldSettings |
||
| 48 | * @param array $attachmentSaveData |
||
| 49 | */ |
||
| 50 | private function normalFileSave($fileInfo, $fieldSettings, $attachmentSaveData) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * normalFileDelete |
||
| 78 | * 通常のファイル削除 |
||
| 79 | * @author hagiwara |
||
| 80 | * @param string $modelName |
||
| 81 | * @param integer $modelId |
||
| 82 | * @param string $field |
||
| 83 | */ |
||
| 84 | private function normalFileDelete($modelName, $modelId, $field) |
||
| 102 | |||
| 103 | /** |
||
| 104 | * normalImageResize |
||
| 105 | * 通常のファイルのリサイズ |
||
| 106 | * @author hagiwara |
||
| 107 | * @param string $newFilepath |
||
| 108 | * @param array $resizeSettings |
||
| 109 | */ |
||
| 110 | private function normalImageResize($newFilepath, $resizeSettings) |
||
| 114 | } |
||
| 115 |