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 | abstract class Tasks_Page_Base 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; |
||
|
|
|||
| 29 | |||
| 30 | /** |
||
| 31 | * @var Task_Ajax_Adapters_Registry |
||
| 32 | */ |
||
| 33 | private $task_ajax_adapters_registry; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var string |
||
| 37 | */ |
||
| 38 | private $version; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Define the {@link Wordlift_Admin_Page} constructor. |
||
| 42 | * |
||
| 43 | * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
||
| 44 | * |
||
| 45 | * @param string $version |
||
| 46 | * @param string $menu_slug |
||
| 47 | * @param string $page_title |
||
| 48 | * @param string $capability |
||
| 49 | * @param string|null $parent_slug |
||
| 50 | * @param string|null $menu_title |
||
| 51 | * |
||
| 52 | * @since 1.0.0 |
||
| 53 | */ |
||
| 54 | public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) { |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Register the stylesheets and scripts for the admin area. |
||
| 65 | * |
||
| 66 | * @since 1.0.0 |
||
| 67 | */ |
||
| 68 | View Code Duplication | public function enqueue_scripts() { |
|
| 75 | |||
| 76 | /** |
||
| 77 | * Render the page. |
||
| 78 | * |
||
| 79 | * @since 1.0.0 |
||
| 80 | */ |
||
| 81 | public function render() { |
||
| 87 | |||
| 88 | } |
||
| 89 |