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 |
||
5 | class AMP_Vine_Embed_Handler extends AMP_Base_Embed_Handler { |
||
6 | const URL_PATTERN = '#https?://vine\.co/v/([^/?]+)#i'; |
||
7 | |||
8 | protected $DEFAULT_WIDTH = 400; |
||
9 | protected $DEFAULT_HEIGHT = 400; |
||
10 | |||
11 | private static $script_slug = 'amp-vine'; |
||
12 | private static $script_src = 'https://cdn.ampproject.org/v0/amp-vine-0.1.js'; |
||
13 | |||
14 | public function register_embed() { |
||
17 | |||
18 | public function unregister_embed() { |
||
21 | |||
22 | public function get_scripts() { |
||
29 | |||
30 | public function oembed( $matches, $attr, $url, $rawattr ) { |
||
33 | |||
34 | View Code Duplication | public function render( $args ) { |
|
56 | } |
||
57 |