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 |
||
24 | View Code Duplication | class CreateAttendeeCommand extends Command implements CommandRequiresCapCheckInterface |
|
25 | { |
||
26 | |||
27 | /** |
||
28 | * array of details where keys are names of EEM_Attendee model fields |
||
29 | * |
||
30 | * @var array $attendee_details |
||
31 | */ |
||
32 | protected $attendee_details; |
||
33 | |||
34 | /** |
||
35 | * an existing registration to associate this attendee with |
||
36 | * |
||
37 | * @var EE_Registration $registration |
||
38 | */ |
||
39 | protected $registration; |
||
40 | |||
41 | |||
42 | |||
43 | /** |
||
44 | * CreateAttendeeCommand constructor. |
||
45 | * |
||
46 | * @param array $attendee_details |
||
47 | * @param EE_Registration $registration |
||
48 | */ |
||
49 | public function __construct(array $attendee_details, EE_Registration $registration) |
||
54 | |||
55 | |||
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | public function attendeeDetails() |
||
64 | |||
65 | |||
66 | |||
67 | /** |
||
68 | * @return EE_Registration |
||
69 | */ |
||
70 | public function registration() |
||
74 | |||
75 | |||
76 | |||
77 | /** |
||
78 | * @return CapCheckInterface |
||
79 | * @throws InvalidDataTypeException |
||
80 | */ |
||
81 | public function getCapCheck() |
||
89 | |||
90 | |||
91 | |||
92 | } |
||
93 | // End of file CreateAttendeeCommand.php |
||
94 | // Location: EventEspresso\core\services\commands\attendee/CreateAttendeeCommand.php |