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 |
||
| 19 | class Tasks_Page extends Submenu_Page_Base { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The ID of this admin page. |
||
| 23 | * |
||
| 24 | * @since 1.0.0 |
||
| 25 | * @access private |
||
| 26 | * @var string $menu_slug The ID of this page. |
||
| 27 | */ |
||
| 28 | private $menu_slug = 'wl_tasks_page'; |
||
|
|
|||
| 29 | |||
| 30 | /** |
||
| 31 | * Used when enqueueing styles or scripts as the version string. |
||
| 32 | * |
||
| 33 | * @since 1.0.0 |
||
| 34 | * @access private |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | private $asset_version = '1.0.0'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var Task_Ajax_Adapters_Registry |
||
| 41 | */ |
||
| 42 | private $task_ajax_adapters_registry; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Define the {@link Wordlift_Admin_Page} constructor. |
||
| 46 | * |
||
| 47 | * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
||
| 48 | * |
||
| 49 | * @since 1.0.0 |
||
| 50 | */ |
||
| 51 | public function __construct( $task_ajax_adapters_registry ) { |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Register the stylesheets and scripts for the admin area. |
||
| 60 | * |
||
| 61 | * @since 1.0.0 |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function enqueue_scripts() { |
|
| 70 | |||
| 71 | /** |
||
| 72 | * Render the page. |
||
| 73 | * |
||
| 74 | * @since 1.0.0 |
||
| 75 | */ |
||
| 76 | public function render() { |
||
| 82 | |||
| 83 | } |
||
| 84 |