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 use EventEspresso\modules\ticket_selector\DisplayTicketSelector; |
||
23 | class EED_Ticket_Selector extends EED_Module { |
||
24 | |||
25 | /** |
||
26 | * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
||
27 | */ |
||
28 | private static $ticket_selector; |
||
29 | |||
30 | /** |
||
31 | * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
||
32 | */ |
||
33 | private static $iframe_embed_button; |
||
34 | |||
35 | |||
36 | |||
37 | /** |
||
38 | * @return EED_Ticket_Selector |
||
39 | */ |
||
40 | public static function instance() { |
||
43 | |||
44 | |||
45 | |||
46 | protected function set_config(){ |
||
51 | |||
52 | |||
53 | |||
54 | /** |
||
55 | * set_hooks - for hooking into EE Core, other modules, etc |
||
56 | * |
||
57 | * @access public |
||
58 | * @return void |
||
59 | */ |
||
60 | public static function set_hooks() { |
||
71 | |||
72 | |||
73 | |||
74 | /** |
||
75 | * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
||
76 | * |
||
77 | * @access public |
||
78 | * @return void |
||
79 | */ |
||
80 | public static function set_hooks_admin() { |
||
99 | |||
100 | |||
101 | |||
102 | /** |
||
103 | * set_definitions |
||
104 | * |
||
105 | * @access public |
||
106 | * @return void |
||
107 | */ |
||
108 | public static function set_definitions() { |
||
124 | |||
125 | |||
126 | |||
127 | /** |
||
128 | * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
||
129 | */ |
||
130 | public static function ticketSelector() |
||
137 | |||
138 | |||
139 | /** |
||
140 | * gets the ball rolling |
||
141 | * |
||
142 | * @access public |
||
143 | * @param WP $WP |
||
144 | * @return void |
||
145 | */ |
||
146 | public function run( $WP ) {} |
||
147 | |||
148 | |||
149 | |||
150 | /** |
||
151 | * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton |
||
152 | */ |
||
153 | public static function getIframeEmbedButton() { |
||
159 | |||
160 | |||
161 | |||
162 | /** |
||
163 | * ticket_selector_iframe_embed_button |
||
164 | * |
||
165 | * @return void |
||
166 | * @throws \EE_Error |
||
167 | */ |
||
168 | public static function ticket_selector_iframe_embed_button() { |
||
172 | |||
173 | |||
174 | |||
175 | /** |
||
176 | * ticket_selector_iframe |
||
177 | * |
||
178 | * @return void |
||
179 | * @throws \DomainException |
||
180 | * @throws \EE_Error |
||
181 | */ |
||
182 | public function ticket_selector_iframe() { |
||
186 | |||
187 | |||
188 | |||
189 | /** |
||
190 | * creates buttons for selecting number of attendees for an event |
||
191 | * |
||
192 | * @access public |
||
193 | * @param WP_Post|int $event |
||
194 | * @param bool $view_details |
||
195 | * @return string |
||
196 | * @throws \EE_Error |
||
197 | */ |
||
198 | public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
||
201 | |||
202 | |||
203 | |||
204 | /** |
||
205 | * process_ticket_selections |
||
206 | * |
||
207 | * @access public |
||
208 | * @return array or FALSE |
||
209 | * @throws \EE_Error |
||
210 | */ |
||
211 | public function process_ticket_selections() { |
||
215 | |||
216 | |||
217 | |||
218 | /** |
||
219 | * cancel_ticket_selections |
||
220 | * |
||
221 | * @access public |
||
222 | * @return string |
||
223 | */ |
||
224 | public static function cancel_ticket_selections() |
||
229 | |||
230 | |||
231 | |||
232 | /** |
||
233 | * @return void |
||
234 | */ |
||
235 | public static function translate_js_strings() { |
||
240 | |||
241 | |||
242 | |||
243 | /** |
||
244 | * load js |
||
245 | * |
||
246 | * @access public |
||
247 | * @return void |
||
248 | */ |
||
249 | public static function load_tckt_slctr_assets() { |
||
272 | |||
273 | |||
274 | |||
275 | /** |
||
276 | * @return void |
||
277 | */ |
||
278 | public static function loadIframeAssets() |
||
299 | |||
300 | |||
301 | |||
302 | /** |
||
303 | * Informs the rest of the forms system what CSS and JS is needed to display the input |
||
304 | * |
||
305 | * @param array $iframe_css |
||
306 | * @return array |
||
307 | */ |
||
308 | public static function iframeCss(array $iframe_css) |
||
313 | |||
314 | |||
315 | |||
316 | /** |
||
317 | * Informs the rest of the forms system what CSS and JS is needed to display the input |
||
318 | * |
||
319 | * @param array $iframe_js |
||
320 | * @return array |
||
321 | */ |
||
322 | public static function iframeJs(array $iframe_js) |
||
327 | |||
328 | |||
329 | /****************************** DEPRECATED ******************************/ |
||
330 | |||
331 | |||
332 | |||
333 | /** |
||
334 | * @deprecated |
||
335 | * @return string |
||
336 | * @throws \EE_Error |
||
337 | */ |
||
338 | public static function display_view_details_btn() |
||
343 | |||
344 | |||
345 | |||
346 | /** |
||
347 | * @deprecated |
||
348 | * @return string |
||
349 | * @throws \EE_Error |
||
350 | */ |
||
351 | public static function display_ticket_selector_submit() |
||
356 | |||
357 | |||
358 | |||
359 | /** |
||
360 | * @deprecated |
||
361 | * @param string $permalink_string |
||
362 | * @param int $id |
||
363 | * @param string $new_title |
||
364 | * @param string $new_slug |
||
365 | * @return string |
||
366 | */ |
||
367 | public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
||
379 | |||
380 | |||
381 | |||
382 | /** |
||
383 | * @deprecated |
||
384 | * @param int $ID |
||
385 | * @param string $external_url |
||
386 | * @return string |
||
387 | */ |
||
388 | public static function ticket_selector_form_open($ID = 0, $external_url = '') |
||
393 | |||
394 | |||
395 | |||
396 | /** |
||
397 | * @deprecated |
||
398 | * @return string |
||
399 | */ |
||
400 | public static function ticket_selector_form_close() |
||
405 | |||
406 | |||
407 | |||
408 | /** |
||
409 | * @deprecated |
||
410 | * @return string |
||
411 | */ |
||
412 | public static function no_tkt_slctr_end_dv() |
||
417 | |||
418 | |||
419 | |||
420 | /** |
||
421 | * @deprecated 4.9.13 |
||
422 | * @return string |
||
423 | */ |
||
424 | public static function tkt_slctr_end_dv() |
||
428 | |||
429 | |||
430 | |||
431 | /** |
||
432 | * @deprecated |
||
433 | * @return string |
||
434 | */ |
||
435 | public static function clear_tkt_slctr() |
||
439 | |||
440 | |||
441 | |||
442 | /** |
||
443 | * @deprecated |
||
444 | */ |
||
445 | public static function load_tckt_slctr_assets_admin() |
||
456 | |||
457 | |||
458 | } |
||
459 | // End of file EED_Ticket_Selector.module.php |
||
461 |