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 |
||
| 24 | class Give_DB_Donor_Meta extends Give_DB_Meta { |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Meta type |
||
| 28 | * |
||
| 29 | * @since 2.0 |
||
| 30 | * @access public |
||
| 31 | * |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | public $meta_type = 'donor'; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Meta supports. |
||
| 38 | * |
||
| 39 | * @since 2.0 |
||
| 40 | * @access protected |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | protected $supports = array(); |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Give_DB_Donor_Meta constructor. |
||
| 47 | * |
||
| 48 | * @access public |
||
| 49 | * @since 1.6 |
||
| 50 | */ |
||
| 51 | public function __construct() { |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Get table columns and data types. |
||
| 67 | * |
||
| 68 | * @access public |
||
| 69 | * @since 1.6 |
||
| 70 | * |
||
| 71 | * @return array Columns and formats. |
||
| 72 | */ |
||
| 73 | public function get_columns() { |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Create the table |
||
| 84 | * |
||
| 85 | * @access public |
||
| 86 | * @since 1.6 |
||
| 87 | * |
||
| 88 | * @return void |
||
| 89 | */ |
||
| 90 | View Code Duplication | public function create_table() { |
|
| 108 | |||
| 109 | /** |
||
| 110 | * Add backward compatibility for old table name |
||
| 111 | * |
||
| 112 | * @since 2.0 |
||
| 113 | * @access private |
||
| 114 | * @global wpdb $wpdb |
||
| 115 | */ |
||
| 116 | private function bc_200_params() { |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Check if current id is valid |
||
| 133 | * |
||
| 134 | * @since 2.0 |
||
| 135 | * @access protected |
||
| 136 | * |
||
| 137 | * @param $ID |
||
| 138 | * |
||
| 139 | * @return bool |
||
| 140 | */ |
||
| 141 | protected function is_valid_post_type( $ID ) { |
||
| 144 | |||
| 145 | } |
||
| 146 |