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 |
||
13 | class Grunion_Contact_Form_Endpoint extends WP_REST_Posts_Controller { |
||
14 | /** |
||
15 | * Check whether a given request has proper authorization to view feedback items. |
||
16 | * |
||
17 | * @param WP_REST_Request $request Full details about the request. |
||
18 | * @return WP_Error|boolean |
||
19 | */ |
||
20 | View Code Duplication | public function get_items_permissions_check( $request ) { |
|
31 | |||
32 | /** |
||
33 | * Check whether a given request has proper authorization to view feedback item. |
||
34 | * |
||
35 | * @param WP_REST_Request $request Full details about the request. |
||
36 | * @return WP_Error|boolean |
||
37 | */ |
||
38 | View Code Duplication | public function get_item_permissions_check( $request ) { |
|
49 | |||
50 | } |
||
51 | |||
53 |