| Conditions | 6 |
| Paths | 8 |
| Total Lines | 54 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 87 | protected function addTemplateArgs() |
||
| 88 | { |
||
| 89 | $row = 1; |
||
| 90 | $ticket_row_html = ''; |
||
| 91 | $required_ticket_sold_out = false; |
||
| 92 | // flag to indicate that at least one taxable ticket has been encountered |
||
| 93 | $taxable_tickets = false; |
||
| 94 | $datetime_selector = null; |
||
| 95 | $this->template_args['datetime_selector'] = ''; |
||
| 96 | if ( |
||
| 97 | $this->ticket_selector_config->getShowDatetimeSelector() |
||
| 98 | !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
||
| 99 | ) { |
||
| 100 | $datetime_selector = new DatetimeSelector( |
||
| 101 | $this->event, |
||
| 102 | $this->tickets, |
||
| 103 | $this->ticket_selector_config, |
||
| 104 | $this->date_format, |
||
| 105 | $this->time_format |
||
| 106 | ); |
||
| 107 | $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
||
| 108 | } |
||
| 109 | // loop through tickets |
||
| 110 | foreach ($this->tickets as $TKT_ID => $ticket) { |
||
| 111 | if ($ticket instanceof \EE_Ticket) { |
||
| 112 | $cols = 2; |
||
| 113 | $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
||
| 114 | $ticket_selector_row = new TicketSelectorRowStandard( |
||
| 115 | $ticket, |
||
| 116 | new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
||
| 117 | $this->ticket_selector_config, |
||
| 118 | $this->tax_config, |
||
| 119 | $this->max_attendees, |
||
| 120 | $row, |
||
| 121 | $cols, |
||
| 122 | $required_ticket_sold_out, |
||
| 123 | $this->template_args['event_status'], |
||
| 124 | $this->template_args['date_format'], |
||
| 125 | $datetime_selector instanceof DatetimeSelector |
||
| 126 | ? $datetime_selector->getTicketDatetimeClasses($ticket) |
||
| 127 | : '' |
||
| 128 | ); |
||
| 129 | $ticket_row_html .= $ticket_selector_row->getHtml(); |
||
| 130 | $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
||
| 131 | $row++; |
||
| 132 | } |
||
| 133 | } |
||
| 134 | $this->template_args['row'] = $row; |
||
| 135 | $this->template_args['ticket_row_html'] = $ticket_row_html; |
||
| 136 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
||
| 137 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
||
| 138 | $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
||
| 139 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
||
| 140 | } |
||
| 141 | |||
| 146 | // Location: EventEspresso\modules\ticket_selector/TicketSelectorStandard.php |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.