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 |
||
16 | class DefaultController extends ContainerAware |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * @return Response |
||
20 | */ |
||
21 | public function indexAction() |
||
25 | |||
26 | /** |
||
27 | * @param string $feature |
||
28 | * @return RedirectResponse |
||
29 | */ |
||
30 | public function activateAction($feature) |
||
38 | |||
39 | /** |
||
40 | * @param string $feature |
||
41 | * @return RedirectResponse |
||
42 | */ |
||
43 | public function deactivateAction($feature) |
||
51 | |||
52 | /** |
||
53 | * @param string $feature |
||
54 | * @return RedirectResponse |
||
55 | */ |
||
56 | View Code Duplication | public function incrementPercentageAction($feature) |
|
66 | |||
67 | /** |
||
68 | * @param string $feature |
||
69 | * @return RedirectResponse |
||
70 | */ |
||
71 | View Code Duplication | public function decrementPercentageAction($feature) |
|
81 | |||
82 | /** |
||
83 | * @param string $feature |
||
84 | * @param string $group |
||
85 | * @return RedirectResponse |
||
86 | */ |
||
87 | View Code Duplication | public function activateGroupAction($feature, $group) |
|
95 | |||
96 | /** |
||
97 | * @param string $feature |
||
98 | * @param string $group |
||
99 | * @return RedirectResponse |
||
100 | */ |
||
101 | View Code Duplication | public function deactivateGroupAction($feature, $group) |
|
109 | |||
110 | /** |
||
111 | * @param Request $request |
||
112 | * @param string $feature |
||
113 | * @return RedirectResponse |
||
114 | */ |
||
115 | public function activateUserAction(Request $request, $feature) |
||
130 | |||
131 | /** |
||
132 | * @param string $feature |
||
133 | * @param string $id |
||
134 | * @return RedirectResponse |
||
135 | */ |
||
136 | public function deactivateUserAction($feature, $id) |
||
145 | |||
146 | /** |
||
147 | * @param string $feature |
||
148 | * @return RedirectResponse |
||
149 | */ |
||
150 | public function removeAction($feature) |
||
158 | |||
159 | /** |
||
160 | * @param Request $request |
||
161 | * @param string $feature |
||
162 | * @return RedirectResponse |
||
163 | */ |
||
164 | public function setRequestParamAction(Request $request, $feature) |
||
178 | |||
179 | /** |
||
180 | * @return Rollout |
||
181 | */ |
||
182 | private function getRollout() |
||
186 | |||
187 | /** |
||
188 | * @return UserProviderInterface |
||
189 | */ |
||
190 | private function getRolloutUserProvider() |
||
194 | |||
195 | /** |
||
196 | * Helper for adding flash messages |
||
197 | * |
||
198 | * @param string $type |
||
199 | * @param string $message |
||
200 | */ |
||
201 | private function addFlash($type, $message) |
||
205 | |||
206 | /** |
||
207 | * @return RedirectResponse |
||
208 | */ |
||
209 | private function createRedirectToFeatureListReponse() |
||
213 | } |
||
214 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.