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 |
||
| 35 | class CirclesController extends BaseController { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @NoAdminRequired |
||
| 39 | * @NoSubAdminRequired |
||
| 40 | * |
||
| 41 | * @param $type |
||
| 42 | * @param string $name |
||
| 43 | * |
||
| 44 | * @return DataResponse |
||
| 45 | */ |
||
| 46 | public function create($type, $name) { |
||
| 65 | |||
| 66 | |||
| 67 | /** |
||
| 68 | * @NoAdminRequired |
||
| 69 | * @NoSubAdminRequired |
||
| 70 | * |
||
| 71 | * @param $type |
||
| 72 | * @param string $name |
||
| 73 | * |
||
| 74 | * @return DataResponse |
||
| 75 | */ |
||
| 76 | public function list($type, $name = '') { |
||
| 88 | |||
| 89 | |||
| 90 | /** |
||
| 91 | * @NoAdminRequired |
||
| 92 | * @NoSubAdminRequired |
||
| 93 | * |
||
| 94 | * @param $id |
||
| 95 | * |
||
| 96 | * @return DataResponse |
||
| 97 | * @internal param string $name |
||
| 98 | * |
||
| 99 | */ |
||
| 100 | View Code Duplication | public function details($id) { |
|
| 111 | |||
| 112 | |||
| 113 | /** |
||
| 114 | * @NoAdminRequired |
||
| 115 | * @NoSubAdminRequired |
||
| 116 | * |
||
| 117 | * @param $id |
||
| 118 | * |
||
| 119 | * @return DataResponse |
||
| 120 | * @internal param string $name |
||
| 121 | * |
||
| 122 | */ |
||
| 123 | View Code Duplication | public function join($id) { |
|
| 133 | |||
| 134 | |||
| 135 | /** |
||
| 136 | * @NoAdminRequired |
||
| 137 | * @NoSubAdminRequired |
||
| 138 | * |
||
| 139 | * @param $id |
||
| 140 | * |
||
| 141 | * @return DataResponse |
||
| 142 | * @internal param string $name |
||
| 143 | * |
||
| 144 | */ |
||
| 145 | View Code Duplication | public function leave($id) { |
|
| 156 | |||
| 157 | |||
| 158 | /** |
||
| 159 | * Convert a Type in String to its Bit Value |
||
| 160 | * |
||
| 161 | * @param $type |
||
| 162 | * |
||
| 163 | * @return int |
||
| 164 | */ |
||
| 165 | public static function convertTypeStringToBitValue($type) { |
||
| 182 | |||
| 183 | } |
||
| 184 | |||
| 185 |