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 |
||
3 | class VideoPress_Gutenberg { |
||
4 | |||
5 | /** |
||
6 | * Initialize the VideoPress Gutenberg extension |
||
7 | */ |
||
8 | public static function init() { |
||
14 | |||
15 | /** |
||
16 | * Register the Jetpack Gutenberg extension that adds VideoPress support to the core video block. |
||
17 | */ |
||
18 | public static function register_video_block_with_videopress() { |
||
27 | |||
28 | /** |
||
29 | * Render the core video block replacing the src attribute with the VideoPress URL |
||
30 | * |
||
31 | * @param array $attributes Array containing the video block attributes. |
||
32 | * @param string $content String containing the video block content. |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | public static function render_video_block_with_videopress( $attributes, $content ) { |
||
69 | } |
||
70 | |||
72 |