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 |
||
| 18 | View Code Duplication | class Reload_Data_Page extends Tasks_Page_Base { |
|
|
|
|||
| 19 | |||
| 20 | /** |
||
| 21 | * The ID of this admin page. |
||
| 22 | * |
||
| 23 | * @since 1.0.0 |
||
| 24 | * @access private |
||
| 25 | * @var string $menu_slug The ID of this page. |
||
| 26 | */ |
||
| 27 | private $menu_slug = 'wl_images_licenses__reload_data'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Define the {@link Wordlift_Admin_Page} constructor. |
||
| 31 | * |
||
| 32 | * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
||
| 33 | * @param string $version |
||
| 34 | * |
||
| 35 | * @since 1.0.0 |
||
| 36 | */ |
||
| 37 | public function __construct( $task_ajax_adapters_registry, $version ) { |
||
| 48 | |||
| 49 | } |
||
| 50 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.