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 |
||
| 31 | class MembersController extends BaseController { |
||
| 32 | |||
| 33 | |||
| 34 | /** |
||
| 35 | * @NoAdminRequired |
||
| 36 | * @NoSubAdminRequired |
||
| 37 | * |
||
| 38 | * @param $id |
||
| 39 | * @param string $name |
||
| 40 | * |
||
| 41 | * @return DataResponse |
||
| 42 | */ |
||
| 43 | public function add($id, $name) { |
||
| 65 | |||
| 66 | |||
| 67 | /** |
||
| 68 | * @NoAdminRequired |
||
| 69 | * @NoSubAdminRequired |
||
| 70 | * |
||
| 71 | * @param $id |
||
| 72 | * @param $member |
||
| 73 | * @param $level |
||
| 74 | * |
||
| 75 | * @return DataResponse |
||
| 76 | * @internal param string $name |
||
| 77 | */ |
||
| 78 | public function level($id, $member, $level) { |
||
| 103 | |||
| 104 | |||
| 105 | /** |
||
| 106 | * @NoAdminRequired |
||
| 107 | * @NoSubAdminRequired |
||
| 108 | * |
||
| 109 | * @param $id |
||
| 110 | * @param $member |
||
| 111 | * |
||
| 112 | * @return DataResponse |
||
| 113 | * @internal param string $name |
||
| 114 | * |
||
| 115 | */ |
||
| 116 | View Code Duplication | public function remove($id, $member) { |
|
| 139 | |||
| 140 | |||
| 141 | } |
||
| 142 | |||
| 143 |