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 |
||
9 | class Grunion_Contact_Form_Endpoint extends WP_REST_Posts_Controller { |
||
10 | /** |
||
11 | * Check whether a given request has proper authoriztion to view feedback items. |
||
12 | * |
||
13 | * @param WP_REST_Request $request Full details about the request. |
||
14 | * @return WP_Error|boolean |
||
15 | */ |
||
16 | View Code Duplication | public function get_items_permissions_check( $request ) { |
|
27 | |||
28 | /** |
||
29 | * Check whether a given request has proper authoriztion to view feedback item. |
||
30 | * |
||
31 | * @param WP_REST_Request $request Full details about the request. |
||
32 | * @return WP_Error|boolean |
||
33 | */ |
||
34 | View Code Duplication | public function get_item_permissions_check( $request ) { |
|
45 | |||
46 | } |
||
47 | |||
49 |