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_Ticket 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_Ticket, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class EE_Ticket extends EE_Soft_Delete_Base_Class implements EEI_Line_Item_Object, EEI_Event_Relation, EEI_Has_Icon |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * The following constants are used by the ticket_status() method to indicate whether a ticket is on sale or not. |
||
19 | */ |
||
20 | const sold_out = 'TKS'; |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | */ |
||
25 | const expired = 'TKE'; |
||
26 | |||
27 | /** |
||
28 | * |
||
29 | */ |
||
30 | const archived = 'TKA'; |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | */ |
||
35 | const pending = 'TKP'; |
||
36 | |||
37 | /** |
||
38 | * |
||
39 | */ |
||
40 | const onsale = 'TKO'; |
||
41 | |||
42 | /** |
||
43 | * extra meta key for tracking ticket reservations |
||
44 | * |
||
45 | * @type string |
||
46 | */ |
||
47 | const META_KEY_TICKET_RESERVATIONS = 'ticket_reservations'; |
||
48 | |||
49 | /** |
||
50 | * cached result from method of the same name |
||
51 | * |
||
52 | * @var float $_ticket_total_with_taxes |
||
53 | */ |
||
54 | private $_ticket_total_with_taxes; |
||
55 | |||
56 | |||
57 | /** |
||
58 | * @param array $props_n_values incoming values |
||
59 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
||
60 | * used.) |
||
61 | * @param array $date_formats incoming date_formats in an array where the first value is the |
||
62 | * date_format and the second value is the time format |
||
63 | * @return EE_Ticket |
||
64 | * @throws \EE_Error |
||
65 | */ |
||
66 | public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
||
71 | |||
72 | |||
73 | /** |
||
74 | * @param array $props_n_values incoming values from the database |
||
75 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
||
76 | * the website will be used. |
||
77 | * @return EE_Ticket |
||
78 | * @throws \EE_Error |
||
79 | */ |
||
80 | public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
||
84 | |||
85 | |||
86 | /** |
||
87 | * @return bool |
||
88 | * @throws \EE_Error |
||
89 | */ |
||
90 | public function parent() |
||
94 | |||
95 | |||
96 | /** |
||
97 | * return if a ticket has quantities available for purchase |
||
98 | * |
||
99 | * @param int $DTT_ID the primary key for a particular datetime |
||
100 | * @return boolean |
||
101 | * @throws \EE_Error |
||
102 | */ |
||
103 | public function available($DTT_ID = 0) |
||
117 | |||
118 | |||
119 | /** |
||
120 | * Using the start date and end date this method calculates whether the ticket is On Sale, Pending, or Expired |
||
121 | * |
||
122 | * @param bool $display true = we'll return a localized string, otherwise we just return the value of the |
||
123 | * relevant status const |
||
124 | * @param bool | null $remaining if it is already known that tickets are available, then simply pass a bool to save |
||
125 | * further processing |
||
126 | * @return mixed status int if the display string isn't requested |
||
127 | * @throws \EE_Error |
||
128 | */ |
||
129 | public function ticket_status($display = false, $remaining = null) |
||
149 | |||
150 | |||
151 | /** |
||
152 | * The purpose of this method is to simply return a boolean for whether there are any tickets remaining for sale |
||
153 | * considering ALL the factors used for figuring that out. |
||
154 | * |
||
155 | * @access public |
||
156 | * @param int $DTT_ID if an int above 0 is included here then we get a specific dtt. |
||
157 | * @return boolean true = tickets remaining, false not. |
||
158 | * @throws \EE_Error |
||
159 | */ |
||
160 | public function is_remaining($DTT_ID = 0) |
||
171 | |||
172 | |||
173 | /** |
||
174 | * return the total number of tickets available for purchase |
||
175 | * |
||
176 | * @param int $DTT_ID the primary key for a particular datetime. |
||
177 | * set to 0 for all related datetimes |
||
178 | * @return int |
||
179 | * @throws \EE_Error |
||
180 | */ |
||
181 | public function remaining($DTT_ID = 0) |
||
185 | |||
186 | |||
187 | /** |
||
188 | * Gets min |
||
189 | * |
||
190 | * @return int |
||
191 | * @throws \EE_Error |
||
192 | */ |
||
193 | public function min() |
||
197 | |||
198 | |||
199 | /** |
||
200 | * return if a ticket is no longer available cause its available dates have expired. |
||
201 | * |
||
202 | * @return boolean |
||
203 | * @throws \EE_Error |
||
204 | */ |
||
205 | public function is_expired() |
||
209 | |||
210 | |||
211 | /** |
||
212 | * Return if a ticket is yet to go on sale or not |
||
213 | * |
||
214 | * @return boolean |
||
215 | * @throws \EE_Error |
||
216 | */ |
||
217 | public function is_pending() |
||
221 | |||
222 | |||
223 | /** |
||
224 | * Return if a ticket is on sale or not |
||
225 | * |
||
226 | * @return boolean |
||
227 | * @throws \EE_Error |
||
228 | */ |
||
229 | public function is_on_sale() |
||
233 | |||
234 | |||
235 | /** |
||
236 | * This returns the chronologically last datetime that this ticket is associated with |
||
237 | * |
||
238 | * @param string $dt_frmt |
||
239 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with |
||
240 | * the end date ie: Jan 01 "to" Dec 31 |
||
241 | * @return string |
||
242 | * @throws \EE_Error |
||
243 | */ |
||
244 | public function date_range($dt_frmt = '', $conjunction = ' - ') |
||
252 | |||
253 | |||
254 | /** |
||
255 | * This returns the chronologically first datetime that this ticket is associated with |
||
256 | * |
||
257 | * @return EE_Datetime |
||
258 | * @throws \EE_Error |
||
259 | */ |
||
260 | public function first_datetime() |
||
265 | |||
266 | |||
267 | /** |
||
268 | * Gets all the datetimes this ticket can be used for attending. |
||
269 | * Unless otherwise specified, orders datetimes by start date. |
||
270 | * |
||
271 | * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
||
272 | * @return EE_Datetime[]|EE_Base_Class[] |
||
273 | * @throws \EE_Error |
||
274 | */ |
||
275 | public function datetimes($query_params = array()) |
||
282 | |||
283 | |||
284 | /** |
||
285 | * This returns the chronologically last datetime that this ticket is associated with |
||
286 | * |
||
287 | * @return EE_Datetime |
||
288 | * @throws \EE_Error |
||
289 | */ |
||
290 | public function last_datetime() |
||
295 | |||
296 | |||
297 | /** |
||
298 | * This returns the total tickets sold depending on the given parameters. |
||
299 | * |
||
300 | * @param string $what Can be one of two options: 'ticket', 'datetime'. |
||
301 | * 'ticket' = total ticket sales for all datetimes this ticket is related to |
||
302 | * 'datetime' = total ticket sales for a specified datetime (required $dtt_id) |
||
303 | * 'datetime' = total ticket sales in the datetime_ticket table. |
||
304 | * If $dtt_id is not given then we return an array of sales indexed by datetime. |
||
305 | * If $dtt_id IS given then we return the tickets sold for that given datetime. |
||
306 | * @param int $dtt_id [optional] include the dtt_id with $what = 'datetime'. |
||
307 | * @return mixed (array|int) how many tickets have sold |
||
308 | * @throws \EE_Error |
||
309 | */ |
||
310 | public function tickets_sold($what = 'ticket', $dtt_id = null) |
||
340 | |||
341 | |||
342 | /** |
||
343 | * This returns an array indexed by datetime_id for tickets sold with this ticket. |
||
344 | * |
||
345 | * @return EE_Ticket[] |
||
346 | * @throws \EE_Error |
||
347 | */ |
||
348 | protected function _all_tickets_sold() |
||
361 | |||
362 | |||
363 | /** |
||
364 | * This returns the base price object for the ticket. |
||
365 | * |
||
366 | * @param bool $return_array whether to return as an array indexed by price id or just the object. |
||
367 | * @return EE_Price|EE_Base_Class|EE_Price[]|EE_Base_Class[] |
||
368 | * @throws \EE_Error |
||
369 | */ |
||
370 | public function base_price($return_array = false) |
||
377 | |||
378 | |||
379 | /** |
||
380 | * This returns ONLY the price modifiers for the ticket (i.e. no taxes or base price) |
||
381 | * |
||
382 | * @access public |
||
383 | * @return EE_Price[] |
||
384 | * @throws \EE_Error |
||
385 | */ |
||
386 | public function price_modifiers() |
||
398 | |||
399 | |||
400 | /** |
||
401 | * Gets all the prices that combine to form the final price of this ticket |
||
402 | * |
||
403 | * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
||
404 | * @return EE_Price[]|EE_Base_Class[] |
||
405 | * @throws \EE_Error |
||
406 | */ |
||
407 | public function prices($query_params = array()) |
||
411 | |||
412 | |||
413 | /** |
||
414 | * Gets all the ticket applicabilities (ie, relations between datetimes and tickets) |
||
415 | * |
||
416 | * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
||
417 | * @return EE_Datetime_Ticket|EE_Base_Class[] |
||
418 | * @throws \EE_Error |
||
419 | */ |
||
420 | public function datetime_tickets($query_params = array()) |
||
424 | |||
425 | |||
426 | /** |
||
427 | * Gets all the datetimes from the db ordered by DTT_order |
||
428 | * |
||
429 | * @param boolean $show_expired |
||
430 | * @param boolean $show_deleted |
||
431 | * @return EE_Datetime[] |
||
432 | * @throws \EE_Error |
||
433 | */ |
||
434 | public function datetimes_ordered($show_expired = true, $show_deleted = false) |
||
442 | |||
443 | |||
444 | /** |
||
445 | * Gets ID |
||
446 | * |
||
447 | * @return string |
||
448 | * @throws \EE_Error |
||
449 | */ |
||
450 | public function ID() |
||
454 | |||
455 | |||
456 | /** |
||
457 | * get the author of the ticket. |
||
458 | * |
||
459 | * @since 4.5.0 |
||
460 | * @return int |
||
461 | * @throws \EE_Error |
||
462 | */ |
||
463 | public function wp_user() |
||
467 | |||
468 | |||
469 | /** |
||
470 | * Gets the template for the ticket |
||
471 | * |
||
472 | * @return EE_Ticket_Template|EE_Base_Class |
||
473 | * @throws \EE_Error |
||
474 | */ |
||
475 | public function template() |
||
479 | |||
480 | |||
481 | /** |
||
482 | * Simply returns an array of EE_Price objects that are taxes. |
||
483 | * |
||
484 | * @return EE_Price[] |
||
485 | * @throws \EE_Error |
||
486 | */ |
||
487 | public function get_ticket_taxes_for_admin() |
||
491 | |||
492 | |||
493 | /** |
||
494 | * @return float |
||
495 | * @throws \EE_Error |
||
496 | */ |
||
497 | public function ticket_price() |
||
501 | |||
502 | |||
503 | /** |
||
504 | * @return mixed |
||
505 | * @throws \EE_Error |
||
506 | */ |
||
507 | public function pretty_price() |
||
511 | |||
512 | |||
513 | /** |
||
514 | * @return bool |
||
515 | * @throws \EE_Error |
||
516 | */ |
||
517 | public function is_free() |
||
521 | |||
522 | |||
523 | /** |
||
524 | * get_ticket_total_with_taxes |
||
525 | * |
||
526 | * @param bool $no_cache |
||
527 | * @return float |
||
528 | * @throws \EE_Error |
||
529 | */ |
||
530 | public function get_ticket_total_with_taxes($no_cache = false) |
||
537 | |||
538 | |||
539 | public function ensure_TKT_Price_correct() |
||
544 | |||
545 | |||
546 | /** |
||
547 | * @return float |
||
548 | * @throws \EE_Error |
||
549 | */ |
||
550 | public function get_ticket_subtotal() |
||
554 | |||
555 | |||
556 | /** |
||
557 | * Returns the total taxes applied to this ticket |
||
558 | * |
||
559 | * @return float |
||
560 | * @throws \EE_Error |
||
561 | */ |
||
562 | public function get_ticket_taxes_total_for_admin() |
||
566 | |||
567 | |||
568 | /** |
||
569 | * Sets name |
||
570 | * |
||
571 | * @param string $name |
||
572 | * @throws \EE_Error |
||
573 | */ |
||
574 | public function set_name($name) |
||
578 | |||
579 | |||
580 | /** |
||
581 | * Gets description |
||
582 | * |
||
583 | * @return string |
||
584 | * @throws \EE_Error |
||
585 | */ |
||
586 | public function description() |
||
590 | |||
591 | |||
592 | /** |
||
593 | * Sets description |
||
594 | * |
||
595 | * @param string $description |
||
596 | * @throws \EE_Error |
||
597 | */ |
||
598 | public function set_description($description) |
||
602 | |||
603 | |||
604 | /** |
||
605 | * Gets start_date |
||
606 | * |
||
607 | * @param string $dt_frmt |
||
608 | * @param string $tm_frmt |
||
609 | * @return string |
||
610 | * @throws \EE_Error |
||
611 | */ |
||
612 | public function start_date($dt_frmt = '', $tm_frmt = '') |
||
616 | |||
617 | |||
618 | /** |
||
619 | * Sets start_date |
||
620 | * |
||
621 | * @param string $start_date |
||
622 | * @return void |
||
623 | * @throws \EE_Error |
||
624 | */ |
||
625 | public function set_start_date($start_date) |
||
629 | |||
630 | |||
631 | /** |
||
632 | * Gets end_date |
||
633 | * |
||
634 | * @param string $dt_frmt |
||
635 | * @param string $tm_frmt |
||
636 | * @return string |
||
637 | * @throws \EE_Error |
||
638 | */ |
||
639 | public function end_date($dt_frmt = '', $tm_frmt = '') |
||
643 | |||
644 | |||
645 | /** |
||
646 | * Sets end_date |
||
647 | * |
||
648 | * @param string $end_date |
||
649 | * @return void |
||
650 | * @throws \EE_Error |
||
651 | */ |
||
652 | public function set_end_date($end_date) |
||
656 | |||
657 | |||
658 | /** |
||
659 | * Sets sell until time |
||
660 | * |
||
661 | * @since 4.5.0 |
||
662 | * @param string $time a string representation of the sell until time (ex 9am or 7:30pm) |
||
663 | * @throws \EE_Error |
||
664 | */ |
||
665 | public function set_end_time($time) |
||
669 | |||
670 | |||
671 | /** |
||
672 | * Sets min |
||
673 | * |
||
674 | * @param int $min |
||
675 | * @return void |
||
676 | * @throws \EE_Error |
||
677 | */ |
||
678 | public function set_min($min) |
||
682 | |||
683 | |||
684 | /** |
||
685 | * Gets max |
||
686 | * |
||
687 | * @return int |
||
688 | * @throws \EE_Error |
||
689 | */ |
||
690 | public function max() |
||
694 | |||
695 | |||
696 | /** |
||
697 | * Sets max |
||
698 | * |
||
699 | * @param int $max |
||
700 | * @return void |
||
701 | * @throws \EE_Error |
||
702 | */ |
||
703 | public function set_max($max) |
||
707 | |||
708 | |||
709 | /** |
||
710 | * Sets price |
||
711 | * |
||
712 | * @param float $price |
||
713 | * @return void |
||
714 | * @throws \EE_Error |
||
715 | */ |
||
716 | public function set_price($price) |
||
720 | |||
721 | |||
722 | /** |
||
723 | * Gets sold |
||
724 | * |
||
725 | * @return int |
||
726 | * @throws \EE_Error |
||
727 | */ |
||
728 | public function sold() |
||
732 | |||
733 | |||
734 | /** |
||
735 | * Sets sold |
||
736 | * |
||
737 | * @param int $sold |
||
738 | * @return void |
||
739 | * @throws \EE_Error |
||
740 | */ |
||
741 | public function set_sold($sold) |
||
747 | |||
748 | |||
749 | /** |
||
750 | * increments sold by amount passed by $qty |
||
751 | * |
||
752 | * @param int $qty |
||
753 | * @return void |
||
754 | * @throws \EE_Error |
||
755 | */ |
||
756 | public function increase_sold($qty = 1) |
||
771 | |||
772 | |||
773 | /** |
||
774 | * Increases sold on related datetimes |
||
775 | * |
||
776 | * @param int $qty |
||
777 | * @return void |
||
778 | * @throws \EE_Error |
||
779 | */ |
||
780 | View Code Duplication | protected function _increase_sold_for_datetimes($qty = 1) |
|
792 | |||
793 | |||
794 | /** |
||
795 | * decrements (subtracts) sold by amount passed by $qty |
||
796 | * |
||
797 | * @param int $qty |
||
798 | * @return void |
||
799 | * @throws \EE_Error |
||
800 | */ |
||
801 | public function decrease_sold($qty = 1) |
||
813 | |||
814 | |||
815 | /** |
||
816 | * Decreases sold on related datetimes |
||
817 | * |
||
818 | * @param int $qty |
||
819 | * @return void |
||
820 | * @throws \EE_Error |
||
821 | */ |
||
822 | View Code Duplication | protected function _decrease_sold_for_datetimes($qty = 1) |
|
834 | |||
835 | |||
836 | /** |
||
837 | * Gets qty of reserved tickets |
||
838 | * |
||
839 | * @return int |
||
840 | * @throws \EE_Error |
||
841 | */ |
||
842 | public function reserved() |
||
846 | |||
847 | |||
848 | /** |
||
849 | * Sets reserved |
||
850 | * |
||
851 | * @param int $reserved |
||
852 | * @return void |
||
853 | * @throws \EE_Error |
||
854 | */ |
||
855 | public function set_reserved($reserved) |
||
861 | |||
862 | |||
863 | /** |
||
864 | * increments reserved by amount passed by $qty |
||
865 | * |
||
866 | * @param int $qty |
||
867 | * @param string $source |
||
868 | * @return bool whether we successfully reserved the ticket or not. |
||
869 | * @throws EE_Error |
||
870 | * @throws InvalidArgumentException |
||
871 | * @throws ReflectionException |
||
872 | * @throws InvalidDataTypeException |
||
873 | * @throws InvalidInterfaceException |
||
874 | */ |
||
875 | public function increase_reserved($qty = 1, $source = 'unknown') |
||
915 | |||
916 | |||
917 | /** |
||
918 | * Increases sold on related datetimes |
||
919 | * |
||
920 | * @param int $qty |
||
921 | * @return boolean indicating success |
||
922 | * @throws \EE_Error |
||
923 | */ |
||
924 | protected function _increase_reserved_for_datetimes($qty = 1) |
||
949 | |||
950 | /** |
||
951 | * Decreases the reserved count on the specified datetimes. |
||
952 | * @since $VID:$ |
||
953 | * @param EE_Datetime[] $datetimes |
||
954 | * @param int $qty |
||
955 | * @throws EE_Error |
||
956 | * @throws InvalidArgumentException |
||
957 | * @throws ReflectionException |
||
958 | * @throws InvalidDataTypeException |
||
959 | * @throws InvalidInterfaceException |
||
960 | */ |
||
961 | protected function decreaseReservedForDatetimes($datetimes, $qty = 1) { |
||
968 | |||
969 | |||
970 | /** |
||
971 | * decrements (subtracts) reserved by amount passed by $qty |
||
972 | * |
||
973 | * @param int $qty |
||
974 | * @param bool $adjust_datetimes |
||
975 | * @param string $source |
||
976 | * @return void |
||
977 | * @throws EE_Error |
||
978 | * @throws InvalidArgumentException |
||
979 | * @throws ReflectionException |
||
980 | * @throws InvalidDataTypeException |
||
981 | * @throws InvalidInterfaceException |
||
982 | */ |
||
983 | public function decrease_reserved($qty = 1, $adjust_datetimes = true, $source = 'unknown') |
||
1006 | |||
1007 | |||
1008 | /** |
||
1009 | * Decreases reserved on related datetimes |
||
1010 | * |
||
1011 | * @param int $qty |
||
1012 | * @return void |
||
1013 | * @throws EE_Error |
||
1014 | * @throws InvalidArgumentException |
||
1015 | * @throws ReflectionException |
||
1016 | * @throws InvalidDataTypeException |
||
1017 | * @throws InvalidInterfaceException |
||
1018 | */ |
||
1019 | protected function _decrease_reserved_for_datetimes($qty = 1) |
||
1023 | |||
1024 | |||
1025 | /** |
||
1026 | * Gets ticket quantity |
||
1027 | * |
||
1028 | * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
||
1029 | * therefore $context can be one of three values: '', 'reg_limit', or 'saleable' |
||
1030 | * '' (default) quantity is the actual db value for TKT_qty, unaffected by other objects |
||
1031 | * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
||
1032 | * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
||
1033 | * is therefore the truest measure of tickets that can be purchased at the moment |
||
1034 | * @return int |
||
1035 | * @throws \EE_Error |
||
1036 | */ |
||
1037 | public function qty($context = '') |
||
1048 | |||
1049 | |||
1050 | /** |
||
1051 | * Gets ticket quantity |
||
1052 | * |
||
1053 | * @param string $context ticket quantity is somewhat subjective depending on the exact information sought |
||
1054 | * therefore $context can be one of two values: 'reg_limit', or 'saleable' |
||
1055 | * REG LIMIT: caps qty based on DTT_reg_limit for ALL related datetimes |
||
1056 | * SALEABLE: also considers datetime sold and returns zero if ANY DTT is sold out, and |
||
1057 | * is therefore the truest measure of tickets that can be purchased at the moment |
||
1058 | * @param int $DTT_ID the primary key for a particular datetime. |
||
1059 | * set to 0 for all related datetimes |
||
1060 | * @return int |
||
1061 | * @throws \EE_Error |
||
1062 | */ |
||
1063 | public function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) |
||
1124 | |||
1125 | |||
1126 | /** |
||
1127 | * Sets qty - IMPORTANT!!! Does NOT allow QTY to be set higher than the lowest reg limit of any related datetimes |
||
1128 | * |
||
1129 | * @param int $qty |
||
1130 | * @return void |
||
1131 | * @throws \EE_Error |
||
1132 | */ |
||
1133 | View Code Duplication | public function set_qty($qty) |
|
1143 | |||
1144 | |||
1145 | /** |
||
1146 | * Gets uses |
||
1147 | * |
||
1148 | * @return int |
||
1149 | * @throws \EE_Error |
||
1150 | */ |
||
1151 | public function uses() |
||
1155 | |||
1156 | |||
1157 | /** |
||
1158 | * Sets uses |
||
1159 | * |
||
1160 | * @param int $uses |
||
1161 | * @return void |
||
1162 | * @throws \EE_Error |
||
1163 | */ |
||
1164 | public function set_uses($uses) |
||
1168 | |||
1169 | |||
1170 | /** |
||
1171 | * returns whether ticket is required or not. |
||
1172 | * |
||
1173 | * @return boolean |
||
1174 | * @throws \EE_Error |
||
1175 | */ |
||
1176 | public function required() |
||
1180 | |||
1181 | |||
1182 | /** |
||
1183 | * sets the TKT_required property |
||
1184 | * |
||
1185 | * @param boolean $required |
||
1186 | * @return void |
||
1187 | * @throws \EE_Error |
||
1188 | */ |
||
1189 | public function set_required($required) |
||
1193 | |||
1194 | |||
1195 | /** |
||
1196 | * Gets taxable |
||
1197 | * |
||
1198 | * @return boolean |
||
1199 | * @throws \EE_Error |
||
1200 | */ |
||
1201 | public function taxable() |
||
1205 | |||
1206 | |||
1207 | /** |
||
1208 | * Sets taxable |
||
1209 | * |
||
1210 | * @param boolean $taxable |
||
1211 | * @return void |
||
1212 | * @throws \EE_Error |
||
1213 | */ |
||
1214 | public function set_taxable($taxable) |
||
1218 | |||
1219 | |||
1220 | /** |
||
1221 | * Gets is_default |
||
1222 | * |
||
1223 | * @return boolean |
||
1224 | * @throws \EE_Error |
||
1225 | */ |
||
1226 | public function is_default() |
||
1230 | |||
1231 | |||
1232 | /** |
||
1233 | * Sets is_default |
||
1234 | * |
||
1235 | * @param boolean $is_default |
||
1236 | * @return void |
||
1237 | * @throws \EE_Error |
||
1238 | */ |
||
1239 | public function set_is_default($is_default) |
||
1243 | |||
1244 | |||
1245 | /** |
||
1246 | * Gets order |
||
1247 | * |
||
1248 | * @return int |
||
1249 | * @throws \EE_Error |
||
1250 | */ |
||
1251 | public function order() |
||
1255 | |||
1256 | |||
1257 | /** |
||
1258 | * Sets order |
||
1259 | * |
||
1260 | * @param int $order |
||
1261 | * @return void |
||
1262 | * @throws \EE_Error |
||
1263 | */ |
||
1264 | public function set_order($order) |
||
1268 | |||
1269 | |||
1270 | /** |
||
1271 | * Gets row |
||
1272 | * |
||
1273 | * @return int |
||
1274 | * @throws \EE_Error |
||
1275 | */ |
||
1276 | public function row() |
||
1280 | |||
1281 | |||
1282 | /** |
||
1283 | * Sets row |
||
1284 | * |
||
1285 | * @param int $row |
||
1286 | * @return void |
||
1287 | * @throws \EE_Error |
||
1288 | */ |
||
1289 | public function set_row($row) |
||
1293 | |||
1294 | |||
1295 | /** |
||
1296 | * Gets deleted |
||
1297 | * |
||
1298 | * @return boolean |
||
1299 | * @throws \EE_Error |
||
1300 | */ |
||
1301 | public function deleted() |
||
1305 | |||
1306 | |||
1307 | /** |
||
1308 | * Sets deleted |
||
1309 | * |
||
1310 | * @param boolean $deleted |
||
1311 | * @return void |
||
1312 | * @throws \EE_Error |
||
1313 | */ |
||
1314 | public function set_deleted($deleted) |
||
1318 | |||
1319 | |||
1320 | /** |
||
1321 | * Gets parent |
||
1322 | * |
||
1323 | * @return int |
||
1324 | * @throws \EE_Error |
||
1325 | */ |
||
1326 | public function parent_ID() |
||
1330 | |||
1331 | |||
1332 | /** |
||
1333 | * Sets parent |
||
1334 | * |
||
1335 | * @param int $parent |
||
1336 | * @return void |
||
1337 | * @throws \EE_Error |
||
1338 | */ |
||
1339 | public function set_parent_ID($parent) |
||
1343 | |||
1344 | |||
1345 | /** |
||
1346 | * Gets a string which is handy for showing in gateways etc that describes the ticket. |
||
1347 | * |
||
1348 | * @return string |
||
1349 | * @throws \EE_Error |
||
1350 | */ |
||
1351 | public function name_and_info() |
||
1359 | |||
1360 | |||
1361 | /** |
||
1362 | * Gets name |
||
1363 | * |
||
1364 | * @return string |
||
1365 | * @throws \EE_Error |
||
1366 | */ |
||
1367 | public function name() |
||
1371 | |||
1372 | |||
1373 | /** |
||
1374 | * Gets price |
||
1375 | * |
||
1376 | * @return float |
||
1377 | * @throws \EE_Error |
||
1378 | */ |
||
1379 | public function price() |
||
1383 | |||
1384 | |||
1385 | /** |
||
1386 | * Gets all the registrations for this ticket |
||
1387 | * |
||
1388 | * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
||
1389 | * @return EE_Registration[]|EE_Base_Class[] |
||
1390 | * @throws \EE_Error |
||
1391 | */ |
||
1392 | public function registrations($query_params = array()) |
||
1396 | |||
1397 | |||
1398 | /** |
||
1399 | * Updates the TKT_sold attribute (and saves) based on the number of APPROVED registrations for this ticket. |
||
1400 | * into account |
||
1401 | * |
||
1402 | * @return int |
||
1403 | * @throws \EE_Error |
||
1404 | */ |
||
1405 | View Code Duplication | public function update_tickets_sold() |
|
1425 | |||
1426 | |||
1427 | /** |
||
1428 | * Counts the registrations for this ticket |
||
1429 | * |
||
1430 | * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
||
1431 | * @return int |
||
1432 | */ |
||
1433 | public function count_registrations($query_params = array()) |
||
1437 | |||
1438 | |||
1439 | /** |
||
1440 | * Implementation for EEI_Has_Icon interface method. |
||
1441 | * |
||
1442 | * @see EEI_Visual_Representation for comments |
||
1443 | * @return string |
||
1444 | */ |
||
1445 | public function get_icon() |
||
1449 | |||
1450 | |||
1451 | /** |
||
1452 | * Implementation of the EEI_Event_Relation interface method |
||
1453 | * |
||
1454 | * @see EEI_Event_Relation for comments |
||
1455 | * @return EE_Event |
||
1456 | * @throws \EE_Error |
||
1457 | * @throws UnexpectedEntityException |
||
1458 | */ |
||
1459 | public function get_related_event() |
||
1486 | |||
1487 | |||
1488 | /** |
||
1489 | * Implementation of the EEI_Event_Relation interface method |
||
1490 | * |
||
1491 | * @see EEI_Event_Relation for comments |
||
1492 | * @return string |
||
1493 | * @throws UnexpectedEntityException |
||
1494 | * @throws \EE_Error |
||
1495 | */ |
||
1496 | public function get_event_name() |
||
1501 | |||
1502 | |||
1503 | /** |
||
1504 | * Implementation of the EEI_Event_Relation interface method |
||
1505 | * |
||
1506 | * @see EEI_Event_Relation for comments |
||
1507 | * @return int |
||
1508 | * @throws UnexpectedEntityException |
||
1509 | * @throws \EE_Error |
||
1510 | */ |
||
1511 | public function get_event_ID() |
||
1516 | |||
1517 | |||
1518 | /** |
||
1519 | * This simply returns whether a ticket can be permanently deleted or not. |
||
1520 | * The criteria for determining this is whether the ticket has any related registrations. |
||
1521 | * If there are none then it can be permanently deleted. |
||
1522 | * |
||
1523 | * @return bool |
||
1524 | */ |
||
1525 | public function is_permanently_deleteable() |
||
1529 | } |
||
1530 |