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 | public static function copyAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 85 | |||
| 86 | |||
| 87 | /** |
||
| 88 | * Returns the HTML code for a new resource object |
||
| 89 | * |
||
| 90 | * @param ContainerInterface $container Dependency injection container |
||
| 91 | * @param ServerRequestInterface $request Request object |
||
| 92 | * @param ResponseInterface $response Response object |
||
| 93 | * @param array $args Associative list of route parameters |
||
| 94 | * @return ResponseInterface $response Modified response object with generated output |
||
| 95 | */ |
||
| 96 | public static function createAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 101 | |||
| 102 | |||
| 103 | /** |
||
| 104 | * Deletes the resource object or a list of resource objects |
||
| 105 | * |
||
| 106 | * @param ContainerInterface $container Dependency injection container |
||
| 107 | * @param ServerRequestInterface $request Request object |
||
| 108 | * @param ResponseInterface $response Response object |
||
| 109 | * @param array $args Associative list of route parameters |
||
| 110 | * @return ResponseInterface $response Modified response object with generated output |
||
| 111 | */ |
||
| 112 | public static function deleteAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 117 | |||
| 118 | |||
| 119 | /** |
||
| 120 | * Returns the HTML code for the requested resource object |
||
| 121 | * |
||
| 122 | * @param ContainerInterface $container Dependency injection container |
||
| 123 | * @param ServerRequestInterface $request Request object |
||
| 124 | * @param ResponseInterface $response Response object |
||
| 125 | * @param array $args Associative list of route parameters |
||
| 126 | * @return ResponseInterface $response Modified response object with generated output |
||
| 127 | */ |
||
| 128 | public static function getAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 133 | |||
| 134 | |||
| 135 | /** |
||
| 136 | * Saves a new resource object |
||
| 137 | * |
||
| 138 | * @param ContainerInterface $container Dependency injection container |
||
| 139 | * @param ServerRequestInterface $request Request object |
||
| 140 | * @param ResponseInterface $response Response object |
||
| 141 | * @param array $args Associative list of route parameters |
||
| 142 | * @return ResponseInterface $response Modified response object with generated output |
||
| 143 | */ |
||
| 144 | public static function saveAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 149 | |||
| 150 | |||
| 151 | /** |
||
| 152 | * Returns the HTML code for a list of resource objects |
||
| 153 | * |
||
| 154 | * @param ContainerInterface $container Dependency injection container |
||
| 155 | * @param ServerRequestInterface $request Request object |
||
| 156 | * @param ResponseInterface $response Response object |
||
| 157 | * @param array $args Associative list of route parameters |
||
| 158 | * @return ResponseInterface $response Modified response object with generated output |
||
| 159 | */ |
||
| 160 | public static function searchAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 165 | |||
| 166 | |||
| 167 | /** |
||
| 168 | * Returns the resource controller |
||
| 169 | * |
||
| 170 | * @param ContainerInterface $container Dependency injection container |
||
| 171 | * @param ServerRequestInterface $request Request object |
||
| 172 | * @param ResponseInterface $response Response object |
||
| 173 | * @param array $args Associative list of route parameters |
||
| 174 | * @return \Aimeos\Admin\JQAdm\Iface JQAdm client |
||
| 175 | */ |
||
| 176 | protected static function createClient( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args ) |
||
| 192 | |||
| 193 | |||
| 194 | /** |
||
| 195 | * Returns the generated HTML code |
||
| 196 | * |
||
| 197 | * @param ContainerInterface $container Dependency injection container |
||
| 198 | * @param ResponseInterface $response Response object |
||
| 199 | * @param string $content Content from admin client |
||
| 200 | * @return \Illuminate\Contracts\View\View View for rendering the output |
||
| 201 | */ |
||
| 202 | protected static function getHtml( ContainerInterface $container, ResponseInterface $response, $content ) |
||
| 209 | |||
| 210 | |||
| 211 | /** |
||
| 212 | * Sets the locale item in the given context |
||
| 213 | * |
||
| 214 | * @param \Aimeos\Slim\Base\I18n $i18n Aimeos translation object builder |
||
| 215 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
||
| 216 | * @param string $site Unique site code |
||
| 217 | * @param string $lang ISO language code, e.g. "en" or "en_GB" |
||
| 218 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
||
| 219 | */ |
||
| 220 | View Code Duplication | protected static function setLocale( \Aimeos\Slim\Base\I18n $i18n, \Aimeos\MShop\Context\Item\Iface $context, $site, $lang ) |
|
| 240 | } |
||
| 241 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.