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 |
||
| 21 | class DetectFileEditorRequest extends Middleware |
||
| 22 | { |
||
| 23 | |||
| 24 | /** |
||
| 25 | * converts a Request to a Response |
||
| 26 | * |
||
| 27 | * @param RequestInterface $request |
||
| 28 | * @param ResponseInterface $response |
||
| 29 | * @return ResponseInterface |
||
| 30 | */ |
||
| 31 | View Code Duplication | public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 41 | |||
| 42 | |||
| 43 | /** |
||
| 44 | * This sets any filters that need set on this request. |
||
| 45 | */ |
||
| 46 | protected function setFiltersForRequest() |
||
| 50 | |||
| 51 | |||
| 52 | /** |
||
| 53 | * Conditions for a "file editor request" |
||
| 54 | * |
||
| 55 | * @see wp-admin/includes/file.php |
||
| 56 | * The file editor does a loopback request to the admin AND to the frontend when checking active theme or |
||
| 57 | * active plugin edits. So these conditions consider that. |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | protected function isFileEditorRequest() |
||
| 65 | } |
||
| 66 |