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 ExportAttendee implements PersonalDataExporterInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var EEM_Attendee |
||
20 | */ |
||
21 | protected $attendee_model; |
||
22 | |||
23 | /** |
||
24 | * ExportAttendee constructor. |
||
25 | * |
||
26 | * @param EEM_Attendee $attendee_model |
||
27 | */ |
||
28 | public function __construct(EEM_Attendee $attendee_model) |
||
32 | |||
33 | |||
34 | /** |
||
35 | * Returns data for export. |
||
36 | * |
||
37 | * @param string $email_address , |
||
38 | * @param int $page starts at 1, not 0 |
||
39 | * @return array { |
||
40 | * @type array $data { |
||
41 | * @type array { |
||
42 | * @type string $group_id (not translated, same for all exports) |
||
43 | * @type string $group_label (translated string) |
||
44 | * @type string|int $item_id |
||
45 | * @type array $data { |
||
46 | * @type array { |
||
47 | * @type string $name what's shown in the left-column of the export row |
||
48 | * @type string $value what's showin the right-column of the export row |
||
49 | * } |
||
50 | * } |
||
51 | * } |
||
52 | * } |
||
53 | * } |
||
54 | */ |
||
55 | public function export($email_address, $page = 1) |
||
118 | |||
119 | /** |
||
120 | * Gets the Translated name of this exporter |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public function name() |
||
128 | } |
||
129 | // End of file ExportAttendee.php |
||
131 |