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 |
||
| 3 | class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin |
||
| 4 | { |
||
| 5 | /** |
||
| 6 | * @return void |
||
| 7 | */ |
||
| 8 | public function Init() |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return array |
||
| 19 | */ |
||
| 20 | View Code Duplication | protected function configMapping() |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function FilterAppData($bAdmin, &$aResult) |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return void |
||
| 44 | */ |
||
| 45 | public function FilterActionParams($sMethodName, &$aActionParams) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param \RainLoop\Model\Account $oAccount |
||
| 58 | * |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | public function isDemoAccount($oAccount) |
||
| 65 | |||
| 66 | public function AjaxActionPreCall($sAction) |
||
| 74 | |||
| 75 | public function FilterSendMessage(&$oMessage) |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param string $sName |
||
| 85 | * @param mixed $oDriver |
||
| 86 | */ |
||
| 87 | public function MainFabrica($sName, &$oDriver) |
||
| 106 | } |
||
| 107 | |||
| 108 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.