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 EditableEmailField extends EditableFormField |
||
| 17 | { |
||
| 18 | private static $singular_name = 'Email Field'; |
||
| 19 | |||
| 20 | private static $plural_name = 'Email Fields'; |
||
| 21 | |||
| 22 | private static $has_placeholder = true; |
||
| 23 | |||
| 24 | private static $table_name = 'EditableEmailField'; |
||
| 25 | |||
| 26 | public function getSetsOwnError() |
||
| 30 | |||
| 31 | View Code Duplication | public function getFormField() |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Updates a formfield with the additional metadata specified by this field |
||
| 44 | * |
||
| 45 | * @param FormField $field |
||
| 46 | */ |
||
| 47 | protected function updateFormField($field) |
||
| 53 | } |
||
| 54 |