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_Transaction 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_Transaction, and based on these observations, apply Extract Interface, too.
1 | <?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
||
11 | class EE_Transaction extends EE_Base_Class implements EEI_Transaction { |
||
12 | |||
13 | /** |
||
14 | * The length of time in seconds that a lock is applied before being considered expired. |
||
15 | * It is not long because a transaction should only be locked for the duration of the request that locked it |
||
16 | */ |
||
17 | const LOCK_EXPIRATION = 2; |
||
18 | |||
19 | /** |
||
20 | * txn status upon initial construction. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $_old_txn_status; |
||
25 | |||
26 | |||
27 | |||
28 | /** |
||
29 | * @param array $props_n_values incoming values |
||
30 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
31 | * used.) |
||
32 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
33 | * date_format and the second value is the time format |
||
34 | * @return EE_Transaction |
||
35 | * @throws \EE_Error |
||
36 | */ |
||
37 | public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
||
47 | |||
48 | |||
49 | |||
50 | /** |
||
51 | * @param array $props_n_values incoming values from the database |
||
52 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
53 | * the website will be used. |
||
54 | * @return EE_Transaction |
||
55 | * @throws \EE_Error |
||
56 | */ |
||
57 | public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
||
62 | |||
63 | |||
64 | |||
65 | /** |
||
66 | * lock |
||
67 | * Sets a meta field indicating that this TXN is locked and should not be updated in the db. |
||
68 | * If a lock has already been set, then we will attempt to remove it in case it has expired. |
||
69 | * If that also fails, then an exception is thrown. |
||
70 | * |
||
71 | * @access public |
||
72 | * @throws \EE_Error |
||
73 | */ |
||
74 | public function lock() { |
||
92 | |||
93 | |||
94 | |||
95 | /** |
||
96 | * unlock |
||
97 | * removes transaction lock applied in EE_Transaction::lock() |
||
98 | * |
||
99 | * @access public |
||
100 | * @return int |
||
101 | * @throws \EE_Error |
||
102 | */ |
||
103 | public function unlock() { |
||
106 | |||
107 | |||
108 | |||
109 | /** |
||
110 | * is_locked |
||
111 | * Decides whether or not now is the right time to update the transaction. |
||
112 | * This is useful because we don't always know if it is safe to update the transaction |
||
113 | * and its related data. why? |
||
114 | * because it's possible that the transaction is being used in another |
||
115 | * request and could overwrite anything we save. |
||
116 | * So we want to only update the txn once we know that won't happen. |
||
117 | * We also check that the lock isn't expired, and remove it if it is |
||
118 | * |
||
119 | * @access public |
||
120 | * @return boolean |
||
121 | * @throws \EE_Error |
||
122 | */ |
||
123 | public function is_locked() { |
||
134 | |||
135 | |||
136 | |||
137 | /** |
||
138 | * _get_lock |
||
139 | * Gets the meta field indicating that this TXN is locked |
||
140 | * |
||
141 | * @access protected |
||
142 | * @return int |
||
143 | * @throws \EE_Error |
||
144 | */ |
||
145 | protected function _get_lock() { |
||
148 | |||
149 | |||
150 | |||
151 | /** |
||
152 | * remove_expired_lock |
||
153 | * If the lock on this transaction is expired, then we want to remove it so that the transaction can be updated |
||
154 | * |
||
155 | * @access public |
||
156 | * @return int |
||
157 | * @throws \EE_Error |
||
158 | */ |
||
159 | protected function _remove_expired_lock() { |
||
166 | |||
167 | |||
168 | |||
169 | /** |
||
170 | * Set transaction total |
||
171 | * |
||
172 | * @access public |
||
173 | * @param float $total total value of transaction |
||
174 | * @throws \EE_Error |
||
175 | */ |
||
176 | public function set_total( $total = 0.00 ) { |
||
179 | |||
180 | |||
181 | |||
182 | /** |
||
183 | * Set Total Amount Paid to Date |
||
184 | * |
||
185 | * @access public |
||
186 | * @param float $total_paid total amount paid to date (sum of all payments) |
||
187 | * @throws \EE_Error |
||
188 | */ |
||
189 | public function set_paid( $total_paid = 0.00 ) { |
||
192 | |||
193 | |||
194 | |||
195 | /** |
||
196 | * Set transaction status |
||
197 | * |
||
198 | * @access public |
||
199 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
||
200 | * @throws \EE_Error |
||
201 | */ |
||
202 | public function set_status( $status = '' ) { |
||
205 | |||
206 | |||
207 | |||
208 | /** |
||
209 | * Set hash salt |
||
210 | * |
||
211 | * @access public |
||
212 | * @param string $hash_salt required for some payment gateways |
||
213 | * @throws \EE_Error |
||
214 | */ |
||
215 | public function set_hash_salt( $hash_salt = '' ) { |
||
218 | |||
219 | |||
220 | |||
221 | /** |
||
222 | * Sets TXN_reg_steps array |
||
223 | * |
||
224 | * @param array $txn_reg_steps |
||
225 | * @throws \EE_Error |
||
226 | */ |
||
227 | public function set_reg_steps( array $txn_reg_steps ) { |
||
230 | |||
231 | |||
232 | |||
233 | /** |
||
234 | * Gets TXN_reg_steps |
||
235 | * |
||
236 | * @return array |
||
237 | * @throws \EE_Error |
||
238 | */ |
||
239 | public function reg_steps() { |
||
243 | |||
244 | |||
245 | |||
246 | /** |
||
247 | * @return string of transaction's total cost, with currency symbol and decimal |
||
248 | * @throws \EE_Error |
||
249 | */ |
||
250 | public function pretty_total() { |
||
253 | |||
254 | |||
255 | |||
256 | /** |
||
257 | * Gets the amount paid in a pretty string (formatted and with currency symbol) |
||
258 | * |
||
259 | * @return string |
||
260 | * @throws \EE_Error |
||
261 | */ |
||
262 | public function pretty_paid() { |
||
265 | |||
266 | |||
267 | |||
268 | /** |
||
269 | * calculate the amount remaining for this transaction and return; |
||
270 | * |
||
271 | * @access public |
||
272 | * @return float amount remaining |
||
273 | * @throws \EE_Error |
||
274 | */ |
||
275 | public function remaining() { |
||
278 | |||
279 | |||
280 | |||
281 | /** |
||
282 | * get Transaction Total |
||
283 | * |
||
284 | * @access public |
||
285 | * @return float |
||
286 | * @throws \EE_Error |
||
287 | */ |
||
288 | public function total() { |
||
291 | |||
292 | |||
293 | |||
294 | /** |
||
295 | * get Total Amount Paid to Date |
||
296 | * |
||
297 | * @access public |
||
298 | * @return float |
||
299 | * @throws \EE_Error |
||
300 | */ |
||
301 | public function paid() { |
||
304 | |||
305 | |||
306 | |||
307 | /** |
||
308 | * get_cart_session |
||
309 | * |
||
310 | * @access public |
||
311 | * @throws \EE_Error |
||
312 | */ |
||
313 | public function get_cart_session() { |
||
319 | |||
320 | |||
321 | |||
322 | /** |
||
323 | * get Transaction session data |
||
324 | * |
||
325 | * @access public |
||
326 | * @throws \EE_Error |
||
327 | */ |
||
328 | public function session_data() { |
||
343 | |||
344 | |||
345 | |||
346 | /** |
||
347 | * Set session data within the TXN object |
||
348 | * |
||
349 | * @access public |
||
350 | * @param EE_Session|array $session_data |
||
351 | * @throws \EE_Error |
||
352 | */ |
||
353 | public function set_txn_session_data( $session_data ) { |
||
360 | |||
361 | |||
362 | |||
363 | /** |
||
364 | * get Transaction hash salt |
||
365 | * |
||
366 | * @access public |
||
367 | * @throws \EE_Error |
||
368 | */ |
||
369 | public function hash_salt_() { |
||
372 | |||
373 | |||
374 | |||
375 | /** |
||
376 | * datetime |
||
377 | * Returns the transaction datetime as either: |
||
378 | * - unix timestamp format ($format = false, $gmt = true) |
||
379 | * - formatted date string including the UTC (timezone) offset ($format = true ($gmt |
||
380 | * has no affect with this option)), this also may include a timezone abbreviation if the |
||
381 | * set timezone in this class differs from what the timezone is on the blog. |
||
382 | * - formatted date string including the UTC (timezone) offset (default). |
||
383 | * |
||
384 | * @access public |
||
385 | * @param boolean $format - whether to return a unix timestamp (default) or formatted date string |
||
386 | * @param boolean $gmt - whether to return a unix timestamp with UTC offset applied (default) or no UTC offset applied |
||
387 | * @return string | int |
||
388 | * @throws \EE_Error |
||
389 | */ |
||
390 | public function datetime( $format = FALSE, $gmt = FALSE ) { |
||
399 | |||
400 | |||
401 | |||
402 | /** |
||
403 | * Gets registrations on this transaction |
||
404 | * |
||
405 | * @param array $query_params array of query parameters |
||
406 | * @param boolean $get_cached TRUE to retrieve cached registrations or FALSE to pull from the db |
||
407 | * @return EE_Registration[] |
||
408 | * @throws \EE_Error |
||
409 | */ |
||
410 | public function registrations( $query_params = array(), $get_cached = FALSE ) { |
||
423 | |||
424 | |||
425 | |||
426 | /** |
||
427 | * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function |
||
428 | * for getting attendees and how many registrations they each have for an event) |
||
429 | * |
||
430 | * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
||
431 | * @throws \EE_Error |
||
432 | */ |
||
433 | public function attendees() { |
||
436 | |||
437 | |||
438 | |||
439 | /** |
||
440 | * Gets payments for this transaction. Unlike other such functions, order by 'DESC' by default |
||
441 | * |
||
442 | * @param array $query_params like EEM_Base::get_all |
||
443 | * @return EE_Payment[] |
||
444 | * @throws \EE_Error |
||
445 | */ |
||
446 | public function payments( $query_params = array() ) { |
||
449 | |||
450 | |||
451 | |||
452 | /** |
||
453 | * gets only approved payments for this transaction |
||
454 | * |
||
455 | * @return EE_Payment[] |
||
456 | * @throws \EE_Error |
||
457 | */ |
||
458 | public function approved_payments() { |
||
462 | |||
463 | |||
464 | |||
465 | /** |
||
466 | * echoes $this->pretty_status() |
||
467 | * |
||
468 | * @param bool $show_icons |
||
469 | * @return string |
||
470 | * @throws \EE_Error |
||
471 | */ |
||
472 | public function e_pretty_status( $show_icons = FALSE ) { |
||
475 | |||
476 | |||
477 | |||
478 | /** |
||
479 | * returns a pretty version of the status, good for displaying to users |
||
480 | * |
||
481 | * @param bool $show_icons |
||
482 | * @return string |
||
483 | * @throws \EE_Error |
||
484 | */ |
||
485 | public function pretty_status( $show_icons = FALSE ) { |
||
507 | |||
508 | |||
509 | |||
510 | /** |
||
511 | * get Transaction Status |
||
512 | * |
||
513 | * @access public |
||
514 | * @throws \EE_Error |
||
515 | */ |
||
516 | public function status_ID() { |
||
519 | |||
520 | |||
521 | |||
522 | /** |
||
523 | * Returns TRUE or FALSE for whether or not this transaction cost any money |
||
524 | * |
||
525 | * @return boolean |
||
526 | * @throws \EE_Error |
||
527 | */ |
||
528 | public function is_free() { |
||
531 | |||
532 | |||
533 | |||
534 | /** |
||
535 | * Returns whether this transaction is complete |
||
536 | * Useful in templates and other logic for deciding if we should ask for another payment... |
||
537 | * |
||
538 | * @return boolean |
||
539 | * @throws \EE_Error |
||
540 | */ |
||
541 | public function is_completed() { |
||
544 | |||
545 | |||
546 | |||
547 | /** |
||
548 | * Returns whether this transaction is incomplete |
||
549 | * Useful in templates and other logic for deciding if we should ask for another payment... |
||
550 | * |
||
551 | * @return boolean |
||
552 | * @throws \EE_Error |
||
553 | */ |
||
554 | public function is_incomplete() { |
||
557 | |||
558 | |||
559 | |||
560 | /** |
||
561 | * Returns whether this transaction is overpaid |
||
562 | * Useful in templates and other logic for deciding if monies need to be refunded |
||
563 | * |
||
564 | * @return boolean |
||
565 | * @throws \EE_Error |
||
566 | */ |
||
567 | public function is_overpaid() { |
||
570 | |||
571 | |||
572 | |||
573 | /** |
||
574 | * Returns whether this transaction was abandoned |
||
575 | * meaning that the transaction/registration process was somehow interrupted and never completed |
||
576 | * but that contact information exists for at least one registrant |
||
577 | * |
||
578 | * @return boolean |
||
579 | * @throws \EE_Error |
||
580 | */ |
||
581 | public function is_abandoned() { |
||
584 | |||
585 | |||
586 | |||
587 | /** |
||
588 | * Returns whether this transaction failed |
||
589 | * meaning that the transaction/registration process was somehow interrupted and never completed |
||
590 | * and that NO contact information exists for any registrants |
||
591 | * |
||
592 | * @return boolean |
||
593 | * @throws \EE_Error |
||
594 | */ |
||
595 | public function failed() { |
||
598 | |||
599 | |||
600 | |||
601 | /** |
||
602 | * This returns the url for the invoice of this transaction |
||
603 | * |
||
604 | * @param string $type 'html' or 'pdf' (default is pdf) |
||
605 | * @access public |
||
606 | * @return string |
||
607 | * @throws \EE_Error |
||
608 | */ |
||
609 | public function invoice_url( $type = 'html' ) { |
||
616 | |||
617 | |||
618 | |||
619 | /** |
||
620 | * Gets the primary registration only |
||
621 | * |
||
622 | * @return EE_Registration |
||
623 | * @throws \EE_Error |
||
624 | */ |
||
625 | public function primary_registration() { |
||
628 | |||
629 | |||
630 | |||
631 | /** |
||
632 | * Gets the URL for viewing the receipt |
||
633 | * |
||
634 | * @param string $type 'pdf' or 'html' (default is 'html') |
||
635 | * @return string |
||
636 | * @throws \EE_Error |
||
637 | */ |
||
638 | public function receipt_url( $type = 'html' ) { |
||
645 | |||
646 | |||
647 | |||
648 | /** |
||
649 | * Gets the URL of the thank you page with this registration REG_url_link added as |
||
650 | * a query parameter |
||
651 | * |
||
652 | * @access public |
||
653 | * @return string |
||
654 | * @throws \EE_Error |
||
655 | */ |
||
656 | public function payment_overview_url() { |
||
660 | |||
661 | |||
662 | |||
663 | /** |
||
664 | * @return string |
||
665 | * @throws \EE_Error |
||
666 | */ |
||
667 | public function gateway_response_on_transaction() { |
||
671 | |||
672 | |||
673 | |||
674 | /** |
||
675 | * Get the status object of this object |
||
676 | * |
||
677 | * @return EE_Status |
||
678 | * @throws \EE_Error |
||
679 | */ |
||
680 | public function status_obj() { |
||
683 | |||
684 | |||
685 | |||
686 | /** |
||
687 | * Gets all the extra meta info on this payment |
||
688 | * |
||
689 | * @param array $query_params like EEM_Base::get_all |
||
690 | * @return EE_Extra_Meta |
||
691 | * @throws \EE_Error |
||
692 | */ |
||
693 | public function extra_meta( $query_params = array() ) { |
||
696 | |||
697 | |||
698 | |||
699 | /** |
||
700 | * Wrapper for _add_relation_to |
||
701 | * |
||
702 | * @param EE_Registration $registration |
||
703 | * @return EE_Base_Class the relation was added to |
||
704 | * @throws \EE_Error |
||
705 | */ |
||
706 | public function add_registration( EE_Registration $registration ) { |
||
709 | |||
710 | |||
711 | |||
712 | /** |
||
713 | * Removes the given registration from being related (even before saving this transaction). |
||
714 | * If an ID/index is provided and this transaction isn't saved yet, removes it from list of cached relations |
||
715 | * |
||
716 | * @param int $registration_or_id |
||
717 | * @return EE_Base_Class that was removed from being related |
||
718 | * @throws \EE_Error |
||
719 | */ |
||
720 | public function remove_registration_with_id( $registration_or_id ) { |
||
723 | |||
724 | |||
725 | |||
726 | /** |
||
727 | * Gets all the line items which are for ACTUAL items |
||
728 | * |
||
729 | * @return EE_Line_Item[] |
||
730 | * @throws \EE_Error |
||
731 | */ |
||
732 | public function items_purchased() { |
||
735 | |||
736 | |||
737 | |||
738 | /** |
||
739 | * Wrapper for _add_relation_to |
||
740 | * |
||
741 | * @param EE_Line_Item $line_item |
||
742 | * @return EE_Base_Class the relation was added to |
||
743 | * @throws \EE_Error |
||
744 | */ |
||
745 | public function add_line_item( EE_Line_Item $line_item ) { |
||
748 | |||
749 | |||
750 | |||
751 | /** |
||
752 | * Gets ALL the line items related to this transaction (unstructured) |
||
753 | * |
||
754 | * @param array $query_params |
||
755 | * @return EE_Line_Item[] |
||
756 | * @throws \EE_Error |
||
757 | */ |
||
758 | public function line_items( $query_params = array() ) { |
||
761 | |||
762 | |||
763 | |||
764 | /** |
||
765 | * Gets all the line items which are taxes on the total |
||
766 | * |
||
767 | * @return EE_Line_Item[] |
||
768 | * @throws \EE_Error |
||
769 | */ |
||
770 | public function tax_items() { |
||
773 | |||
774 | |||
775 | |||
776 | /** |
||
777 | * Gets the total line item (which is a parent of all other related line items, |
||
778 | * meaning it takes them all into account on its total) |
||
779 | * |
||
780 | * @param bool $create_if_not_found |
||
781 | * @return \EE_Line_Item |
||
782 | * @throws \EE_Error |
||
783 | */ |
||
784 | public function total_line_item( $create_if_not_found = true ) { |
||
791 | |||
792 | |||
793 | |||
794 | /** |
||
795 | * Returns the total amount of tax on this transaction |
||
796 | * (assumes there's only one tax subtotal line item) |
||
797 | * |
||
798 | * @return float |
||
799 | * @throws \EE_Error |
||
800 | */ |
||
801 | public function tax_total() { |
||
809 | |||
810 | |||
811 | |||
812 | /** |
||
813 | * Gets the tax subtotal line item (assumes there's only one) |
||
814 | * |
||
815 | * @return EE_Line_Item |
||
816 | * @throws \EE_Error |
||
817 | */ |
||
818 | public function tax_total_line_item() { |
||
821 | |||
822 | |||
823 | |||
824 | /** |
||
825 | * Gets the array of billing info for the gateway and for this transaction's primary registration's attendee. |
||
826 | * |
||
827 | * @return EE_Form_Section_Proper |
||
828 | * @throws \EE_Error |
||
829 | */ |
||
830 | public function billing_info(){ |
||
848 | |||
849 | |||
850 | |||
851 | /** |
||
852 | * Gets PMD_ID |
||
853 | * |
||
854 | * @return int |
||
855 | * @throws \EE_Error |
||
856 | */ |
||
857 | public function payment_method_ID() { |
||
860 | |||
861 | |||
862 | |||
863 | /** |
||
864 | * Sets PMD_ID |
||
865 | * |
||
866 | * @param int $PMD_ID |
||
867 | * @return boolean |
||
868 | * @throws \EE_Error |
||
869 | */ |
||
870 | public function set_payment_method_ID($PMD_ID) { |
||
873 | |||
874 | |||
875 | |||
876 | /** |
||
877 | * Gets the last-used payment method on this transaction |
||
878 | * (we COULD just use the last-made payment, but some payment methods, namely |
||
879 | * offline ones, dont' create payments) |
||
880 | * |
||
881 | * @return EE_Payment_Method |
||
882 | * @throws \EE_Error |
||
883 | */ |
||
884 | public function payment_method(){ |
||
897 | |||
898 | |||
899 | |||
900 | /** |
||
901 | * Gets the last payment made |
||
902 | * |
||
903 | * @return EE_Payment |
||
904 | * @throws \EE_Error |
||
905 | */ |
||
906 | public function last_payment() { |
||
909 | |||
910 | |||
911 | |||
912 | /** |
||
913 | * Gets all the line items which are unrelated to tickets on this transaction |
||
914 | * |
||
915 | * @return EE_Line_Item[] |
||
916 | * @throws \EE_Error |
||
917 | */ |
||
918 | public function non_ticket_line_items(){ |
||
921 | |||
922 | |||
923 | |||
924 | /** |
||
925 | * possibly toggles TXN status |
||
926 | * |
||
927 | * @param boolean $update whether to save the TXN |
||
928 | * @return boolean whether the TXN was saved |
||
929 | * @throws \RuntimeException |
||
930 | */ |
||
931 | public function update_status_based_on_total_paid($update = true) |
||
953 | |||
954 | |||
955 | |||
956 | /** |
||
957 | * Updates the transaction's status and total_paid based on all the payments |
||
958 | * that apply to it |
||
959 | * |
||
960 | * @deprecated |
||
961 | * @return boolean |
||
962 | * @throws \EE_Error |
||
963 | */ |
||
964 | View Code Duplication | public function update_based_on_payments() |
|
976 | |||
977 | |||
978 | |||
979 | /** |
||
980 | * @return string |
||
981 | */ |
||
982 | public function old_txn_status() { |
||
985 | |||
986 | |||
987 | |||
988 | /** |
||
989 | * @param string $old_txn_status |
||
990 | */ |
||
991 | public function set_old_txn_status( $old_txn_status ) { |
||
997 | |||
998 | |||
999 | |||
1000 | /** |
||
1001 | * reg_status_updated |
||
1002 | * |
||
1003 | * @return bool |
||
1004 | */ |
||
1005 | public function txn_status_updated() { |
||
1008 | |||
1009 | |||
1010 | |||
1011 | /** |
||
1012 | * _reg_steps_completed |
||
1013 | * if $check_all is TRUE, then returns TRUE if ALL reg steps have been marked as completed, |
||
1014 | * if a $reg_step_slug is provided, then this step will be skipped when testing for completion |
||
1015 | * if $check_all is FALSE and a $reg_step_slug is provided, then ONLY that reg step will be tested for completion |
||
1016 | * |
||
1017 | * @access private |
||
1018 | * @param string $reg_step_slug |
||
1019 | * @param bool $check_all |
||
1020 | * @return boolean | int |
||
1021 | */ |
||
1022 | private function _reg_steps_completed( $reg_step_slug = '', $check_all = true ) { |
||
1056 | |||
1057 | |||
1058 | |||
1059 | /** |
||
1060 | * all_reg_steps_completed |
||
1061 | * returns: |
||
1062 | * true if ALL reg steps have been marked as completed |
||
1063 | * or false if any step is not completed |
||
1064 | * |
||
1065 | * @return boolean |
||
1066 | */ |
||
1067 | public function all_reg_steps_completed() { |
||
1070 | |||
1071 | |||
1072 | |||
1073 | /** |
||
1074 | * all_reg_steps_completed_except |
||
1075 | * returns: |
||
1076 | * true if ALL reg steps, except a particular step that you wish to skip over, have been marked as completed |
||
1077 | * or false if any other step is not completed |
||
1078 | * or false if ALL steps are completed including the exception you are testing !!! |
||
1079 | * |
||
1080 | * @param string $exception |
||
1081 | * @return boolean |
||
1082 | */ |
||
1083 | public function all_reg_steps_completed_except( $exception = '' ) { |
||
1086 | |||
1087 | |||
1088 | |||
1089 | /** |
||
1090 | * all_reg_steps_completed_except |
||
1091 | * returns: |
||
1092 | * true if ALL reg steps, except the final step, have been marked as completed |
||
1093 | * or false if any step is not completed |
||
1094 | * or false if ALL steps are completed including the final step !!! |
||
1095 | * |
||
1096 | * @return boolean |
||
1097 | */ |
||
1098 | public function all_reg_steps_completed_except_final_step() { |
||
1101 | |||
1102 | |||
1103 | |||
1104 | /** |
||
1105 | * reg_step_completed |
||
1106 | * returns: |
||
1107 | * true if a specific reg step has been marked as completed |
||
1108 | * a Unix timestamp if it has been initialized but not yet completed, |
||
1109 | * or false if it has not yet been initialized |
||
1110 | * |
||
1111 | * @param string $reg_step_slug |
||
1112 | * @return boolean | int |
||
1113 | */ |
||
1114 | public function reg_step_completed( $reg_step_slug ) { |
||
1117 | |||
1118 | |||
1119 | |||
1120 | /** |
||
1121 | * completed_final_reg_step |
||
1122 | * returns: |
||
1123 | * true if the finalize_registration reg step has been marked as completed |
||
1124 | * a Unix timestamp if it has been initialized but not yet completed, |
||
1125 | * or false if it has not yet been initialized |
||
1126 | * |
||
1127 | * @return boolean | int |
||
1128 | */ |
||
1129 | public function final_reg_step_completed() { |
||
1132 | |||
1133 | |||
1134 | |||
1135 | /** |
||
1136 | * set_reg_step_initiated |
||
1137 | * given a valid TXN_reg_step, this sets it's value to a unix timestamp |
||
1138 | * |
||
1139 | * @access public |
||
1140 | * @param string $reg_step_slug |
||
1141 | * @return boolean |
||
1142 | * @throws \EE_Error |
||
1143 | */ |
||
1144 | public function set_reg_step_initiated( $reg_step_slug ) { |
||
1147 | |||
1148 | |||
1149 | |||
1150 | /** |
||
1151 | * set_reg_step_completed |
||
1152 | * given a valid TXN_reg_step, this sets the step as completed |
||
1153 | * |
||
1154 | * @access public |
||
1155 | * @param string $reg_step_slug |
||
1156 | * @return boolean |
||
1157 | * @throws \EE_Error |
||
1158 | */ |
||
1159 | public function set_reg_step_completed( $reg_step_slug ) { |
||
1162 | |||
1163 | |||
1164 | |||
1165 | /** |
||
1166 | * set_reg_step_completed |
||
1167 | * given a valid TXN_reg_step slug, this sets the step as NOT completed |
||
1168 | * |
||
1169 | * @access public |
||
1170 | * @param string $reg_step_slug |
||
1171 | * @return boolean |
||
1172 | * @throws \EE_Error |
||
1173 | */ |
||
1174 | public function set_reg_step_not_completed( $reg_step_slug ) { |
||
1177 | |||
1178 | |||
1179 | |||
1180 | /** |
||
1181 | * set_reg_step_completed |
||
1182 | * given a valid reg step slug, this sets the TXN_reg_step completed status which is either: |
||
1183 | * |
||
1184 | * @access private |
||
1185 | * @param string $reg_step_slug |
||
1186 | * @param boolean|int $status |
||
1187 | * @return boolean |
||
1188 | * @throws \EE_Error |
||
1189 | */ |
||
1190 | private function _set_reg_step_completed_status( $reg_step_slug, $status ) { |
||
1224 | |||
1225 | |||
1226 | |||
1227 | /** |
||
1228 | * remove_reg_step |
||
1229 | * given a valid TXN_reg_step slug, this will remove (unset) |
||
1230 | * the reg step from the TXN reg step array |
||
1231 | * |
||
1232 | * @access public |
||
1233 | * @param string $reg_step_slug |
||
1234 | * @return void |
||
1235 | */ |
||
1236 | public function remove_reg_step( $reg_step_slug ) { |
||
1242 | |||
1243 | |||
1244 | |||
1245 | /** |
||
1246 | * toggle_failed_transaction_status |
||
1247 | * upgrades a TXNs status from failed to abandoned, |
||
1248 | * meaning that contact information has been captured for at least one registrant |
||
1249 | * |
||
1250 | * @access public |
||
1251 | * @param bool $save |
||
1252 | * @return bool |
||
1253 | */ |
||
1254 | public function toggle_failed_transaction_status( $save = true ) { |
||
1265 | |||
1266 | |||
1267 | |||
1268 | /** |
||
1269 | * toggle_abandoned_transaction_status |
||
1270 | * upgrades a TXNs status from failed or abandoned to incomplete |
||
1271 | * |
||
1272 | * @access public |
||
1273 | * @return boolean |
||
1274 | */ |
||
1275 | public function toggle_abandoned_transaction_status() { |
||
1296 | |||
1297 | |||
1298 | |||
1299 | /** |
||
1300 | * checks if an Abandoned TXN has any related payments, and if so, |
||
1301 | * updates the TXN status based on the amount paid |
||
1302 | */ |
||
1303 | public function verify_abandoned_transaction_status() { |
||
1337 | |||
1338 | }/* End of file EE_Transaction.class.php */ |
||
1339 | /* Location: includes/classes/EE_Transaction.class.php */ |
||
1340 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.