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 PreProductionVersionWarning extends Middleware |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * converts a Request to a Response |
||
27 | * |
||
28 | * @param RequestInterface $request |
||
29 | * @param ResponseInterface $response |
||
30 | * @return ResponseInterface |
||
31 | */ |
||
32 | View Code Duplication | public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
40 | |||
41 | |||
42 | |||
43 | /** |
||
44 | * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | public function displayPreProductionVersionWarning() |
||
69 | |||
70 | |||
71 | |||
72 | /** |
||
73 | * displays admin notice that current version of EE is not a stable release |
||
74 | * |
||
75 | * @return void |
||
76 | * @throws InvalidDataTypeException |
||
77 | */ |
||
78 | public function preProductionVersionAdminNotice() |
||
85 | |||
86 | |||
87 | /** |
||
88 | * displays message on frontend of site notifying admin that current version of EE is not a stable release |
||
89 | * |
||
90 | * @return void |
||
91 | */ |
||
92 | public function preProductionVersionWarningNotice() |
||
98 | |||
99 | |||
100 | /** |
||
101 | * @return string |
||
102 | */ |
||
103 | private function warningNotice() |
||
114 | |||
115 | } |
||
116 | // Location: NonProductionReadyVersionWarning.php |
||
117 |