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 |
||
8 | class FrmDbDeprecated { |
||
9 | |||
10 | var $fields; |
||
11 | var $forms; |
||
12 | var $entries; |
||
13 | var $entry_metas; |
||
14 | |||
15 | View Code Duplication | public function __construct() { |
|
26 | |||
27 | /** |
||
28 | * @deprecated 2.03.05 |
||
29 | */ |
||
30 | public function upgrade( $old_db_version = false ) { |
||
36 | |||
37 | /** |
||
38 | * @deprecated 2.03.05 |
||
39 | */ |
||
40 | public function collation() { |
||
46 | |||
47 | /** |
||
48 | * @deprecated 2.03.05 |
||
49 | */ |
||
50 | public function uninstall() { |
||
56 | |||
57 | /** |
||
58 | * @deprecated 2.03.05 |
||
59 | */ |
||
60 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
||
64 | |||
65 | /** |
||
66 | * @deprecated 2.03.05 |
||
67 | */ |
||
68 | public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
||
72 | |||
73 | /** |
||
74 | * @deprecated 2.03.05 |
||
75 | */ |
||
76 | public static function get_count( $table, $where = array(), $args = array() ) { |
||
81 | |||
82 | /** |
||
83 | * @deprecated 2.03.05 |
||
84 | */ |
||
85 | public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
||
90 | |||
91 | /** |
||
92 | * @deprecated 2.03.05 |
||
93 | */ |
||
94 | public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
||
99 | |||
100 | /** |
||
101 | * @deprecated 2.03.05 |
||
102 | */ |
||
103 | public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
||
108 | |||
109 | /** |
||
110 | * @deprecated 2.03.05 |
||
111 | */ |
||
112 | public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
||
117 | |||
118 | /** |
||
119 | * @deprecated 2.03.05 |
||
120 | */ |
||
121 | public static function append_where_is( $where_is ) { |
||
126 | |||
127 | /** |
||
128 | * @deprecated 2.03.05 |
||
129 | */ |
||
130 | public static function get_associative_array_results( $columns, $table, $where ) { |
||
135 | } |
||
136 |
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.