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 |
||
24 | class Jqadm |
||
25 | { |
||
26 | /** |
||
27 | * Returns the JS file content |
||
28 | * |
||
29 | * @param ContainerInterface $container Dependency injection container |
||
30 | * @param ServerRequestInterface $request Request object |
||
31 | * @param ResponseInterface $response Response object |
||
32 | * @param array $args Associative list of route parameters |
||
33 | * @return ResponseInterface $response Modified response object with generated output |
||
34 | */ |
||
35 | public static function fileAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
69 | |||
70 | |||
71 | /** |
||
72 | * Returns the HTML code for a copy of a resource object |
||
73 | * |
||
74 | * @param ContainerInterface $container Dependency injection container |
||
75 | * @param ServerRequestInterface $request Request object |
||
76 | * @param ResponseInterface $response Response object |
||
77 | * @param array $args Associative list of route parameters |
||
78 | * @return ResponseInterface $response Modified response object with generated output |
||
79 | */ |
||
80 | View Code Duplication | public static function copyAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
90 | |||
91 | |||
92 | /** |
||
93 | * Returns the HTML code for a new resource object |
||
94 | * |
||
95 | * @param ContainerInterface $container Dependency injection container |
||
96 | * @param ServerRequestInterface $request Request object |
||
97 | * @param ResponseInterface $response Response object |
||
98 | * @param array $args Associative list of route parameters |
||
99 | * @return ResponseInterface $response Modified response object with generated output |
||
100 | */ |
||
101 | View Code Duplication | public static function createAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
111 | |||
112 | |||
113 | /** |
||
114 | * Deletes the resource object or a list of resource objects |
||
115 | * |
||
116 | * @param ContainerInterface $container Dependency injection container |
||
117 | * @param ServerRequestInterface $request Request object |
||
118 | * @param ResponseInterface $response Response object |
||
119 | * @param array $args Associative list of route parameters |
||
120 | * @return ResponseInterface $response Modified response object with generated output |
||
121 | */ |
||
122 | View Code Duplication | public static function deleteAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
132 | |||
133 | |||
134 | /** |
||
135 | * Exports the requested resource object |
||
136 | * |
||
137 | * @param ContainerInterface $container Dependency injection container |
||
138 | * @param ServerRequestInterface $request Request object |
||
139 | * @param ResponseInterface $response Response object |
||
140 | * @param array $args Associative list of route parameters |
||
141 | * @return ResponseInterface $response Modified response object with generated output |
||
142 | */ |
||
143 | View Code Duplication | public static function exportAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
153 | |||
154 | |||
155 | /** |
||
156 | * Returns the HTML code for the requested resource object |
||
157 | * |
||
158 | * @param ContainerInterface $container Dependency injection container |
||
159 | * @param ServerRequestInterface $request Request object |
||
160 | * @param ResponseInterface $response Response object |
||
161 | * @param array $args Associative list of route parameters |
||
162 | * @return ResponseInterface $response Modified response object with generated output |
||
163 | */ |
||
164 | View Code Duplication | public static function getAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
174 | |||
175 | |||
176 | /** |
||
177 | * Saves a new resource object |
||
178 | * |
||
179 | * @param ContainerInterface $container Dependency injection container |
||
180 | * @param ServerRequestInterface $request Request object |
||
181 | * @param ResponseInterface $response Response object |
||
182 | * @param array $args Associative list of route parameters |
||
183 | * @return ResponseInterface $response Modified response object with generated output |
||
184 | */ |
||
185 | View Code Duplication | public static function saveAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
195 | |||
196 | |||
197 | /** |
||
198 | * Returns the HTML code for a list of resource objects |
||
199 | * |
||
200 | * @param ContainerInterface $container Dependency injection container |
||
201 | * @param ServerRequestInterface $request Request object |
||
202 | * @param ResponseInterface $response Response object |
||
203 | * @param array $args Associative list of route parameters |
||
204 | * @return ResponseInterface $response Modified response object with generated output |
||
205 | */ |
||
206 | View Code Duplication | public static function searchAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
|
216 | |||
217 | |||
218 | /** |
||
219 | * Returns the resource controller |
||
220 | * |
||
221 | * @param ContainerInterface $container Dependency injection container |
||
222 | * @param ServerRequestInterface $request Request object |
||
223 | * @param ResponseInterface $response Response object |
||
224 | * @param array $args Associative list of route parameters |
||
225 | * @return \Aimeos\Admin\JQAdm\Iface JQAdm client |
||
226 | */ |
||
227 | protected static function createClient( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
246 | |||
247 | |||
248 | /** |
||
249 | * Returns the generated HTML code |
||
250 | * |
||
251 | * @param ContainerInterface $container Dependency injection container |
||
252 | * @param ResponseInterface $response Response object |
||
253 | * @param string $content Content from admin client |
||
254 | * @return \Illuminate\Contracts\View\View View for rendering the output |
||
255 | */ |
||
256 | protected static function getHtml( ContainerInterface $container, ResponseInterface $response, $content ) |
||
264 | } |
||
265 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.