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 |
||
| 14 | class EditableFieldGroup extends EditableFormField |
||
| 15 | { |
||
| 16 | private static $has_one = [ |
||
| 17 | 'End' => EditableFieldGroupEnd::class, |
||
| 18 | ]; |
||
| 19 | |||
| 20 | private static $owns = [ |
||
| 21 | 'End', |
||
| 22 | ]; |
||
| 23 | |||
| 24 | private static $cascade_deletes = [ |
||
| 25 | 'End', |
||
| 26 | ]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Disable selection of group class |
||
| 30 | * |
||
| 31 | * @config |
||
| 32 | * @var bool |
||
| 33 | */ |
||
| 34 | private static $hidden = true; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Non-data field type |
||
| 38 | * |
||
| 39 | * @var type |
||
| 40 | */ |
||
| 41 | private static $literal = true; |
||
| 42 | |||
| 43 | private static $table_name = 'EditableFieldGroup'; |
||
| 44 | |||
| 45 | public function getCMSFields() |
||
| 51 | |||
| 52 | public function getCMSTitle() |
||
| 64 | |||
| 65 | public function getInlineClassnameField($column, $fieldClasses) |
||
| 69 | |||
| 70 | public function showInReports() |
||
| 74 | |||
| 75 | public function getFormField() |
||
| 83 | |||
| 84 | View Code Duplication | protected function updateFormField($field) |
|
| 97 | } |
||
| 98 |