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 |
||
15 | abstract class AbstractUserCommand extends ContainerAwareCommand |
||
|
|||
16 | { |
||
17 | /** |
||
18 | * @return UserManagerInterface |
||
19 | */ |
||
20 | protected function getUserManager() |
||
24 | |||
25 | /** |
||
26 | * @return QuestionHelper |
||
27 | */ |
||
28 | protected function getQuestionHelper() |
||
32 | |||
33 | protected function printUser(User $user, OutputInterface $output) |
||
46 | |||
47 | /** |
||
48 | * @param InputInterface $input |
||
49 | * @param OutputInterface $output |
||
50 | * |
||
51 | * @return mixed |
||
52 | */ |
||
53 | protected function createUser(InputInterface $input, OutputInterface $output) |
||
72 | |||
73 | /** |
||
74 | * @param OutputInterface $output |
||
75 | * @param User[] $users |
||
76 | */ |
||
77 | protected function printUserTable(OutputInterface $output, $users) |
||
97 | |||
98 | /** |
||
99 | * @param InputInterface $input |
||
100 | * @param OutputInterface $output |
||
101 | * @param User $user |
||
102 | * @param QuestionHelper $questionHelper |
||
103 | * |
||
104 | * @return User |
||
105 | */ |
||
106 | View Code Duplication | protected function editUsername( |
|
127 | |||
128 | /** |
||
129 | * @param InputInterface $input |
||
130 | * @param OutputInterface $output |
||
131 | * @param User $user |
||
132 | * @param QuestionHelper $questionHelper |
||
133 | * |
||
134 | * @return User |
||
135 | */ |
||
136 | View Code Duplication | protected function editRealName( |
|
157 | |||
158 | /** |
||
159 | * @param InputInterface $input |
||
160 | * @param OutputInterface $output |
||
161 | * @param User $user |
||
162 | * @param QuestionHelper $questionHelper |
||
163 | * |
||
164 | * @return User |
||
165 | */ |
||
166 | View Code Duplication | protected function editEmail( |
|
187 | |||
188 | /** |
||
189 | * @param InputInterface $input |
||
190 | * @param OutputInterface $output |
||
191 | * @param User $user |
||
192 | * @param QuestionHelper $questionHelper |
||
193 | * |
||
194 | * @return User |
||
195 | */ |
||
196 | protected function editRole( |
||
211 | |||
212 | /** |
||
213 | * @param InputInterface $input |
||
214 | * @param OutputInterface $output |
||
215 | * @param User $user |
||
216 | * @param QuestionHelper $questionHelper |
||
217 | * @param UserManagerInterface $userManager |
||
218 | * |
||
219 | * @return User |
||
220 | */ |
||
221 | protected function editPassword( |
||
243 | |||
244 | /** |
||
245 | * @param InputInterface $input |
||
246 | * @param OutputInterface $output |
||
247 | * @param User $user |
||
248 | * @param QuestionHelper $questionHelper |
||
249 | * |
||
250 | * @return User |
||
251 | */ |
||
252 | View Code Duplication | protected function editGithubId( |
|
263 | |||
264 | /** |
||
265 | * @param InputInterface $input |
||
266 | * @param OutputInterface $output |
||
267 | * @param User $user |
||
268 | * @param QuestionHelper $questionHelper |
||
269 | * |
||
270 | * @return User |
||
271 | */ |
||
272 | View Code Duplication | protected function editGoogleId( |
|
283 | |||
284 | /** |
||
285 | * @param InputInterface $input |
||
286 | * @param OutputInterface $output |
||
287 | * |
||
288 | * @return User |
||
289 | */ |
||
290 | protected function selectUser(InputInterface $input, OutputInterface $output): User |
||
309 | |||
310 | /** |
||
311 | * @return User[] |
||
312 | */ |
||
313 | protected function findUsers() |
||
321 | } |
||
322 |
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.