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 |
||
16 | class acf_field_url extends acf_field { |
||
17 | |||
18 | |||
19 | /* |
||
20 | * __construct |
||
21 | * |
||
22 | * This function will setup the field type data |
||
23 | * |
||
24 | * @type function |
||
25 | * @date 5/03/2014 |
||
26 | * @since 5.0.0 |
||
27 | * |
||
28 | * @param n/a |
||
29 | * @return n/a |
||
30 | */ |
||
|
|||
31 | |||
32 | View Code Duplication | function __construct() { |
|
46 | |||
47 | |||
48 | /* |
||
49 | * render_field() |
||
50 | * |
||
51 | * Create the HTML interface for your field |
||
52 | * |
||
53 | * @param $field - an array holding all the field's data |
||
54 | * |
||
55 | * @type action |
||
56 | * @since 3.6 |
||
57 | * @date 23/01/13 |
||
58 | */ |
||
59 | |||
60 | function render_field( $field ) { |
||
98 | |||
99 | |||
100 | /* |
||
101 | * render_field_settings() |
||
102 | * |
||
103 | * Create extra options for your field. This is rendered when editing a field. |
||
104 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
||
105 | * |
||
106 | * @type action |
||
107 | * @since 3.6 |
||
108 | * @date 23/01/13 |
||
109 | * |
||
110 | * @param $field - an array holding all the field's data |
||
111 | */ |
||
112 | |||
113 | View Code Duplication | function render_field_settings( $field ) { |
|
133 | |||
134 | |||
135 | /* |
||
136 | * validate_value |
||
137 | * |
||
138 | * description |
||
139 | * |
||
140 | * @type function |
||
141 | * @date 11/02/2014 |
||
142 | * @since 5.0.0 |
||
143 | * |
||
144 | * @param $post_id (int) |
||
145 | * @return $post_id (int) |
||
146 | */ |
||
147 | |||
148 | function validate_value( $valid, $value, $field, $input ){ |
||
177 | |||
178 | } |
||
179 | |||
185 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.