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 |
||
| 16 | class WPCOM_REST_API_V2_Endpoint_External_Media extends WP_REST_Controller { |
||
| 17 | /** |
||
| 18 | * Constructor. |
||
| 19 | */ |
||
| 20 | public function __construct() { |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Register the route. |
||
| 28 | */ |
||
| 29 | View Code Duplication | public function register_routes() { |
|
| 39 | |||
| 40 | public function get_external_media( \WP_REST_Request $request ) { |
||
| 55 | } |
||
| 56 | |||
| 58 |