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 |
||
| 17 | class EE_Registration extends EE_Soft_Delete_Base_Class implements EEI_Registration, EEI_Admin_Links |
||
| 18 | { |
||
| 19 | |||
| 20 | |||
| 21 | /** |
||
| 22 | * Used to reference when a registration has never been checked in. |
||
| 23 | * |
||
| 24 | * @deprecated use \EE_Checkin::status_checked_never instead |
||
| 25 | * @type int |
||
| 26 | */ |
||
| 27 | const checkin_status_never = 2; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Used to reference when a registration has been checked in. |
||
| 31 | * |
||
| 32 | * @deprecated use \EE_Checkin::status_checked_in instead |
||
| 33 | * @type int |
||
| 34 | */ |
||
| 35 | const checkin_status_in = 1; |
||
| 36 | |||
| 37 | |||
| 38 | /** |
||
| 39 | * Used to reference when a registration has been checked out. |
||
| 40 | * |
||
| 41 | * @deprecated use \EE_Checkin::status_checked_out instead |
||
| 42 | * @type int |
||
| 43 | */ |
||
| 44 | const checkin_status_out = 0; |
||
| 45 | |||
| 46 | |||
| 47 | /** |
||
| 48 | * extra meta key for tracking reg status os trashed registrations |
||
| 49 | * |
||
| 50 | * @type string |
||
| 51 | */ |
||
| 52 | const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
||
| 53 | |||
| 54 | |||
| 55 | /** |
||
| 56 | * extra meta key for tracking if registration has reserved ticket |
||
| 57 | * |
||
| 58 | * @type string |
||
| 59 | */ |
||
| 60 | const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
||
| 61 | |||
| 62 | |||
| 63 | /** |
||
| 64 | * @param array $props_n_values incoming values |
||
| 65 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
| 66 | * used.) |
||
| 67 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
| 68 | * date_format and the second value is the time format |
||
| 69 | * @return EE_Registration |
||
| 70 | * @throws EE_Error |
||
| 71 | */ |
||
| 72 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
| 77 | |||
| 78 | |||
| 79 | /** |
||
| 80 | * @param array $props_n_values incoming values from the database |
||
| 81 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
| 82 | * the website will be used. |
||
| 83 | * @return EE_Registration |
||
| 84 | */ |
||
| 85 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
| 89 | |||
| 90 | |||
| 91 | /** |
||
| 92 | * Set Event ID |
||
| 93 | * |
||
| 94 | * @param int $EVT_ID Event ID |
||
| 95 | * @throws EE_Error |
||
| 96 | * @throws RuntimeException |
||
| 97 | */ |
||
| 98 | public function set_event($EVT_ID = 0) |
||
| 102 | |||
| 103 | |||
| 104 | /** |
||
| 105 | * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
||
| 106 | * be routed to internal methods |
||
| 107 | * |
||
| 108 | * @param string $field_name |
||
| 109 | * @param mixed $field_value |
||
| 110 | * @param bool $use_default |
||
| 111 | * @throws EE_Error |
||
| 112 | * @throws EntityNotFoundException |
||
| 113 | * @throws InvalidArgumentException |
||
| 114 | * @throws InvalidDataTypeException |
||
| 115 | * @throws InvalidInterfaceException |
||
| 116 | * @throws ReflectionException |
||
| 117 | * @throws RuntimeException |
||
| 118 | */ |
||
| 119 | public function set($field_name, $field_value, $use_default = false) |
||
| 134 | |||
| 135 | |||
| 136 | /** |
||
| 137 | * Set Status ID |
||
| 138 | * updates the registration status and ALSO... |
||
| 139 | * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
||
| 140 | * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
||
| 141 | * |
||
| 142 | * @param string $new_STS_ID |
||
| 143 | * @param boolean $use_default |
||
| 144 | * @param Context|null $context |
||
| 145 | * @return bool |
||
| 146 | * @throws EE_Error |
||
| 147 | * @throws EntityNotFoundException |
||
| 148 | * @throws InvalidArgumentException |
||
| 149 | * @throws ReflectionException |
||
| 150 | * @throws RuntimeException |
||
| 151 | * @throws InvalidDataTypeException |
||
| 152 | * @throws InvalidInterfaceException |
||
| 153 | */ |
||
| 154 | public function set_status($new_STS_ID = null, $use_default = false, Context $context = null) |
||
| 195 | |||
| 196 | |||
| 197 | /** |
||
| 198 | * update REGs and TXN when cancelled or declined registrations involved |
||
| 199 | * |
||
| 200 | * @param string $new_STS_ID |
||
| 201 | * @param string $old_STS_ID |
||
| 202 | * @param Context|null $context |
||
| 203 | * @throws EE_Error |
||
| 204 | * @throws InvalidArgumentException |
||
| 205 | * @throws InvalidDataTypeException |
||
| 206 | * @throws InvalidInterfaceException |
||
| 207 | * @throws ReflectionException |
||
| 208 | */ |
||
| 209 | private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, Context $context = null) |
||
| 227 | |||
| 228 | |||
| 229 | /** |
||
| 230 | * update REGs and TXN when cancelled or declined registrations involved |
||
| 231 | * |
||
| 232 | * @param array $closed_reg_statuses |
||
| 233 | * @param string $new_STS_ID |
||
| 234 | * @param string $old_STS_ID |
||
| 235 | * @param Context|null $context |
||
| 236 | * @throws EE_Error |
||
| 237 | * @throws InvalidArgumentException |
||
| 238 | * @throws InvalidDataTypeException |
||
| 239 | * @throws InvalidInterfaceException |
||
| 240 | * @throws ReflectionException |
||
| 241 | */ |
||
| 242 | View Code Duplication | private function updateIfCanceled(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, Context $context = null) |
|
| 272 | |||
| 273 | |||
| 274 | /** |
||
| 275 | * update REGs and TXN when cancelled or declined registrations involved |
||
| 276 | * |
||
| 277 | * @param array $closed_reg_statuses |
||
| 278 | * @param string $new_STS_ID |
||
| 279 | * @param string $old_STS_ID |
||
| 280 | * @param Context|null $context |
||
| 281 | * @throws EE_Error |
||
| 282 | * @throws InvalidArgumentException |
||
| 283 | * @throws InvalidDataTypeException |
||
| 284 | * @throws InvalidInterfaceException |
||
| 285 | * @throws ReflectionException |
||
| 286 | */ |
||
| 287 | View Code Duplication | private function updateIfDeclined(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, Context $context = null) |
|
| 316 | |||
| 317 | |||
| 318 | /** |
||
| 319 | * @param Context|null $context |
||
| 320 | * @return bool |
||
| 321 | */ |
||
| 322 | private function statusChangeUpdatesTransaction(Context $context = null) |
||
| 335 | |||
| 336 | |||
| 337 | /** |
||
| 338 | * @throws EE_Error |
||
| 339 | * @throws EntityNotFoundException |
||
| 340 | * @throws InvalidArgumentException |
||
| 341 | * @throws InvalidDataTypeException |
||
| 342 | * @throws InvalidInterfaceException |
||
| 343 | * @throws ReflectionException |
||
| 344 | * @throws RuntimeException |
||
| 345 | */ |
||
| 346 | private function updateTransactionAfterStatusChange() |
||
| 353 | |||
| 354 | |||
| 355 | /** |
||
| 356 | * get Status ID |
||
| 357 | */ |
||
| 358 | public function status_ID() |
||
| 362 | |||
| 363 | |||
| 364 | /** |
||
| 365 | * increments this registration's related ticket sold and corresponding datetime sold values |
||
| 366 | * |
||
| 367 | * @return void |
||
| 368 | * @throws EE_Error |
||
| 369 | * @throws EntityNotFoundException |
||
| 370 | */ |
||
| 371 | private function _reserve_registration_space() |
||
| 382 | |||
| 383 | |||
| 384 | /** |
||
| 385 | * Gets the ticket this registration is for |
||
| 386 | * |
||
| 387 | * @param boolean $include_archived whether to include archived tickets or not. |
||
| 388 | * |
||
| 389 | * @return EE_Ticket|EE_Base_Class |
||
| 390 | * @throws EE_Error |
||
| 391 | */ |
||
| 392 | public function ticket($include_archived = true) |
||
| 400 | |||
| 401 | |||
| 402 | /** |
||
| 403 | * Gets the event this registration is for |
||
| 404 | * |
||
| 405 | * @return EE_Event |
||
| 406 | * @throws EE_Error |
||
| 407 | * @throws EntityNotFoundException |
||
| 408 | */ |
||
| 409 | public function event() |
||
| 417 | |||
| 418 | |||
| 419 | /** |
||
| 420 | * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
||
| 421 | * with the author of the event this registration is for. |
||
| 422 | * |
||
| 423 | * @since 4.5.0 |
||
| 424 | * @return int |
||
| 425 | * @throws EE_Error |
||
| 426 | * @throws EntityNotFoundException |
||
| 427 | */ |
||
| 428 | public function wp_user() |
||
| 436 | |||
| 437 | |||
| 438 | /** |
||
| 439 | * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
||
| 440 | * |
||
| 441 | * @return void |
||
| 442 | * @throws EE_Error |
||
| 443 | */ |
||
| 444 | private function _release_registration_space() |
||
| 450 | |||
| 451 | |||
| 452 | /** |
||
| 453 | * tracks this registration's ticket reservation in extra meta |
||
| 454 | * and can increment related ticket reserved and corresponding datetime reserved values |
||
| 455 | * |
||
| 456 | * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
||
| 457 | * |
||
| 458 | * @return void |
||
| 459 | * @throws EE_Error |
||
| 460 | */ |
||
| 461 | public function reserve_ticket($update_ticket = false) |
||
| 473 | |||
| 474 | |||
| 475 | /** |
||
| 476 | * stops tracking this registration's ticket reservation in extra meta |
||
| 477 | * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
||
| 478 | * |
||
| 479 | * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
||
| 480 | * |
||
| 481 | * @return void |
||
| 482 | * @throws EE_Error |
||
| 483 | */ |
||
| 484 | public function release_reserved_ticket($update_ticket = false) |
||
| 496 | |||
| 497 | |||
| 498 | /** |
||
| 499 | * Set Attendee ID |
||
| 500 | * |
||
| 501 | * @param int $ATT_ID Attendee ID |
||
| 502 | * @throws EE_Error |
||
| 503 | * @throws RuntimeException |
||
| 504 | */ |
||
| 505 | public function set_attendee_id($ATT_ID = 0) |
||
| 509 | |||
| 510 | |||
| 511 | /** |
||
| 512 | * Set Transaction ID |
||
| 513 | * |
||
| 514 | * @param int $TXN_ID Transaction ID |
||
| 515 | * @throws EE_Error |
||
| 516 | * @throws RuntimeException |
||
| 517 | */ |
||
| 518 | public function set_transaction_id($TXN_ID = 0) |
||
| 522 | |||
| 523 | |||
| 524 | /** |
||
| 525 | * Set Session |
||
| 526 | * |
||
| 527 | * @param string $REG_session PHP Session ID |
||
| 528 | * @throws EE_Error |
||
| 529 | * @throws RuntimeException |
||
| 530 | */ |
||
| 531 | public function set_session($REG_session = '') |
||
| 535 | |||
| 536 | |||
| 537 | /** |
||
| 538 | * Set Registration URL Link |
||
| 539 | * |
||
| 540 | * @param string $REG_url_link Registration URL Link |
||
| 541 | * @throws EE_Error |
||
| 542 | * @throws RuntimeException |
||
| 543 | */ |
||
| 544 | public function set_reg_url_link($REG_url_link = '') |
||
| 548 | |||
| 549 | |||
| 550 | /** |
||
| 551 | * Set Attendee Counter |
||
| 552 | * |
||
| 553 | * @param int $REG_count Primary Attendee |
||
| 554 | * @throws EE_Error |
||
| 555 | * @throws RuntimeException |
||
| 556 | */ |
||
| 557 | public function set_count($REG_count = 1) |
||
| 561 | |||
| 562 | |||
| 563 | /** |
||
| 564 | * Set Group Size |
||
| 565 | * |
||
| 566 | * @param boolean $REG_group_size Group Registration |
||
| 567 | * @throws EE_Error |
||
| 568 | * @throws RuntimeException |
||
| 569 | */ |
||
| 570 | public function set_group_size($REG_group_size = false) |
||
| 574 | |||
| 575 | |||
| 576 | /** |
||
| 577 | * is_not_approved - convenience method that returns TRUE if REG status ID == |
||
| 578 | * EEM_Registration::status_id_not_approved |
||
| 579 | * |
||
| 580 | * @return boolean |
||
| 581 | */ |
||
| 582 | public function is_not_approved() |
||
| 586 | |||
| 587 | |||
| 588 | /** |
||
| 589 | * is_pending_payment - convenience method that returns TRUE if REG status ID == |
||
| 590 | * EEM_Registration::status_id_pending_payment |
||
| 591 | * |
||
| 592 | * @return boolean |
||
| 593 | */ |
||
| 594 | public function is_pending_payment() |
||
| 598 | |||
| 599 | |||
| 600 | /** |
||
| 601 | * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
||
| 602 | * |
||
| 603 | * @return boolean |
||
| 604 | */ |
||
| 605 | public function is_approved() |
||
| 609 | |||
| 610 | |||
| 611 | /** |
||
| 612 | * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
||
| 613 | * |
||
| 614 | * @return boolean |
||
| 615 | */ |
||
| 616 | public function is_cancelled() |
||
| 620 | |||
| 621 | |||
| 622 | /** |
||
| 623 | * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
||
| 624 | * |
||
| 625 | * @return boolean |
||
| 626 | */ |
||
| 627 | public function is_declined() |
||
| 631 | |||
| 632 | |||
| 633 | /** |
||
| 634 | * is_incomplete - convenience method that returns TRUE if REG status ID == |
||
| 635 | * EEM_Registration::status_id_incomplete |
||
| 636 | * |
||
| 637 | * @return boolean |
||
| 638 | */ |
||
| 639 | public function is_incomplete() |
||
| 643 | |||
| 644 | |||
| 645 | /** |
||
| 646 | * Set Registration Date |
||
| 647 | * |
||
| 648 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
||
| 649 | * Date |
||
| 650 | * @throws EE_Error |
||
| 651 | * @throws RuntimeException |
||
| 652 | */ |
||
| 653 | public function set_reg_date($REG_date = false) |
||
| 657 | |||
| 658 | |||
| 659 | /** |
||
| 660 | * Set final price owing for this registration after all ticket/price modifications |
||
| 661 | * |
||
| 662 | * @access public |
||
| 663 | * @param float $REG_final_price |
||
| 664 | * @throws EE_Error |
||
| 665 | * @throws RuntimeException |
||
| 666 | */ |
||
| 667 | public function set_final_price($REG_final_price = 0.00) |
||
| 671 | |||
| 672 | |||
| 673 | /** |
||
| 674 | * Set amount paid towards this registration's final price |
||
| 675 | * |
||
| 676 | * @access public |
||
| 677 | * @param float $REG_paid |
||
| 678 | * @throws EE_Error |
||
| 679 | * @throws RuntimeException |
||
| 680 | */ |
||
| 681 | public function set_paid($REG_paid = 0.00) |
||
| 685 | |||
| 686 | |||
| 687 | /** |
||
| 688 | * Attendee Is Going |
||
| 689 | * |
||
| 690 | * @param boolean $REG_att_is_going Attendee Is Going |
||
| 691 | * @throws EE_Error |
||
| 692 | * @throws RuntimeException |
||
| 693 | */ |
||
| 694 | public function set_att_is_going($REG_att_is_going = false) |
||
| 698 | |||
| 699 | |||
| 700 | /** |
||
| 701 | * Gets the related attendee |
||
| 702 | * |
||
| 703 | * @return EE_Attendee |
||
| 704 | * @throws EE_Error |
||
| 705 | */ |
||
| 706 | public function attendee() |
||
| 710 | |||
| 711 | |||
| 712 | /** |
||
| 713 | * get Event ID |
||
| 714 | */ |
||
| 715 | public function event_ID() |
||
| 719 | |||
| 720 | |||
| 721 | /** |
||
| 722 | * get Event ID |
||
| 723 | */ |
||
| 724 | public function event_name() |
||
| 733 | |||
| 734 | |||
| 735 | /** |
||
| 736 | * Fetches the event this registration is for |
||
| 737 | * |
||
| 738 | * @return EE_Event |
||
| 739 | * @throws EE_Error |
||
| 740 | */ |
||
| 741 | public function event_obj() |
||
| 745 | |||
| 746 | |||
| 747 | /** |
||
| 748 | * get Attendee ID |
||
| 749 | */ |
||
| 750 | public function attendee_ID() |
||
| 754 | |||
| 755 | |||
| 756 | /** |
||
| 757 | * get PHP Session ID |
||
| 758 | */ |
||
| 759 | public function session_ID() |
||
| 763 | |||
| 764 | |||
| 765 | /** |
||
| 766 | * Gets the string which represents the URL trigger for the receipt template in the message template system. |
||
| 767 | * |
||
| 768 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
||
| 769 | * @return string |
||
| 770 | */ |
||
| 771 | public function receipt_url($messenger = 'html') |
||
| 794 | |||
| 795 | |||
| 796 | /** |
||
| 797 | * Gets the string which represents the URL trigger for the invoice template in the message template system. |
||
| 798 | * |
||
| 799 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
||
| 800 | * @return string |
||
| 801 | * @throws EE_Error |
||
| 802 | */ |
||
| 803 | public function invoice_url($messenger = 'html') |
||
| 834 | |||
| 835 | |||
| 836 | /** |
||
| 837 | * get Registration URL Link |
||
| 838 | * |
||
| 839 | * @access public |
||
| 840 | * @return string |
||
| 841 | * @throws EE_Error |
||
| 842 | */ |
||
| 843 | public function reg_url_link() |
||
| 847 | |||
| 848 | |||
| 849 | /** |
||
| 850 | * Echoes out invoice_url() |
||
| 851 | * |
||
| 852 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
||
| 853 | * @return void |
||
| 854 | * @throws EE_Error |
||
| 855 | */ |
||
| 856 | public function e_invoice_url($type = 'launch') |
||
| 860 | |||
| 861 | |||
| 862 | /** |
||
| 863 | * Echoes out payment_overview_url |
||
| 864 | */ |
||
| 865 | public function e_payment_overview_url() |
||
| 869 | |||
| 870 | |||
| 871 | /** |
||
| 872 | * Gets the URL of the thank you page with this registration REG_url_link added as |
||
| 873 | * a query parameter |
||
| 874 | * |
||
| 875 | * @param bool $clear_session Set to true when you want to clear the session on revisiting the |
||
| 876 | * payment overview url. |
||
| 877 | * @return string |
||
| 878 | * @throws EE_Error |
||
| 879 | */ |
||
| 880 | View Code Duplication | public function payment_overview_url($clear_session = false) |
|
| 889 | |||
| 890 | |||
| 891 | /** |
||
| 892 | * Gets the URL of the thank you page with this registration REG_url_link added as |
||
| 893 | * a query parameter |
||
| 894 | * |
||
| 895 | * @return string |
||
| 896 | * @throws EE_Error |
||
| 897 | */ |
||
| 898 | View Code Duplication | public function edit_attendee_information_url() |
|
| 906 | |||
| 907 | |||
| 908 | /** |
||
| 909 | * Simply generates and returns the appropriate admin_url link to edit this registration |
||
| 910 | * |
||
| 911 | * @return string |
||
| 912 | * @throws EE_Error |
||
| 913 | */ |
||
| 914 | public function get_admin_edit_url() |
||
| 922 | |||
| 923 | |||
| 924 | /** |
||
| 925 | * is_primary_registrant? |
||
| 926 | */ |
||
| 927 | public function is_primary_registrant() |
||
| 931 | |||
| 932 | |||
| 933 | /** |
||
| 934 | * This returns the primary registration object for this registration group (which may be this object). |
||
| 935 | * |
||
| 936 | * @return EE_Registration |
||
| 937 | * @throws EE_Error |
||
| 938 | */ |
||
| 939 | public function get_primary_registration() |
||
| 955 | |||
| 956 | |||
| 957 | /** |
||
| 958 | * get Attendee Number |
||
| 959 | * |
||
| 960 | * @access public |
||
| 961 | */ |
||
| 962 | public function count() |
||
| 966 | |||
| 967 | |||
| 968 | /** |
||
| 969 | * get Group Size |
||
| 970 | */ |
||
| 971 | public function group_size() |
||
| 975 | |||
| 976 | |||
| 977 | /** |
||
| 978 | * get Registration Date |
||
| 979 | */ |
||
| 980 | public function date() |
||
| 984 | |||
| 985 | |||
| 986 | /** |
||
| 987 | * gets a pretty date |
||
| 988 | * |
||
| 989 | * @param string $date_format |
||
| 990 | * @param string $time_format |
||
| 991 | * @return string |
||
| 992 | * @throws EE_Error |
||
| 993 | */ |
||
| 994 | public function pretty_date($date_format = null, $time_format = null) |
||
| 998 | |||
| 999 | |||
| 1000 | /** |
||
| 1001 | * final_price |
||
| 1002 | * the registration's share of the transaction total, so that the |
||
| 1003 | * sum of all the transaction's REG_final_prices equal the transaction's total |
||
| 1004 | * |
||
| 1005 | * @return float |
||
| 1006 | * @throws EE_Error |
||
| 1007 | */ |
||
| 1008 | public function final_price() |
||
| 1012 | |||
| 1013 | |||
| 1014 | /** |
||
| 1015 | * pretty_final_price |
||
| 1016 | * final price as formatted string, with correct decimal places and currency symbol |
||
| 1017 | * |
||
| 1018 | * @return string |
||
| 1019 | * @throws EE_Error |
||
| 1020 | */ |
||
| 1021 | public function pretty_final_price() |
||
| 1025 | |||
| 1026 | |||
| 1027 | /** |
||
| 1028 | * get paid (yeah) |
||
| 1029 | * |
||
| 1030 | * @return float |
||
| 1031 | * @throws EE_Error |
||
| 1032 | */ |
||
| 1033 | public function paid() |
||
| 1037 | |||
| 1038 | |||
| 1039 | /** |
||
| 1040 | * pretty_paid |
||
| 1041 | * |
||
| 1042 | * @return float |
||
| 1043 | * @throws EE_Error |
||
| 1044 | */ |
||
| 1045 | public function pretty_paid() |
||
| 1049 | |||
| 1050 | |||
| 1051 | /** |
||
| 1052 | * owes_monies_and_can_pay |
||
| 1053 | * whether or not this registration has monies owing and it's' status allows payment |
||
| 1054 | * |
||
| 1055 | * @param array $requires_payment |
||
| 1056 | * @return bool |
||
| 1057 | * @throws EE_Error |
||
| 1058 | */ |
||
| 1059 | public function owes_monies_and_can_pay($requires_payment = array()) |
||
| 1074 | |||
| 1075 | |||
| 1076 | /** |
||
| 1077 | * Prints out the return value of $this->pretty_status() |
||
| 1078 | * |
||
| 1079 | * @param bool $show_icons |
||
| 1080 | * @return void |
||
| 1081 | * @throws EE_Error |
||
| 1082 | */ |
||
| 1083 | public function e_pretty_status($show_icons = false) |
||
| 1087 | |||
| 1088 | |||
| 1089 | /** |
||
| 1090 | * Returns a nice version of the status for displaying to customers |
||
| 1091 | * |
||
| 1092 | * @param bool $show_icons |
||
| 1093 | * @return string |
||
| 1094 | * @throws EE_Error |
||
| 1095 | */ |
||
| 1096 | public function pretty_status($show_icons = false) |
||
| 1143 | |||
| 1144 | |||
| 1145 | /** |
||
| 1146 | * get Attendee Is Going |
||
| 1147 | */ |
||
| 1148 | public function att_is_going() |
||
| 1152 | |||
| 1153 | |||
| 1154 | /** |
||
| 1155 | * Gets related answers |
||
| 1156 | * |
||
| 1157 | * @param array $query_params like EEM_Base::get_all |
||
| 1158 | * @return EE_Answer[] |
||
| 1159 | * @throws EE_Error |
||
| 1160 | */ |
||
| 1161 | public function answers($query_params = null) |
||
| 1165 | |||
| 1166 | |||
| 1167 | /** |
||
| 1168 | * Gets the registration's answer value to the specified question |
||
| 1169 | * (either the question's ID or a question object) |
||
| 1170 | * |
||
| 1171 | * @param EE_Question|int $question |
||
| 1172 | * @param bool $pretty_value |
||
| 1173 | * @return array|string if pretty_value= true, the result will always be a string |
||
| 1174 | * (because the answer might be an array of answer values, so passing pretty_value=true |
||
| 1175 | * will convert it into some kind of string) |
||
| 1176 | * @throws EE_Error |
||
| 1177 | */ |
||
| 1178 | public function answer_value_to_question($question, $pretty_value = true) |
||
| 1183 | |||
| 1184 | |||
| 1185 | /** |
||
| 1186 | * question_groups |
||
| 1187 | * returns an array of EE_Question_Group objects for this registration |
||
| 1188 | * |
||
| 1189 | * @return EE_Question_Group[] |
||
| 1190 | * @throws EE_Error |
||
| 1191 | * @throws EntityNotFoundException |
||
| 1192 | */ |
||
| 1193 | public function question_groups() |
||
| 1208 | |||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * count_question_groups |
||
| 1212 | * returns a count of the number of EE_Question_Group objects for this registration |
||
| 1213 | * |
||
| 1214 | * @return int |
||
| 1215 | * @throws EE_Error |
||
| 1216 | * @throws EntityNotFoundException |
||
| 1217 | */ |
||
| 1218 | public function count_question_groups() |
||
| 1233 | |||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Returns the registration date in the 'standard' string format |
||
| 1237 | * (function may be improved in the future to allow for different formats and timezones) |
||
| 1238 | * |
||
| 1239 | * @return string |
||
| 1240 | * @throws EE_Error |
||
| 1241 | */ |
||
| 1242 | public function reg_date() |
||
| 1246 | |||
| 1247 | |||
| 1248 | /** |
||
| 1249 | * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
||
| 1250 | * the ticket this registration purchased, or the datetime they have registered |
||
| 1251 | * to attend) |
||
| 1252 | * |
||
| 1253 | * @return EE_Datetime_Ticket |
||
| 1254 | * @throws EE_Error |
||
| 1255 | */ |
||
| 1256 | public function datetime_ticket() |
||
| 1260 | |||
| 1261 | |||
| 1262 | /** |
||
| 1263 | * Sets the registration's datetime_ticket. |
||
| 1264 | * |
||
| 1265 | * @param EE_Datetime_Ticket $datetime_ticket |
||
| 1266 | * @return EE_Datetime_Ticket |
||
| 1267 | * @throws EE_Error |
||
| 1268 | */ |
||
| 1269 | public function set_datetime_ticket($datetime_ticket) |
||
| 1273 | |||
| 1274 | /** |
||
| 1275 | * Gets deleted |
||
| 1276 | * |
||
| 1277 | * @return bool |
||
| 1278 | * @throws EE_Error |
||
| 1279 | */ |
||
| 1280 | public function deleted() |
||
| 1284 | |||
| 1285 | /** |
||
| 1286 | * Sets deleted |
||
| 1287 | * |
||
| 1288 | * @param boolean $deleted |
||
| 1289 | * @return bool |
||
| 1290 | * @throws EE_Error |
||
| 1291 | * @throws RuntimeException |
||
| 1292 | */ |
||
| 1293 | public function set_deleted($deleted) |
||
| 1301 | |||
| 1302 | |||
| 1303 | /** |
||
| 1304 | * Get the status object of this object |
||
| 1305 | * |
||
| 1306 | * @return EE_Status |
||
| 1307 | * @throws EE_Error |
||
| 1308 | */ |
||
| 1309 | public function status_obj() |
||
| 1313 | |||
| 1314 | |||
| 1315 | /** |
||
| 1316 | * Returns the number of times this registration has checked into any of the datetimes |
||
| 1317 | * its available for |
||
| 1318 | * |
||
| 1319 | * @return int |
||
| 1320 | * @throws EE_Error |
||
| 1321 | */ |
||
| 1322 | public function count_checkins() |
||
| 1326 | |||
| 1327 | |||
| 1328 | /** |
||
| 1329 | * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
||
| 1330 | * registration is for. Note, this is ONLY checked in (does not include checkedout) |
||
| 1331 | * |
||
| 1332 | * @return int |
||
| 1333 | * @throws EE_Error |
||
| 1334 | */ |
||
| 1335 | public function count_checkins_not_checkedout() |
||
| 1339 | |||
| 1340 | |||
| 1341 | /** |
||
| 1342 | * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
||
| 1343 | * |
||
| 1344 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
||
| 1345 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
||
| 1346 | * consider registration status as well as datetime access. |
||
| 1347 | * @return bool |
||
| 1348 | * @throws EE_Error |
||
| 1349 | */ |
||
| 1350 | public function can_checkin($DTT_OR_ID, $check_approved = true) |
||
| 1372 | |||
| 1373 | |||
| 1374 | /** |
||
| 1375 | * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
||
| 1376 | * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
||
| 1377 | * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
||
| 1378 | * then return false. Otherwise return true. |
||
| 1379 | * |
||
| 1380 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
||
| 1381 | * @return bool true means can checkin. false means cannot checkin. |
||
| 1382 | * @throws EE_Error |
||
| 1383 | */ |
||
| 1384 | public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
||
| 1430 | |||
| 1431 | |||
| 1432 | /** |
||
| 1433 | * toggle Check-in status for this registration |
||
| 1434 | * Check-ins are toggled in the following order: |
||
| 1435 | * never checked in -> checked in |
||
| 1436 | * checked in -> checked out |
||
| 1437 | * checked out -> checked in |
||
| 1438 | * |
||
| 1439 | * @param int $DTT_ID include specific datetime to toggle Check-in for. |
||
| 1440 | * If not included or null, then it is assumed latest datetime is being toggled. |
||
| 1441 | * @param bool $verify If true then can_checkin() is used to verify whether the person |
||
| 1442 | * can be checked in or not. Otherwise this forces change in checkin status. |
||
| 1443 | * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
||
| 1444 | * @throws EE_Error |
||
| 1445 | */ |
||
| 1446 | public function toggle_checkin_status($DTT_ID = null, $verify = false) |
||
| 1511 | |||
| 1512 | |||
| 1513 | /** |
||
| 1514 | * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
||
| 1515 | * "Latest" is defined by the `DTT_EVT_start` column. |
||
| 1516 | * |
||
| 1517 | * @return EE_Datetime|null |
||
| 1518 | * @throws EE_Error |
||
| 1519 | */ |
||
| 1520 | View Code Duplication | public function get_latest_related_datetime() |
|
| 1531 | |||
| 1532 | |||
| 1533 | /** |
||
| 1534 | * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
||
| 1535 | * "Earliest" is defined by the `DTT_EVT_start` column. |
||
| 1536 | * |
||
| 1537 | * @throws EE_Error |
||
| 1538 | */ |
||
| 1539 | View Code Duplication | public function get_earliest_related_datetime() |
|
| 1550 | |||
| 1551 | |||
| 1552 | /** |
||
| 1553 | * This method simply returns the check-in status for this registration and the given datetime. |
||
| 1554 | * If neither the datetime nor the checkin values are provided as arguments, |
||
| 1555 | * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
||
| 1556 | * |
||
| 1557 | * @param int $DTT_ID The ID of the datetime we're checking against |
||
| 1558 | * (if empty we'll get the primary datetime for |
||
| 1559 | * this registration (via event) and use it's ID); |
||
| 1560 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
||
| 1561 | * |
||
| 1562 | * @return int Integer representing Check-in status. |
||
| 1563 | * @throws EE_Error |
||
| 1564 | */ |
||
| 1565 | public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
||
| 1587 | |||
| 1588 | |||
| 1589 | /** |
||
| 1590 | * This method returns a localized message for the toggled Check-in message. |
||
| 1591 | * |
||
| 1592 | * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
||
| 1593 | * then it is assumed Check-in for primary datetime was toggled. |
||
| 1594 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
||
| 1595 | * message can be customized with the attendee name. |
||
| 1596 | * @return string internationalized message |
||
| 1597 | * @throws EE_Error |
||
| 1598 | */ |
||
| 1599 | public function get_checkin_msg($DTT_ID, $error = false) |
||
| 1624 | |||
| 1625 | |||
| 1626 | /** |
||
| 1627 | * Returns the related EE_Transaction to this registration |
||
| 1628 | * |
||
| 1629 | * @return EE_Transaction |
||
| 1630 | * @throws EE_Error |
||
| 1631 | * @throws EntityNotFoundException |
||
| 1632 | */ |
||
| 1633 | public function transaction() |
||
| 1641 | |||
| 1642 | |||
| 1643 | /** |
||
| 1644 | * get Registration Code |
||
| 1645 | */ |
||
| 1646 | public function reg_code() |
||
| 1650 | |||
| 1651 | |||
| 1652 | /** |
||
| 1653 | * get Transaction ID |
||
| 1654 | */ |
||
| 1655 | public function transaction_ID() |
||
| 1659 | |||
| 1660 | |||
| 1661 | /** |
||
| 1662 | * @return int |
||
| 1663 | * @throws EE_Error |
||
| 1664 | */ |
||
| 1665 | public function ticket_ID() |
||
| 1669 | |||
| 1670 | |||
| 1671 | /** |
||
| 1672 | * Set Registration Code |
||
| 1673 | * |
||
| 1674 | * @access public |
||
| 1675 | * @param string $REG_code Registration Code |
||
| 1676 | * @param boolean $use_default |
||
| 1677 | * @throws EE_Error |
||
| 1678 | */ |
||
| 1679 | public function set_reg_code($REG_code, $use_default = false) |
||
| 1700 | |||
| 1701 | |||
| 1702 | /** |
||
| 1703 | * Returns all other registrations in the same group as this registrant who have the same ticket option. |
||
| 1704 | * Note, if you want to just get all registrations in the same transaction (group), use: |
||
| 1705 | * $registration->transaction()->registrations(); |
||
| 1706 | * |
||
| 1707 | * @since 4.5.0 |
||
| 1708 | * @return EE_Registration[] or empty array if this isn't a group registration. |
||
| 1709 | * @throws EE_Error |
||
| 1710 | */ |
||
| 1711 | public function get_all_other_registrations_in_group() |
||
| 1726 | |||
| 1727 | /** |
||
| 1728 | * Return the link to the admin details for the object. |
||
| 1729 | * |
||
| 1730 | * @return string |
||
| 1731 | * @throws EE_Error |
||
| 1732 | */ |
||
| 1733 | View Code Duplication | public function get_admin_details_link() |
|
| 1745 | |||
| 1746 | /** |
||
| 1747 | * Returns the link to the editor for the object. Sometimes this is the same as the details. |
||
| 1748 | * |
||
| 1749 | * @return string |
||
| 1750 | * @throws EE_Error |
||
| 1751 | */ |
||
| 1752 | public function get_admin_edit_link() |
||
| 1756 | |||
| 1757 | /** |
||
| 1758 | * Returns the link to a settings page for the object. |
||
| 1759 | * |
||
| 1760 | * @return string |
||
| 1761 | * @throws EE_Error |
||
| 1762 | */ |
||
| 1763 | public function get_admin_settings_link() |
||
| 1767 | |||
| 1768 | /** |
||
| 1769 | * Returns the link to the "overview" for the object (typically the "list table" view). |
||
| 1770 | * |
||
| 1771 | * @return string |
||
| 1772 | */ |
||
| 1773 | public function get_admin_overview_link() |
||
| 1783 | |||
| 1784 | |||
| 1785 | /** |
||
| 1786 | * @param array $query_params |
||
| 1787 | * |
||
| 1788 | * @return \EE_Registration[] |
||
| 1789 | * @throws EE_Error |
||
| 1790 | */ |
||
| 1791 | public function payments($query_params = array()) |
||
| 1795 | |||
| 1796 | |||
| 1797 | /** |
||
| 1798 | * @param array $query_params |
||
| 1799 | * |
||
| 1800 | * @return \EE_Registration_Payment[] |
||
| 1801 | * @throws EE_Error |
||
| 1802 | */ |
||
| 1803 | public function registration_payments($query_params = array()) |
||
| 1807 | |||
| 1808 | |||
| 1809 | /** |
||
| 1810 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
||
| 1811 | * Note: if there are no payments on the registration there will be no payment method returned. |
||
| 1812 | * |
||
| 1813 | * @return EE_Payment_Method|null |
||
| 1814 | */ |
||
| 1815 | public function payment_method() |
||
| 1819 | |||
| 1820 | |||
| 1821 | /** |
||
| 1822 | * @return \EE_Line_Item |
||
| 1823 | * @throws EntityNotFoundException |
||
| 1824 | * @throws EE_Error |
||
| 1825 | */ |
||
| 1826 | public function ticket_line_item() |
||
| 1851 | |||
| 1852 | |||
| 1853 | /** |
||
| 1854 | * Soft Deletes this model object. |
||
| 1855 | * |
||
| 1856 | * @return boolean | int |
||
| 1857 | * @throws RuntimeException |
||
| 1858 | * @throws EE_Error |
||
| 1859 | */ |
||
| 1860 | public function delete() |
||
| 1867 | |||
| 1868 | |||
| 1869 | /** |
||
| 1870 | * Restores whatever the previous status was on a registration before it was trashed (if possible) |
||
| 1871 | * |
||
| 1872 | * @throws EE_Error |
||
| 1873 | * @throws RuntimeException |
||
| 1874 | */ |
||
| 1875 | public function restore() |
||
| 1888 | |||
| 1889 | |||
| 1890 | /** |
||
| 1891 | * possibly toggle Registration status based on comparison of REG_paid vs REG_final_price |
||
| 1892 | * |
||
| 1893 | * @param boolean $trigger_set_status_logic EE_Registration::set_status() can trigger additional logic |
||
| 1894 | * depending on whether the reg status changes to or from "Approved" |
||
| 1895 | * @return boolean whether the Registration status was updated |
||
| 1896 | * @throws EE_Error |
||
| 1897 | * @throws RuntimeException |
||
| 1898 | */ |
||
| 1899 | public function updateStatusBasedOnTotalPaid($trigger_set_status_logic = true) |
||
| 1928 | |||
| 1929 | |||
| 1930 | /*************************** DEPRECATED ***************************/ |
||
| 1931 | |||
| 1932 | |||
| 1933 | /** |
||
| 1934 | * @deprecated |
||
| 1935 | * @since 4.7.0 |
||
| 1936 | * @access public |
||
| 1937 | */ |
||
| 1938 | public function price_paid() |
||
| 1945 | |||
| 1946 | |||
| 1947 | /** |
||
| 1948 | * @deprecated |
||
| 1949 | * @since 4.7.0 |
||
| 1950 | * @access public |
||
| 1951 | * @param float $REG_final_price |
||
| 1952 | * @throws EE_Error |
||
| 1953 | * @throws RuntimeException |
||
| 1954 | */ |
||
| 1955 | public function set_price_paid($REG_final_price = 0.00) |
||
| 1962 | |||
| 1963 | |||
| 1964 | /** |
||
| 1965 | * @deprecated |
||
| 1966 | * @since 4.7.0 |
||
| 1967 | * @return string |
||
| 1968 | * @throws EE_Error |
||
| 1969 | */ |
||
| 1970 | public function pretty_price_paid() |
||
| 1977 | |||
| 1978 | |||
| 1979 | /** |
||
| 1980 | * Gets the primary datetime related to this registration via the related Event to this registration |
||
| 1981 | * |
||
| 1982 | * @deprecated 4.9.17 |
||
| 1983 | * @return EE_Datetime |
||
| 1984 | * @throws EE_Error |
||
| 1985 | * @throws EntityNotFoundException |
||
| 1986 | */ |
||
| 1987 | public function get_related_primary_datetime() |
||
| 2000 | |||
| 2001 | |||
| 2002 | } |
||
| 2003 |
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.