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 |
||
2 | class WPCOM_JSON_API_Get_Post_Endpoint extends WPCOM_JSON_API_Post_Endpoint { |
||
3 | // /sites/%s/posts/%d -> $blog_id, $post_id |
||
4 | // /sites/%s/posts/name:%s -> $blog_id, $post_id // not documented |
||
5 | // /sites/%s/posts/slug:%s -> $blog_id, $post_id |
||
6 | function callback( $path = '', $blog_id = 0, $post_id = 0 ) { |
||
34 | } |
||
35 |