Conditions | 26 |
Paths | 625 |
Total Lines | 144 |
Code Lines | 103 |
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 |
||
119 | public function display( $event = null, $view_details = false ) |
||
120 | { |
||
121 | // reset filter for displaying submit button |
||
122 | remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
||
123 | // poke and prod incoming event till it tells us what it is |
||
124 | if ( ! $this->setEvent( $event ) ) { |
||
125 | return false; |
||
126 | } |
||
127 | if ( apply_filters( 'FHEE__EED_Events_Archive__event_list_iframe', false ) ) { |
||
128 | $this->setIframe(); |
||
129 | } |
||
130 | $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
||
131 | // grab event status |
||
132 | $_event_active_status = $this->event->get_active_status(); |
||
133 | if ( |
||
134 | ! is_admin() |
||
135 | && ( |
||
136 | ! $this->event->display_ticket_selector() |
||
137 | || $view_details |
||
138 | || post_password_required( $event_post ) |
||
139 | || ( |
||
140 | $_event_active_status !== \EE_Datetime::active |
||
141 | && $_event_active_status !== \EE_Datetime::upcoming |
||
142 | && $_event_active_status !== \EE_Datetime::sold_out |
||
143 | && ! ( |
||
144 | $_event_active_status === \EE_Datetime::inactive |
||
145 | && is_user_logged_in() |
||
146 | ) |
||
147 | ) |
||
148 | ) |
||
149 | ) { |
||
150 | return ! is_single() ? $this->displayViewDetailsButton() : ''; |
||
151 | } |
||
152 | $template_args = array(); |
||
153 | $template_args[ 'event_status' ] = $_event_active_status; |
||
154 | $template_args[ 'date_format' ] = apply_filters( |
||
155 | 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
||
156 | get_option( 'date_format' ) |
||
157 | ); |
||
158 | $template_args[ 'time_format' ] = apply_filters( |
||
159 | 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
||
160 | get_option( 'time_format' ) |
||
161 | ); |
||
162 | $template_args[ 'EVT_ID' ] = $this->event->ID(); |
||
163 | $template_args[ 'event' ] = $this->event; |
||
164 | // is the event expired ? |
||
165 | $template_args[ 'event_is_expired' ] = $this->event->is_expired(); |
||
166 | if ( $template_args[ 'event_is_expired' ] ) { |
||
167 | return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( |
||
168 | 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
||
169 | 'event_espresso' |
||
170 | ) . '</span></div>'; |
||
171 | } |
||
172 | $ticket_query_args = array( |
||
173 | array( 'Datetime.EVT_ID' => $this->event->ID() ), |
||
174 | 'order_by' => array( |
||
175 | 'TKT_order' => 'ASC', |
||
176 | 'TKT_required' => 'DESC', |
||
177 | 'TKT_start_date' => 'ASC', |
||
178 | 'TKT_end_date' => 'ASC', |
||
179 | 'Datetime.DTT_EVT_start' => 'DESC', |
||
180 | ), |
||
181 | ); |
||
182 | if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
||
183 | //use the correct applicable time query depending on what version of core is being run. |
||
184 | $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) |
||
185 | ? time() |
||
186 | : current_time( 'timestamp' ); |
||
187 | $ticket_query_args[ 0 ][ 'TKT_end_date' ] = array( '>', $current_time ); |
||
188 | } |
||
189 | // get all tickets for this event ordered by the datetime |
||
190 | $template_args[ 'tickets' ] = \EEM_Ticket::instance()->get_all( $ticket_query_args ); |
||
191 | if ( count( $template_args[ 'tickets' ] ) < 1 ) { |
||
192 | return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( |
||
193 | 'We\'re sorry, but all ticket sales have ended.', |
||
194 | 'event_espresso' |
||
195 | ) . '</span></div>'; |
||
196 | } |
||
197 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
||
198 | $this->setMaxAttendees( |
||
199 | apply_filters( |
||
200 | 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
||
201 | $this->event->additional_limit() |
||
202 | ) |
||
203 | ); |
||
204 | $template_args[ 'max_atndz' ] = $this->getMaxAttendees(); |
||
205 | if ( $template_args[ 'max_atndz' ] < 1 ) { |
||
206 | $sales_closed_msg = __( |
||
207 | 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
||
208 | 'event_espresso' |
||
209 | ); |
||
210 | if ( current_user_can( 'edit_post', $this->event->ID() ) ) { |
||
211 | $link = get_edit_post_link( $this->event->ID() ); |
||
212 | $sales_closed_msg .= sprintf( |
||
213 | __( |
||
214 | '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
||
215 | 'event_espresso' |
||
216 | ), |
||
217 | '<div class="ee-attention" style="text-align: left;"><b>', |
||
218 | '</b><br />', |
||
219 | $link = '<span class="edit-link"><a class="post-edit-link" href="' . $link . '">', |
||
220 | '</a></span></div>' |
||
221 | ); |
||
222 | } |
||
223 | return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
||
224 | } |
||
225 | $templates[ 'ticket_selector' ] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
||
226 | $templates[ 'ticket_selector' ] = apply_filters( |
||
227 | 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
||
228 | $templates[ 'ticket_selector' ], |
||
229 | $this->event |
||
230 | ); |
||
231 | // redirecting to another site for registration ?? |
||
232 | $external_url = $this->event->external_url() !== null || $this->event->external_url() !== '' |
||
233 | ? $this->event->external_url() |
||
234 | : ''; |
||
235 | // if not redirecting to another site for registration |
||
236 | if ( ! $external_url ) { |
||
237 | // then display the ticket selector |
||
238 | $ticket_selector = \EEH_Template::locate_template( $templates[ 'ticket_selector' ], $template_args ); |
||
239 | } else { |
||
240 | // if not we still need to trigger the display of the submit button |
||
241 | add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
||
242 | //display notice to admin that registration is external |
||
243 | $ticket_selector = ! is_admin() |
||
244 | ? '' |
||
245 | : __( |
||
246 | 'Registration is at an external URL for this event.', |
||
247 | 'event_espresso' |
||
248 | ); |
||
249 | } |
||
250 | $ticket_selector = ! is_admin() |
||
251 | ? $this->formOpen( |
||
252 | $this->event->ID(), |
||
253 | $external_url |
||
254 | ) . $ticket_selector |
||
255 | : $ticket_selector; |
||
256 | // now set up the form (but not for the admin) |
||
257 | // submit button and form close tag |
||
258 | $ticket_selector .= ! is_admin() ? $this->displaySubmitButton() : ''; |
||
259 | // set no cache headers and constants |
||
260 | \EE_System::do_not_cache(); |
||
261 | return $ticket_selector; |
||
262 | } |
||
263 | |||
515 | // Location: /DisplayTicketSelector.php |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.