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 |
||
| 19 | class EccubeMonologListener implements EventSubscriberInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @param GetResponseEvent $event |
||
| 23 | */ |
||
| 24 | public function onKernelRequestEarly(GetResponseEvent $event) |
||
| 32 | |||
| 33 | 462 | /** |
|
| 34 | 462 | * @param GetResponseEvent $event |
|
| 35 | */ |
||
| 36 | View Code Duplication | public function onKernelRequest(GetResponseEvent $event) |
|
| 45 | |||
| 46 | /** |
||
| 47 | 457 | * @param FilterControllerEvent $event |
|
| 48 | 457 | */ |
|
| 49 | View Code Duplication | public function onKernelController(FilterControllerEvent $event) |
|
| 58 | |||
| 59 | /** |
||
| 60 | * @param FilterResponseEvent $event |
||
| 61 | */ |
||
| 62 | View Code Duplication | public function onKernelResponse(FilterResponseEvent $event) |
|
| 71 | |||
| 72 | /** |
||
| 73 | * @param PostResponseEvent $event |
||
| 74 | 17 | */ |
|
| 75 | public function onKernelTerminate(PostResponseEvent $event) |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param GetResponseForExceptionEvent $event |
||
| 83 | */ |
||
| 84 | 462 | public function onKernelException(GetResponseForExceptionEvent $event) |
|
| 101 | |||
| 102 | /** |
||
| 103 | * {@inheritdoc} |
||
| 104 | */ |
||
| 105 | public static function getSubscribedEvents() |
||
| 125 | 17 | ||
| 126 | 13 | /** |
|
| 127 | * ルーティング名を取得する. |
||
| 128 | 13 | * |
|
| 129 | 4 | * @param $request |
|
| 130 | 4 | * @return string |
|
| 131 | 4 | */ |
|
| 132 | 4 | private function getRoute($request) |
|
| 136 | } |
||
| 137 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.