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 |
||
15 | View Code Duplication | class PartialFieldSubmission extends SubmittedFormField |
|
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private static $table_name = 'PartialFieldSubmission'; |
||
|
|||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private static $has_one = [ |
||
26 | 'SubmittedForm' => PartialFormSubmission::class, |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * @param Member $member |
||
31 | * @param array $context |
||
32 | * @return boolean |
||
33 | */ |
||
34 | 1 | public function canCreate($member = null, $context = []) |
|
38 | |||
39 | /** |
||
40 | * @param Member $member |
||
41 | * |
||
42 | * @return boolean|string |
||
43 | */ |
||
44 | 14 | public function canView($member = null) |
|
52 | |||
53 | /** |
||
54 | * @param Member $member |
||
55 | * |
||
56 | * @return boolean|string |
||
57 | */ |
||
58 | 1 | public function canEdit($member = null) |
|
66 | |||
67 | /** |
||
68 | * @param Member $member |
||
69 | * |
||
70 | * @return boolean|string |
||
71 | */ |
||
72 | 1 | public function canDelete($member = null) |
|
80 | } |
||
81 |