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 |
||
| 22 | class SidebarController extends Controller |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Avatar user panel |
||
| 26 | * @return Response |
||
| 27 | */ |
||
| 28 | View Code Duplication | public function userPanelAction() |
|
| 43 | |||
| 44 | /** |
||
| 45 | * User inbox, profile links |
||
| 46 | * @return Response |
||
| 47 | */ |
||
| 48 | /*public function userProfileAction() |
||
| 49 | { |
||
| 50 | if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_SIDEBAR_USER)) { |
||
| 51 | return new Response(); |
||
| 52 | } |
||
| 53 | |||
| 54 | $userEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_SIDEBAR_USER, new ShowUserEvent()); |
||
| 55 | |||
| 56 | return $this->render( |
||
| 57 | 'ChamiloThemeBundle:Sidebar:user-profile.html.twig', |
||
| 58 | array( |
||
| 59 | 'user' => $userEvent->getUser() |
||
| 60 | ) |
||
| 61 | ); |
||
| 62 | }*/ |
||
| 63 | |||
| 64 | /** |
||
| 65 | * User social network section |
||
| 66 | * @return Response |
||
| 67 | */ |
||
| 68 | View Code Duplication | public function socialPanelAction() |
|
| 83 | |||
| 84 | /** |
||
| 85 | * Search bar |
||
| 86 | * @return Response |
||
| 87 | */ |
||
| 88 | public function searchFormAction() |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @return EventDispatcher |
||
| 95 | */ |
||
| 96 | protected function getDispatcher() |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @param Request $request |
||
| 103 | * @return Response |
||
| 104 | */ |
||
| 105 | public function leftMenuAction(Request $request) |
||
| 124 | } |
||
| 125 |