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:
Complex classes like EE_Registration often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EE_Registration, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | class EE_Registration extends EE_Soft_Delete_Base_Class implements EEI_Registration, EEI_Admin_Links |
||
17 | { |
||
18 | |||
19 | |||
20 | /** |
||
21 | * Used to reference when a registration has never been checked in. |
||
22 | * |
||
23 | * @deprecated use \EE_Checkin::status_checked_never instead |
||
24 | * @type int |
||
25 | */ |
||
26 | const checkin_status_never = 2; |
||
27 | |||
28 | /** |
||
29 | * Used to reference when a registration has been checked in. |
||
30 | * |
||
31 | * @deprecated use \EE_Checkin::status_checked_in instead |
||
32 | * @type int |
||
33 | */ |
||
34 | const checkin_status_in = 1; |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Used to reference when a registration has been checked out. |
||
39 | * |
||
40 | * @deprecated use \EE_Checkin::status_checked_out instead |
||
41 | * @type int |
||
42 | */ |
||
43 | const checkin_status_out = 0; |
||
44 | |||
45 | |||
46 | /** |
||
47 | * extra meta key for tracking reg status os trashed registrations |
||
48 | * |
||
49 | * @type string |
||
50 | */ |
||
51 | const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
||
52 | |||
53 | |||
54 | /** |
||
55 | * extra meta key for tracking if registration has reserved ticket |
||
56 | * |
||
57 | * @type string |
||
58 | */ |
||
59 | const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * @param array $props_n_values incoming values |
||
64 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
65 | * used.) |
||
66 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
67 | * date_format and the second value is the time format |
||
68 | * @return EE_Registration |
||
69 | * @throws EE_Error |
||
70 | */ |
||
71 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
76 | |||
77 | |||
78 | /** |
||
79 | * @param array $props_n_values incoming values from the database |
||
80 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
81 | * the website will be used. |
||
82 | * @return EE_Registration |
||
83 | */ |
||
84 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Set Event ID |
||
92 | * |
||
93 | * @param int $EVT_ID Event ID |
||
94 | * @throws EE_Error |
||
95 | * @throws RuntimeException |
||
96 | */ |
||
97 | public function set_event($EVT_ID = 0) |
||
101 | |||
102 | |||
103 | /** |
||
104 | * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
||
105 | * be routed to internal methods |
||
106 | * |
||
107 | * @param string $field_name |
||
108 | * @param mixed $field_value |
||
109 | * @param bool $use_default |
||
110 | * @throws EE_Error |
||
111 | * @throws EntityNotFoundException |
||
112 | * @throws InvalidArgumentException |
||
113 | * @throws InvalidDataTypeException |
||
114 | * @throws InvalidInterfaceException |
||
115 | * @throws ReflectionException |
||
116 | * @throws RuntimeException |
||
117 | */ |
||
118 | public function set($field_name, $field_value, $use_default = false) |
||
133 | |||
134 | |||
135 | /** |
||
136 | * Set Status ID |
||
137 | * updates the registration status and ALSO... |
||
138 | * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
||
139 | * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
||
140 | * |
||
141 | * @param string $new_STS_ID |
||
142 | * @param boolean $use_default |
||
143 | * @param ContextInterface|null $context |
||
144 | * @return bool |
||
145 | * @throws DomainException |
||
146 | * @throws EE_Error |
||
147 | * @throws EntityNotFoundException |
||
148 | * @throws InvalidArgumentException |
||
149 | * @throws InvalidDataTypeException |
||
150 | * @throws InvalidInterfaceException |
||
151 | * @throws ReflectionException |
||
152 | * @throws RuntimeException |
||
153 | * @throws UnexpectedEntityException |
||
154 | */ |
||
155 | public function set_status($new_STS_ID = null, $use_default = false, ContextInterface $context = null) |
||
199 | |||
200 | |||
201 | /** |
||
202 | * update REGs and TXN when cancelled or declined registrations involved |
||
203 | * |
||
204 | * @param string $new_STS_ID |
||
205 | * @param string $old_STS_ID |
||
206 | * @param ContextInterface|null $context |
||
207 | * @throws EE_Error |
||
208 | * @throws InvalidArgumentException |
||
209 | * @throws InvalidDataTypeException |
||
210 | * @throws InvalidInterfaceException |
||
211 | * @throws ReflectionException |
||
212 | * @throws RuntimeException |
||
213 | */ |
||
214 | private function updateIfCanceledOrReinstated($new_STS_ID, $old_STS_ID, ContextInterface $context = null) |
||
232 | |||
233 | |||
234 | /** |
||
235 | * update REGs and TXN when cancelled or declined registrations involved |
||
236 | * |
||
237 | * @param array $closed_reg_statuses |
||
238 | * @param string $new_STS_ID |
||
239 | * @param string $old_STS_ID |
||
240 | * @param ContextInterface|null $context |
||
241 | * @throws EE_Error |
||
242 | * @throws InvalidArgumentException |
||
243 | * @throws InvalidDataTypeException |
||
244 | * @throws InvalidInterfaceException |
||
245 | * @throws ReflectionException |
||
246 | * @throws RuntimeException |
||
247 | */ |
||
248 | View Code Duplication | private function updateIfCanceled( |
|
282 | |||
283 | |||
284 | /** |
||
285 | * update REGs and TXN when cancelled or declined registrations involved |
||
286 | * |
||
287 | * @param array $closed_reg_statuses |
||
288 | * @param string $new_STS_ID |
||
289 | * @param string $old_STS_ID |
||
290 | * @param ContextInterface|null $context |
||
291 | * @throws EE_Error |
||
292 | * @throws InvalidArgumentException |
||
293 | * @throws InvalidDataTypeException |
||
294 | * @throws InvalidInterfaceException |
||
295 | * @throws ReflectionException |
||
296 | */ |
||
297 | View Code Duplication | private function updateIfReinstated( |
|
330 | |||
331 | |||
332 | /** |
||
333 | * @param ContextInterface|null $context |
||
334 | * @return bool |
||
335 | */ |
||
336 | private function statusChangeUpdatesTransaction(ContextInterface $context = null) |
||
349 | |||
350 | |||
351 | /** |
||
352 | * @throws EE_Error |
||
353 | * @throws EntityNotFoundException |
||
354 | * @throws InvalidArgumentException |
||
355 | * @throws InvalidDataTypeException |
||
356 | * @throws InvalidInterfaceException |
||
357 | * @throws ReflectionException |
||
358 | * @throws RuntimeException |
||
359 | */ |
||
360 | private function updateTransactionAfterStatusChange() |
||
367 | |||
368 | |||
369 | /** |
||
370 | * get Status ID |
||
371 | */ |
||
372 | public function status_ID() |
||
376 | |||
377 | |||
378 | /** |
||
379 | * Gets the ticket this registration is for |
||
380 | * |
||
381 | * @param boolean $include_archived whether to include archived tickets or not. |
||
382 | * |
||
383 | * @return EE_Ticket|EE_Base_Class |
||
384 | * @throws EE_Error |
||
385 | */ |
||
386 | public function ticket($include_archived = true) |
||
394 | |||
395 | |||
396 | /** |
||
397 | * Gets the event this registration is for |
||
398 | * |
||
399 | * @return EE_Event |
||
400 | * @throws EE_Error |
||
401 | * @throws EntityNotFoundException |
||
402 | */ |
||
403 | public function event() |
||
411 | |||
412 | |||
413 | /** |
||
414 | * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
||
415 | * with the author of the event this registration is for. |
||
416 | * |
||
417 | * @since 4.5.0 |
||
418 | * @return int |
||
419 | * @throws EE_Error |
||
420 | * @throws EntityNotFoundException |
||
421 | */ |
||
422 | public function wp_user() |
||
430 | |||
431 | |||
432 | /** |
||
433 | * increments this registration's related ticket sold and corresponding datetime sold values |
||
434 | * |
||
435 | * @return void |
||
436 | * @throws DomainException |
||
437 | * @throws EE_Error |
||
438 | * @throws EntityNotFoundException |
||
439 | * @throws InvalidArgumentException |
||
440 | * @throws InvalidDataTypeException |
||
441 | * @throws InvalidInterfaceException |
||
442 | * @throws ReflectionException |
||
443 | * @throws UnexpectedEntityException |
||
444 | */ |
||
445 | private function reserveRegistrationSpace() |
||
455 | |||
456 | |||
457 | /** |
||
458 | * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
||
459 | * |
||
460 | * @return void |
||
461 | * @throws DomainException |
||
462 | * @throws EE_Error |
||
463 | * @throws EntityNotFoundException |
||
464 | * @throws InvalidArgumentException |
||
465 | * @throws InvalidDataTypeException |
||
466 | * @throws InvalidInterfaceException |
||
467 | * @throws ReflectionException |
||
468 | * @throws UnexpectedEntityException |
||
469 | */ |
||
470 | private function releaseRegistrationSpace() |
||
477 | |||
478 | |||
479 | /** |
||
480 | * tracks this registration's ticket reservation in extra meta |
||
481 | * and can increment related ticket reserved and corresponding datetime reserved values |
||
482 | * |
||
483 | * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
||
484 | * @return void |
||
485 | * @throws EE_Error |
||
486 | * @throws InvalidArgumentException |
||
487 | * @throws InvalidDataTypeException |
||
488 | * @throws InvalidInterfaceException |
||
489 | * @throws ReflectionException |
||
490 | */ |
||
491 | View Code Duplication | public function reserve_ticket($update_ticket = false, $source = 'unknown') |
|
508 | |||
509 | |||
510 | /** |
||
511 | * stops tracking this registration's ticket reservation in extra meta |
||
512 | * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
||
513 | * |
||
514 | * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
||
515 | * @return void |
||
516 | * @throws EE_Error |
||
517 | * @throws InvalidArgumentException |
||
518 | * @throws InvalidDataTypeException |
||
519 | * @throws InvalidInterfaceException |
||
520 | * @throws ReflectionException |
||
521 | */ |
||
522 | View Code Duplication | public function release_reserved_ticket($update_ticket = false, $source = 'unknown') |
|
538 | |||
539 | |||
540 | /** |
||
541 | * Set Attendee ID |
||
542 | * |
||
543 | * @param int $ATT_ID Attendee ID |
||
544 | * @throws EE_Error |
||
545 | * @throws RuntimeException |
||
546 | */ |
||
547 | public function set_attendee_id($ATT_ID = 0) |
||
551 | |||
552 | |||
553 | /** |
||
554 | * Set Transaction ID |
||
555 | * |
||
556 | * @param int $TXN_ID Transaction ID |
||
557 | * @throws EE_Error |
||
558 | * @throws RuntimeException |
||
559 | */ |
||
560 | public function set_transaction_id($TXN_ID = 0) |
||
564 | |||
565 | |||
566 | /** |
||
567 | * Set Session |
||
568 | * |
||
569 | * @param string $REG_session PHP Session ID |
||
570 | * @throws EE_Error |
||
571 | * @throws RuntimeException |
||
572 | */ |
||
573 | public function set_session($REG_session = '') |
||
577 | |||
578 | |||
579 | /** |
||
580 | * Set Registration URL Link |
||
581 | * |
||
582 | * @param string $REG_url_link Registration URL Link |
||
583 | * @throws EE_Error |
||
584 | * @throws RuntimeException |
||
585 | */ |
||
586 | public function set_reg_url_link($REG_url_link = '') |
||
590 | |||
591 | |||
592 | /** |
||
593 | * Set Attendee Counter |
||
594 | * |
||
595 | * @param int $REG_count Primary Attendee |
||
596 | * @throws EE_Error |
||
597 | * @throws RuntimeException |
||
598 | */ |
||
599 | public function set_count($REG_count = 1) |
||
603 | |||
604 | |||
605 | /** |
||
606 | * Set Group Size |
||
607 | * |
||
608 | * @param boolean $REG_group_size Group Registration |
||
609 | * @throws EE_Error |
||
610 | * @throws RuntimeException |
||
611 | */ |
||
612 | public function set_group_size($REG_group_size = false) |
||
616 | |||
617 | |||
618 | /** |
||
619 | * is_not_approved - convenience method that returns TRUE if REG status ID == |
||
620 | * EEM_Registration::status_id_not_approved |
||
621 | * |
||
622 | * @return boolean |
||
623 | */ |
||
624 | public function is_not_approved() |
||
628 | |||
629 | |||
630 | /** |
||
631 | * is_pending_payment - convenience method that returns TRUE if REG status ID == |
||
632 | * EEM_Registration::status_id_pending_payment |
||
633 | * |
||
634 | * @return boolean |
||
635 | */ |
||
636 | public function is_pending_payment() |
||
640 | |||
641 | |||
642 | /** |
||
643 | * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
||
644 | * |
||
645 | * @return boolean |
||
646 | */ |
||
647 | public function is_approved() |
||
651 | |||
652 | |||
653 | /** |
||
654 | * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
||
655 | * |
||
656 | * @return boolean |
||
657 | */ |
||
658 | public function is_cancelled() |
||
662 | |||
663 | |||
664 | /** |
||
665 | * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
||
666 | * |
||
667 | * @return boolean |
||
668 | */ |
||
669 | public function is_declined() |
||
673 | |||
674 | |||
675 | /** |
||
676 | * is_incomplete - convenience method that returns TRUE if REG status ID == |
||
677 | * EEM_Registration::status_id_incomplete |
||
678 | * |
||
679 | * @return boolean |
||
680 | */ |
||
681 | public function is_incomplete() |
||
685 | |||
686 | |||
687 | /** |
||
688 | * Set Registration Date |
||
689 | * |
||
690 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
||
691 | * Date |
||
692 | * @throws EE_Error |
||
693 | * @throws RuntimeException |
||
694 | */ |
||
695 | public function set_reg_date($REG_date = false) |
||
699 | |||
700 | |||
701 | /** |
||
702 | * Set final price owing for this registration after all ticket/price modifications |
||
703 | * |
||
704 | * @access public |
||
705 | * @param float $REG_final_price |
||
706 | * @throws EE_Error |
||
707 | * @throws RuntimeException |
||
708 | */ |
||
709 | public function set_final_price($REG_final_price = 0.00) |
||
713 | |||
714 | |||
715 | /** |
||
716 | * Set amount paid towards this registration's final price |
||
717 | * |
||
718 | * @access public |
||
719 | * @param float $REG_paid |
||
720 | * @throws EE_Error |
||
721 | * @throws RuntimeException |
||
722 | */ |
||
723 | public function set_paid($REG_paid = 0.00) |
||
727 | |||
728 | |||
729 | /** |
||
730 | * Attendee Is Going |
||
731 | * |
||
732 | * @param boolean $REG_att_is_going Attendee Is Going |
||
733 | * @throws EE_Error |
||
734 | * @throws RuntimeException |
||
735 | */ |
||
736 | public function set_att_is_going($REG_att_is_going = false) |
||
740 | |||
741 | |||
742 | /** |
||
743 | * Gets the related attendee |
||
744 | * |
||
745 | * @return EE_Attendee |
||
746 | * @throws EE_Error |
||
747 | */ |
||
748 | public function attendee() |
||
752 | |||
753 | |||
754 | /** |
||
755 | * get Event ID |
||
756 | */ |
||
757 | public function event_ID() |
||
761 | |||
762 | |||
763 | /** |
||
764 | * get Event ID |
||
765 | */ |
||
766 | public function event_name() |
||
775 | |||
776 | |||
777 | /** |
||
778 | * Fetches the event this registration is for |
||
779 | * |
||
780 | * @return EE_Event |
||
781 | * @throws EE_Error |
||
782 | */ |
||
783 | public function event_obj() |
||
787 | |||
788 | |||
789 | /** |
||
790 | * get Attendee ID |
||
791 | */ |
||
792 | public function attendee_ID() |
||
796 | |||
797 | |||
798 | /** |
||
799 | * get PHP Session ID |
||
800 | */ |
||
801 | public function session_ID() |
||
805 | |||
806 | |||
807 | /** |
||
808 | * Gets the string which represents the URL trigger for the receipt template in the message template system. |
||
809 | * |
||
810 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
||
811 | * @return string |
||
812 | */ |
||
813 | public function receipt_url($messenger = 'html') |
||
836 | |||
837 | |||
838 | /** |
||
839 | * Gets the string which represents the URL trigger for the invoice template in the message template system. |
||
840 | * |
||
841 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
||
842 | * @return string |
||
843 | * @throws EE_Error |
||
844 | */ |
||
845 | public function invoice_url($messenger = 'html') |
||
876 | |||
877 | |||
878 | /** |
||
879 | * get Registration URL Link |
||
880 | * |
||
881 | * @access public |
||
882 | * @return string |
||
883 | * @throws EE_Error |
||
884 | */ |
||
885 | public function reg_url_link() |
||
889 | |||
890 | |||
891 | /** |
||
892 | * Echoes out invoice_url() |
||
893 | * |
||
894 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
||
895 | * @return void |
||
896 | * @throws EE_Error |
||
897 | */ |
||
898 | public function e_invoice_url($type = 'launch') |
||
902 | |||
903 | |||
904 | /** |
||
905 | * Echoes out payment_overview_url |
||
906 | */ |
||
907 | public function e_payment_overview_url() |
||
911 | |||
912 | |||
913 | /** |
||
914 | * Gets the URL for the checkout payment options reg step |
||
915 | * with this registration's REG_url_link added as a query parameter |
||
916 | * |
||
917 | * @param bool $clear_session Set to true when you want to clear the session on revisiting the |
||
918 | * payment overview url. |
||
919 | * @return string |
||
920 | * @throws InvalidInterfaceException |
||
921 | * @throws InvalidDataTypeException |
||
922 | * @throws EE_Error |
||
923 | * @throws InvalidArgumentException |
||
924 | */ |
||
925 | View Code Duplication | public function payment_overview_url($clear_session = false) |
|
941 | |||
942 | |||
943 | /** |
||
944 | * Gets the URL for the checkout attendee information reg step |
||
945 | * with this registration's REG_url_link added as a query parameter |
||
946 | * |
||
947 | * @return string |
||
948 | * @throws InvalidInterfaceException |
||
949 | * @throws InvalidDataTypeException |
||
950 | * @throws EE_Error |
||
951 | * @throws InvalidArgumentException |
||
952 | */ |
||
953 | View Code Duplication | public function edit_attendee_information_url() |
|
968 | |||
969 | |||
970 | /** |
||
971 | * Simply generates and returns the appropriate admin_url link to edit this registration |
||
972 | * |
||
973 | * @return string |
||
974 | * @throws EE_Error |
||
975 | */ |
||
976 | public function get_admin_edit_url() |
||
987 | |||
988 | |||
989 | /** |
||
990 | * is_primary_registrant? |
||
991 | */ |
||
992 | public function is_primary_registrant() |
||
996 | |||
997 | |||
998 | /** |
||
999 | * This returns the primary registration object for this registration group (which may be this object). |
||
1000 | * |
||
1001 | * @return EE_Registration |
||
1002 | * @throws EE_Error |
||
1003 | */ |
||
1004 | public function get_primary_registration() |
||
1022 | |||
1023 | |||
1024 | /** |
||
1025 | * get Attendee Number |
||
1026 | * |
||
1027 | * @access public |
||
1028 | */ |
||
1029 | public function count() |
||
1033 | |||
1034 | |||
1035 | /** |
||
1036 | * get Group Size |
||
1037 | */ |
||
1038 | public function group_size() |
||
1042 | |||
1043 | |||
1044 | /** |
||
1045 | * get Registration Date |
||
1046 | */ |
||
1047 | public function date() |
||
1051 | |||
1052 | |||
1053 | /** |
||
1054 | * gets a pretty date |
||
1055 | * |
||
1056 | * @param string $date_format |
||
1057 | * @param string $time_format |
||
1058 | * @return string |
||
1059 | * @throws EE_Error |
||
1060 | */ |
||
1061 | public function pretty_date($date_format = null, $time_format = null) |
||
1065 | |||
1066 | |||
1067 | /** |
||
1068 | * final_price |
||
1069 | * the registration's share of the transaction total, so that the |
||
1070 | * sum of all the transaction's REG_final_prices equal the transaction's total |
||
1071 | * |
||
1072 | * @return float |
||
1073 | * @throws EE_Error |
||
1074 | */ |
||
1075 | public function final_price() |
||
1079 | |||
1080 | |||
1081 | /** |
||
1082 | * pretty_final_price |
||
1083 | * final price as formatted string, with correct decimal places and currency symbol |
||
1084 | * |
||
1085 | * @return string |
||
1086 | * @throws EE_Error |
||
1087 | */ |
||
1088 | public function pretty_final_price() |
||
1092 | |||
1093 | |||
1094 | /** |
||
1095 | * get paid (yeah) |
||
1096 | * |
||
1097 | * @return float |
||
1098 | * @throws EE_Error |
||
1099 | */ |
||
1100 | public function paid() |
||
1104 | |||
1105 | |||
1106 | /** |
||
1107 | * pretty_paid |
||
1108 | * |
||
1109 | * @return float |
||
1110 | * @throws EE_Error |
||
1111 | */ |
||
1112 | public function pretty_paid() |
||
1116 | |||
1117 | |||
1118 | /** |
||
1119 | * owes_monies_and_can_pay |
||
1120 | * whether or not this registration has monies owing and it's' status allows payment |
||
1121 | * |
||
1122 | * @param array $requires_payment |
||
1123 | * @return bool |
||
1124 | * @throws EE_Error |
||
1125 | */ |
||
1126 | public function owes_monies_and_can_pay($requires_payment = array()) |
||
1141 | |||
1142 | |||
1143 | /** |
||
1144 | * Prints out the return value of $this->pretty_status() |
||
1145 | * |
||
1146 | * @param bool $show_icons |
||
1147 | * @return void |
||
1148 | * @throws EE_Error |
||
1149 | */ |
||
1150 | public function e_pretty_status($show_icons = false) |
||
1154 | |||
1155 | |||
1156 | /** |
||
1157 | * Returns a nice version of the status for displaying to customers |
||
1158 | * |
||
1159 | * @param bool $show_icons |
||
1160 | * @return string |
||
1161 | * @throws EE_Error |
||
1162 | */ |
||
1163 | public function pretty_status($show_icons = false) |
||
1210 | |||
1211 | |||
1212 | /** |
||
1213 | * get Attendee Is Going |
||
1214 | */ |
||
1215 | public function att_is_going() |
||
1219 | |||
1220 | |||
1221 | /** |
||
1222 | * Gets related answers |
||
1223 | * |
||
1224 | * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
||
1225 | * @return EE_Answer[] |
||
1226 | * @throws EE_Error |
||
1227 | */ |
||
1228 | public function answers($query_params = null) |
||
1232 | |||
1233 | |||
1234 | /** |
||
1235 | * Gets the registration's answer value to the specified question |
||
1236 | * (either the question's ID or a question object) |
||
1237 | * |
||
1238 | * @param EE_Question|int $question |
||
1239 | * @param bool $pretty_value |
||
1240 | * @return array|string if pretty_value= true, the result will always be a string |
||
1241 | * (because the answer might be an array of answer values, so passing pretty_value=true |
||
1242 | * will convert it into some kind of string) |
||
1243 | * @throws EE_Error |
||
1244 | */ |
||
1245 | public function answer_value_to_question($question, $pretty_value = true) |
||
1250 | |||
1251 | |||
1252 | /** |
||
1253 | * question_groups |
||
1254 | * returns an array of EE_Question_Group objects for this registration |
||
1255 | * |
||
1256 | * @return EE_Question_Group[] |
||
1257 | * @throws EE_Error |
||
1258 | * @throws EntityNotFoundException |
||
1259 | */ |
||
1260 | public function question_groups() |
||
1275 | |||
1276 | |||
1277 | /** |
||
1278 | * count_question_groups |
||
1279 | * returns a count of the number of EE_Question_Group objects for this registration |
||
1280 | * |
||
1281 | * @return int |
||
1282 | * @throws EE_Error |
||
1283 | * @throws EntityNotFoundException |
||
1284 | */ |
||
1285 | public function count_question_groups() |
||
1300 | |||
1301 | |||
1302 | /** |
||
1303 | * Returns the registration date in the 'standard' string format |
||
1304 | * (function may be improved in the future to allow for different formats and timezones) |
||
1305 | * |
||
1306 | * @return string |
||
1307 | * @throws EE_Error |
||
1308 | */ |
||
1309 | public function reg_date() |
||
1313 | |||
1314 | |||
1315 | /** |
||
1316 | * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
||
1317 | * the ticket this registration purchased, or the datetime they have registered |
||
1318 | * to attend) |
||
1319 | * |
||
1320 | * @return EE_Datetime_Ticket |
||
1321 | * @throws EE_Error |
||
1322 | */ |
||
1323 | public function datetime_ticket() |
||
1327 | |||
1328 | |||
1329 | /** |
||
1330 | * Sets the registration's datetime_ticket. |
||
1331 | * |
||
1332 | * @param EE_Datetime_Ticket $datetime_ticket |
||
1333 | * @return EE_Datetime_Ticket |
||
1334 | * @throws EE_Error |
||
1335 | */ |
||
1336 | public function set_datetime_ticket($datetime_ticket) |
||
1340 | |||
1341 | /** |
||
1342 | * Gets deleted |
||
1343 | * |
||
1344 | * @return bool |
||
1345 | * @throws EE_Error |
||
1346 | */ |
||
1347 | public function deleted() |
||
1351 | |||
1352 | /** |
||
1353 | * Sets deleted |
||
1354 | * |
||
1355 | * @param boolean $deleted |
||
1356 | * @return bool |
||
1357 | * @throws EE_Error |
||
1358 | * @throws RuntimeException |
||
1359 | */ |
||
1360 | public function set_deleted($deleted) |
||
1368 | |||
1369 | |||
1370 | /** |
||
1371 | * Get the status object of this object |
||
1372 | * |
||
1373 | * @return EE_Status |
||
1374 | * @throws EE_Error |
||
1375 | */ |
||
1376 | public function status_obj() |
||
1380 | |||
1381 | |||
1382 | /** |
||
1383 | * Returns the number of times this registration has checked into any of the datetimes |
||
1384 | * its available for |
||
1385 | * |
||
1386 | * @return int |
||
1387 | * @throws EE_Error |
||
1388 | */ |
||
1389 | public function count_checkins() |
||
1393 | |||
1394 | |||
1395 | /** |
||
1396 | * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
||
1397 | * registration is for. Note, this is ONLY checked in (does not include checkedout) |
||
1398 | * |
||
1399 | * @return int |
||
1400 | * @throws EE_Error |
||
1401 | */ |
||
1402 | public function count_checkins_not_checkedout() |
||
1406 | |||
1407 | |||
1408 | /** |
||
1409 | * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
||
1410 | * |
||
1411 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
||
1412 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
||
1413 | * consider registration status as well as datetime access. |
||
1414 | * @return bool |
||
1415 | * @throws EE_Error |
||
1416 | */ |
||
1417 | public function can_checkin($DTT_OR_ID, $check_approved = true) |
||
1441 | |||
1442 | |||
1443 | /** |
||
1444 | * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
||
1445 | * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
||
1446 | * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
||
1447 | * then return false. Otherwise return true. |
||
1448 | * |
||
1449 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
||
1450 | * @return bool true means can checkin. false means cannot checkin. |
||
1451 | * @throws EE_Error |
||
1452 | */ |
||
1453 | public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
||
1503 | |||
1504 | |||
1505 | /** |
||
1506 | * toggle Check-in status for this registration |
||
1507 | * Check-ins are toggled in the following order: |
||
1508 | * never checked in -> checked in |
||
1509 | * checked in -> checked out |
||
1510 | * checked out -> checked in |
||
1511 | * |
||
1512 | * @param int $DTT_ID include specific datetime to toggle Check-in for. |
||
1513 | * If not included or null, then it is assumed latest datetime is being toggled. |
||
1514 | * @param bool $verify If true then can_checkin() is used to verify whether the person |
||
1515 | * can be checked in or not. Otherwise this forces change in checkin status. |
||
1516 | * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
||
1517 | * @throws EE_Error |
||
1518 | */ |
||
1519 | public function toggle_checkin_status($DTT_ID = null, $verify = false) |
||
1586 | |||
1587 | |||
1588 | /** |
||
1589 | * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
||
1590 | * "Latest" is defined by the `DTT_EVT_start` column. |
||
1591 | * |
||
1592 | * @return EE_Datetime|null |
||
1593 | * @throws EE_Error |
||
1594 | */ |
||
1595 | View Code Duplication | public function get_latest_related_datetime() |
|
1606 | |||
1607 | |||
1608 | /** |
||
1609 | * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
||
1610 | * "Earliest" is defined by the `DTT_EVT_start` column. |
||
1611 | * |
||
1612 | * @throws EE_Error |
||
1613 | */ |
||
1614 | View Code Duplication | public function get_earliest_related_datetime() |
|
1625 | |||
1626 | |||
1627 | /** |
||
1628 | * This method simply returns the check-in status for this registration and the given datetime. |
||
1629 | * If neither the datetime nor the checkin values are provided as arguments, |
||
1630 | * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
||
1631 | * |
||
1632 | * @param int $DTT_ID The ID of the datetime we're checking against |
||
1633 | * (if empty we'll get the primary datetime for |
||
1634 | * this registration (via event) and use it's ID); |
||
1635 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
||
1636 | * |
||
1637 | * @return int Integer representing Check-in status. |
||
1638 | * @throws EE_Error |
||
1639 | */ |
||
1640 | public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
||
1662 | |||
1663 | |||
1664 | /** |
||
1665 | * This method returns a localized message for the toggled Check-in message. |
||
1666 | * |
||
1667 | * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
||
1668 | * then it is assumed Check-in for primary datetime was toggled. |
||
1669 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
||
1670 | * message can be customized with the attendee name. |
||
1671 | * @return string internationalized message |
||
1672 | * @throws EE_Error |
||
1673 | */ |
||
1674 | public function get_checkin_msg($DTT_ID, $error = false) |
||
1701 | |||
1702 | |||
1703 | /** |
||
1704 | * Returns the related EE_Transaction to this registration |
||
1705 | * |
||
1706 | * @return EE_Transaction |
||
1707 | * @throws EE_Error |
||
1708 | * @throws EntityNotFoundException |
||
1709 | */ |
||
1710 | public function transaction() |
||
1718 | |||
1719 | |||
1720 | /** |
||
1721 | * get Registration Code |
||
1722 | */ |
||
1723 | public function reg_code() |
||
1727 | |||
1728 | |||
1729 | /** |
||
1730 | * get Transaction ID |
||
1731 | */ |
||
1732 | public function transaction_ID() |
||
1736 | |||
1737 | |||
1738 | /** |
||
1739 | * @return int |
||
1740 | * @throws EE_Error |
||
1741 | */ |
||
1742 | public function ticket_ID() |
||
1746 | |||
1747 | |||
1748 | /** |
||
1749 | * Set Registration Code |
||
1750 | * |
||
1751 | * @access public |
||
1752 | * @param string $REG_code Registration Code |
||
1753 | * @param boolean $use_default |
||
1754 | * @throws EE_Error |
||
1755 | */ |
||
1756 | public function set_reg_code($REG_code, $use_default = false) |
||
1777 | |||
1778 | |||
1779 | /** |
||
1780 | * Returns all other registrations in the same group as this registrant who have the same ticket option. |
||
1781 | * Note, if you want to just get all registrations in the same transaction (group), use: |
||
1782 | * $registration->transaction()->registrations(); |
||
1783 | * |
||
1784 | * @since 4.5.0 |
||
1785 | * @return EE_Registration[] or empty array if this isn't a group registration. |
||
1786 | * @throws EE_Error |
||
1787 | */ |
||
1788 | public function get_all_other_registrations_in_group() |
||
1803 | |||
1804 | /** |
||
1805 | * Return the link to the admin details for the object. |
||
1806 | * |
||
1807 | * @return string |
||
1808 | * @throws EE_Error |
||
1809 | */ |
||
1810 | View Code Duplication | public function get_admin_details_link() |
|
1822 | |||
1823 | /** |
||
1824 | * Returns the link to the editor for the object. Sometimes this is the same as the details. |
||
1825 | * |
||
1826 | * @return string |
||
1827 | * @throws EE_Error |
||
1828 | */ |
||
1829 | public function get_admin_edit_link() |
||
1833 | |||
1834 | /** |
||
1835 | * Returns the link to a settings page for the object. |
||
1836 | * |
||
1837 | * @return string |
||
1838 | * @throws EE_Error |
||
1839 | */ |
||
1840 | public function get_admin_settings_link() |
||
1844 | |||
1845 | /** |
||
1846 | * Returns the link to the "overview" for the object (typically the "list table" view). |
||
1847 | * |
||
1848 | * @return string |
||
1849 | */ |
||
1850 | public function get_admin_overview_link() |
||
1860 | |||
1861 | |||
1862 | /** |
||
1863 | * @param array $query_params |
||
1864 | * |
||
1865 | * @return \EE_Registration[] |
||
1866 | * @throws EE_Error |
||
1867 | */ |
||
1868 | public function payments($query_params = array()) |
||
1872 | |||
1873 | |||
1874 | /** |
||
1875 | * @param array $query_params |
||
1876 | * |
||
1877 | * @return \EE_Registration_Payment[] |
||
1878 | * @throws EE_Error |
||
1879 | */ |
||
1880 | public function registration_payments($query_params = array()) |
||
1884 | |||
1885 | |||
1886 | /** |
||
1887 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
||
1888 | * Note: if there are no payments on the registration there will be no payment method returned. |
||
1889 | * |
||
1890 | * @return EE_Payment_Method|null |
||
1891 | */ |
||
1892 | public function payment_method() |
||
1896 | |||
1897 | |||
1898 | /** |
||
1899 | * @return \EE_Line_Item |
||
1900 | * @throws EntityNotFoundException |
||
1901 | * @throws EE_Error |
||
1902 | */ |
||
1903 | public function ticket_line_item() |
||
1927 | |||
1928 | |||
1929 | /** |
||
1930 | * Soft Deletes this model object. |
||
1931 | * |
||
1932 | * @return boolean | int |
||
1933 | * @throws RuntimeException |
||
1934 | * @throws EE_Error |
||
1935 | */ |
||
1936 | public function delete() |
||
1943 | |||
1944 | |||
1945 | /** |
||
1946 | * Restores whatever the previous status was on a registration before it was trashed (if possible) |
||
1947 | * |
||
1948 | * @throws EE_Error |
||
1949 | * @throws RuntimeException |
||
1950 | */ |
||
1951 | public function restore() |
||
1964 | |||
1965 | |||
1966 | /** |
||
1967 | * possibly toggle Registration status based on comparison of REG_paid vs REG_final_price |
||
1968 | * |
||
1969 | * @param boolean $trigger_set_status_logic EE_Registration::set_status() can trigger additional logic |
||
1970 | * depending on whether the reg status changes to or from "Approved" |
||
1971 | * @return boolean whether the Registration status was updated |
||
1972 | * @throws EE_Error |
||
1973 | * @throws RuntimeException |
||
1974 | */ |
||
1975 | public function updateStatusBasedOnTotalPaid($trigger_set_status_logic = true) |
||
2004 | |||
2005 | |||
2006 | /*************************** DEPRECATED ***************************/ |
||
2007 | |||
2008 | |||
2009 | /** |
||
2010 | * @deprecated |
||
2011 | * @since 4.7.0 |
||
2012 | * @access public |
||
2013 | */ |
||
2014 | public function price_paid() |
||
2026 | |||
2027 | |||
2028 | /** |
||
2029 | * @deprecated |
||
2030 | * @since 4.7.0 |
||
2031 | * @access public |
||
2032 | * @param float $REG_final_price |
||
2033 | * @throws EE_Error |
||
2034 | * @throws RuntimeException |
||
2035 | */ |
||
2036 | public function set_price_paid($REG_final_price = 0.00) |
||
2048 | |||
2049 | |||
2050 | /** |
||
2051 | * @deprecated |
||
2052 | * @since 4.7.0 |
||
2053 | * @return string |
||
2054 | * @throws EE_Error |
||
2055 | */ |
||
2056 | public function pretty_price_paid() |
||
2068 | |||
2069 | |||
2070 | /** |
||
2071 | * Gets the primary datetime related to this registration via the related Event to this registration |
||
2072 | * |
||
2073 | * @deprecated 4.9.17 |
||
2074 | * @return EE_Datetime |
||
2075 | * @throws EE_Error |
||
2076 | * @throws EntityNotFoundException |
||
2077 | */ |
||
2078 | public function get_related_primary_datetime() |
||
2091 | } |
||
2092 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.