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 |
||
20 | class PartialFormSubmission extends SubmittedForm |
||
21 | { |
||
22 | private static $table_name = 'PartialFormSubmission'; |
||
23 | |||
24 | private static $db = [ |
||
25 | 'IsSend' => 'Boolean(false)' |
||
26 | ]; |
||
27 | |||
28 | private static $has_one = [ |
||
29 | 'UserDefinedForm' => DataObject::class |
||
30 | ]; |
||
31 | |||
32 | private static $has_many = [ |
||
33 | 'PartialFields' => PartialFieldSubmission::class |
||
34 | ]; |
||
35 | |||
36 | public function getCMSFields() |
||
49 | |||
50 | /** |
||
51 | * @param Member |
||
52 | * |
||
53 | * @return boolean |
||
54 | */ |
||
55 | public function canCreate($member = null, $context = []) |
||
72 | |||
73 | /** |
||
74 | * @param Member |
||
75 | * |
||
76 | * @return boolean |
||
77 | */ |
||
78 | View Code Duplication | public function canView($member = null) |
|
92 | |||
93 | /** |
||
94 | * @param Member |
||
95 | * |
||
96 | * @return boolean |
||
97 | */ |
||
98 | View Code Duplication | public function canEdit($member = null) |
|
112 | |||
113 | /** |
||
114 | * @param Member |
||
115 | * |
||
116 | * @return boolean |
||
117 | */ |
||
118 | View Code Duplication | public function canDelete($member = null) |
|
132 | |||
133 | } |
||
134 |