Completed
Branch FET-9099-unit-test-factories (8a4437)
by
unknown
92:28 queued 80:41
created
core/business/EE_Transaction_Processor.class.php 1 patch
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Transaction_Processor
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 	 * @param array $registration_query_params
51 51
 	 *@return EE_Transaction_Processor instance
52 52
 	 */
53
-	public static function instance( $registration_query_params = array() ) {
53
+	public static function instance($registration_query_params = array()) {
54 54
 		// check if class object is instantiated
55
-		if ( ! self::$_instance instanceof EE_Transaction_Processor ) {
56
-			self::$_instance = new self( $registration_query_params );
55
+		if ( ! self::$_instance instanceof EE_Transaction_Processor) {
56
+			self::$_instance = new self($registration_query_params);
57 57
 		}
58 58
 		return self::$_instance;
59 59
 	}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * @param array $registration_query_params
65 65
 	 * @return EE_Transaction_Processor
66 66
 	 */
67
-	private function __construct( $registration_query_params = array() ) {
67
+	private function __construct($registration_query_params = array()) {
68 68
 		// make sure some query params are set for retrieving registrations
69
-		$this->_set_registration_query_params( $registration_query_params );
69
+		$this->_set_registration_query_params($registration_query_params);
70 70
 	}
71 71
 
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 * @access private
76 76
 	 * @param array $registration_query_params
77 77
 	 */
78
-	private function _set_registration_query_params( $registration_query_params ) {
79
-		$this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' ));
78
+	private function _set_registration_query_params($registration_query_params) {
79
+		$this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC'));
80 80
 	}
81 81
 
82 82
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * @param string $old_txn_status
95 95
 	 */
96
-	public function set_old_txn_status( $old_txn_status ) {
96
+	public function set_old_txn_status($old_txn_status) {
97 97
 		// only set the first time
98
-		if ( $this->_old_txn_status === null ) {
98
+		if ($this->_old_txn_status === null) {
99 99
 			$this->_old_txn_status = $old_txn_status;
100 100
 		}
101 101
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	/**
115 115
 	 * @param string $new_txn_status
116 116
 	 */
117
-	public function set_new_txn_status( $new_txn_status ) {
117
+	public function set_new_txn_status($new_txn_status) {
118 118
 		$this->_new_txn_status = $new_txn_status;
119 119
 	}
120 120
 
@@ -145,17 +145,17 @@  discard block
 block discarded – undo
145 145
 	 * @param bool   $check_all
146 146
 	 * @return boolean | int
147 147
 	 */
148
-	private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) {
148
+	private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) {
149 149
 		$reg_steps = $transaction->reg_steps();
150
-		if ( ! is_array( $reg_steps ) || empty( $reg_steps )) {
150
+		if ( ! is_array($reg_steps) || empty($reg_steps)) {
151 151
 			return false;
152 152
 		}
153 153
 		// loop thru reg steps array)
154
-		foreach ( $reg_steps as $slug => $reg_step_completed ) {
154
+		foreach ($reg_steps as $slug => $reg_step_completed) {
155 155
 			// if NOT checking ALL steps (only checking one step)
156
-			if ( ! $check_all ) {
156
+			if ( ! $check_all) {
157 157
 				// and this is the one
158
-				if ( $slug == $reg_step_slug ) {
158
+				if ($slug == $reg_step_slug) {
159 159
 					return $reg_step_completed;
160 160
 				} else {
161 161
 					// skip to next reg step in loop
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 				}
164 164
 			}
165 165
 			// if any reg step is NOT completed (ignoring any specific steps), then just leave
166
-			if ( $reg_step_completed !== true && $slug != $reg_step_slug ) {
166
+			if ($reg_step_completed !== true && $slug != $reg_step_slug) {
167 167
 				return false;
168
-			} else if ( $slug == $reg_step_slug ) {
168
+			} else if ($slug == $reg_step_slug) {
169 169
 				// if we reach this point, then we are testing either:
170 170
 				// all_reg_steps_completed_except() or
171 171
 				// all_reg_steps_completed_except_final_step(),
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 * @param EE_Transaction $transaction
191 191
 	 * @return boolean
192 192
 	 */
193
-	public function all_reg_steps_completed( EE_Transaction $transaction ) {
194
-		return $this->_reg_steps_completed( $transaction );
193
+	public function all_reg_steps_completed(EE_Transaction $transaction) {
194
+		return $this->_reg_steps_completed($transaction);
195 195
 	}
196 196
 
197 197
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param string $exception
209 209
 	 * @return boolean
210 210
 	 */
211
-	public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) {
212
-		return $this->_reg_steps_completed( $transaction, $exception );
211
+	public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') {
212
+		return $this->_reg_steps_completed($transaction, $exception);
213 213
 	}
214 214
 
215 215
 
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Transaction $transaction
226 226
 	 * @return boolean
227 227
 	 */
228
-	public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) {
229
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration' );
228
+	public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) {
229
+		return $this->_reg_steps_completed($transaction, 'finalize_registration');
230 230
 	}
231 231
 
232 232
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 * @param string $reg_step_slug
244 244
 	 * @return boolean | int
245 245
 	 */
246
-	public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
247
-		return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE );
246
+	public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
247
+		return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE);
248 248
 	}
249 249
 
250 250
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @param EE_Transaction $transaction
261 261
 	 * @return boolean | int
262 262
 	 */
263
-	public function final_reg_step_completed( EE_Transaction $transaction ) {
264
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE );
263
+	public function final_reg_step_completed(EE_Transaction $transaction) {
264
+		return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE);
265 265
 	}
266 266
 
267 267
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 * @param string          $reg_step_slug
276 276
 	 * @return boolean
277 277
 	 */
278
-	public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) {
278
+	public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) {
279 279
 		$current_time = time();
280
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, $current_time );
280
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, $current_time);
281 281
 	}
282 282
 
283 283
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 	 * @param string          $reg_step_slug
292 292
 	 * @return boolean
293 293
 	 */
294
-	public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
295
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, TRUE );
294
+	public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
295
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, TRUE);
296 296
 	}
297 297
 
298 298
 
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 	 * @param string          $reg_step_slug
307 307
 	 * @return boolean
308 308
 	 */
309
-	public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) {
310
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, FALSE );
309
+	public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) {
310
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, FALSE);
311 311
 	}
312 312
 
313 313
 
@@ -323,36 +323,36 @@  discard block
 block discarded – undo
323 323
 	 * @param boolean | int $status
324 324
 	 * @return boolean
325 325
 	 */
326
-	private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) {
326
+	private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) {
327 327
 		// validate status
328
-		$status = is_bool( $status ) || is_numeric( $status ) ? $status : false;
328
+		$status = is_bool($status) || is_numeric($status) ? $status : false;
329 329
 		// get reg steps array
330 330
 		$txn_reg_steps = $transaction->reg_steps();
331 331
 		// if reg step does NOT exist
332
-		if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) {
332
+		if ( ! isset($txn_reg_steps[$reg_step_slug])) {
333 333
 			return false;
334 334
 		}
335 335
 		// if  we're trying to complete a step that is already completed
336
-		if ( $txn_reg_steps[ $reg_step_slug ] === true ) {
336
+		if ($txn_reg_steps[$reg_step_slug] === true) {
337 337
 			return true;
338 338
 		}
339 339
 		// if  we're trying to complete a step that hasn't even started
340
-		if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) {
340
+		if ($status === true && $txn_reg_steps[$reg_step_slug] === false) {
341 341
 			return false;
342 342
 		}
343 343
 		// if current status value matches the incoming value (no change)
344
-		if ( $txn_reg_steps[ $reg_step_slug ] === $status ) {
344
+		if ($txn_reg_steps[$reg_step_slug] === $status) {
345 345
 			// this will happen in cases where multiple AJAX requests occur during the same step
346 346
 			return true;
347 347
 		}
348 348
 		// if we're trying to set a start time
349
-		if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) {
349
+		if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) {
350 350
 			// skip the update below, but don't return FALSE so that errors won't be displayed
351 351
 			return true;
352 352
 		}
353 353
 		// update completed status
354
-		$txn_reg_steps[ $reg_step_slug ] = $status;
355
-		$transaction->set_reg_steps( $txn_reg_steps );
354
+		$txn_reg_steps[$reg_step_slug] = $status;
355
+		$transaction->set_reg_steps($txn_reg_steps);
356 356
 		$transaction->save();
357 357
 		// DEBUG LOG
358 358
 		//$this->log(
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
 	 * @param string $reg_step_slug
379 379
 	 * @return void
380 380
 	 */
381
-	public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) {
381
+	public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) {
382 382
 		// get reg steps array
383 383
 		$txn_reg_steps = $transaction->reg_steps();
384
-		unset( $txn_reg_steps[ $reg_step_slug ] );
385
-		$transaction->set_reg_steps( $txn_reg_steps );
384
+		unset($txn_reg_steps[$reg_step_slug]);
385
+		$transaction->set_reg_steps($txn_reg_steps);
386 386
 	}
387 387
 
388 388
 
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 	 * @param EE_Transaction $transaction
397 397
 	 * 	@return 	boolean
398 398
 	 */
399
-	public function toggle_failed_transaction_status( EE_Transaction $transaction ) {
399
+	public function toggle_failed_transaction_status(EE_Transaction $transaction) {
400 400
 		// set incoming TXN_Status
401
-		$this->set_old_txn_status( $transaction->status_ID() );
401
+		$this->set_old_txn_status($transaction->status_ID());
402 402
 		// if TXN status is still set as "failed"...
403
-		if ( $transaction->status_ID() == EEM_Transaction::failed_status_code ) {
403
+		if ($transaction->status_ID() == EEM_Transaction::failed_status_code) {
404 404
 			// set incoming TXN_Status
405
-			$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
406
-			$transaction->set_status( EEM_Transaction::abandoned_status_code );
405
+			$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
406
+			$transaction->set_status(EEM_Transaction::abandoned_status_code);
407 407
 			return TRUE;
408 408
 		}
409 409
 		return FALSE;
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
 	 * @param EE_Transaction $transaction
420 420
 	 * 	@return 	boolean
421 421
 	 */
422
-	public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) {
422
+	public function toggle_abandoned_transaction_status(EE_Transaction $transaction) {
423 423
 		// set incoming TXN_Status
424
-		$this->set_old_txn_status( $transaction->status_ID() );
424
+		$this->set_old_txn_status($transaction->status_ID());
425 425
 		// if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"...
426
-		if ( $transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code ) {
427
-			$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
426
+		if ($transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code) {
427
+			$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
428 428
 			// if a contact record for the primary registrant has been created
429
-			if ( $transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee ) {
430
-				$transaction->set_status( EEM_Transaction::incomplete_status_code );
431
-				$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
429
+			if ($transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee) {
430
+				$transaction->set_status(EEM_Transaction::incomplete_status_code);
431
+				$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
432 432
 			} else {
433 433
 				// no contact record? yer abandoned!
434
-				$transaction->set_status( EEM_Transaction::abandoned_status_code );
435
-				$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
434
+				$transaction->set_status(EEM_Transaction::abandoned_status_code);
435
+				$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
436 436
 			}
437 437
 			return TRUE;
438 438
 		}
@@ -450,16 +450,16 @@  discard block
 block discarded – undo
450 450
 	 * @param array 	$registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction
451 451
 	 * 	@return 	boolean
452 452
 	 */
453
-	public function manually_update_registration_statuses( EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array() ) {
454
-		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status );
453
+	public function manually_update_registration_statuses(EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array()) {
454
+		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor('manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status);
455 455
 		// send messages
456 456
 		/** @type EE_Registration_Processor $registration_processor */
457
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
457
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
458 458
 		$registration_processor->trigger_registration_update_notifications(
459 459
 			$transaction->primary_registration(),
460
-			array( 'manually_updated' 	=> true )
460
+			array('manually_updated' 	=> true)
461 461
 		);
462
-		do_action( 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates );
462
+		do_action('AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates);
463 463
 		return $status_updates;
464 464
 	}
465 465
 
@@ -473,9 +473,9 @@  discard block
 block discarded – undo
473 473
 	 * @param array 	$registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction
474 474
 	 * 	@return 	boolean
475 475
 	 */
476
-	public function toggle_registration_statuses_for_default_approved_events( EE_Transaction $transaction, $registration_query_params = array() ) {
477
-		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params );
478
-		do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates );
476
+	public function toggle_registration_statuses_for_default_approved_events(EE_Transaction $transaction, $registration_query_params = array()) {
477
+		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params);
478
+		do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates);
479 479
 		return $status_updates;
480 480
 	}
481 481
 
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
 	 * @param array 	$registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction
490 490
 	 * 	@return 	boolean
491 491
 	 */
492
-	public function toggle_registration_statuses_if_no_monies_owing( EE_Transaction $transaction, $registration_query_params = array() ) {
493
-		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params );
494
-		do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates );
492
+	public function toggle_registration_statuses_if_no_monies_owing(EE_Transaction $transaction, $registration_query_params = array()) {
493
+		$status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params);
494
+		do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates);
495 495
 		return $status_updates;
496 496
 	}
497 497
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
 	 * @throws \EE_Error
508 508
 	 * @return array
509 509
 	 */
510
-	public function update_transaction_and_registrations_after_checkout_or_payment( EE_Transaction $transaction, $payment = NULL, $registration_query_params = array() ) {
510
+	public function update_transaction_and_registrations_after_checkout_or_payment(EE_Transaction $transaction, $payment = NULL, $registration_query_params = array()) {
511 511
 		// set incoming TXN_Status, and consider it new since old status should have been set
512
-		$this->set_new_txn_status( $transaction->status_ID() );
513
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' );
512
+		$this->set_new_txn_status($transaction->status_ID());
513
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()');
514 514
 		// make sure some query params are set for retrieving registrations
515
-		$this->_set_registration_query_params( $registration_query_params );
515
+		$this->_set_registration_query_params($registration_query_params);
516 516
 		// get final reg step status
517
-		$finalized = $this->final_reg_step_completed( $transaction );
517
+		$finalized = $this->final_reg_step_completed($transaction);
518 518
 		// if the 'finalize_registration' step has been initiated (has a timestamp) but has not yet been fully completed (TRUE)
519
-		if ( is_numeric( $finalized ) && $finalized !== true ) {
520
-			$this->set_reg_step_completed( $transaction, 'finalize_registration' );
519
+		if (is_numeric($finalized) && $finalized !== true) {
520
+			$this->set_reg_step_completed($transaction, 'finalize_registration');
521 521
 			$finalized = true;
522 522
 		}
523 523
 		$transaction->save();
@@ -540,13 +540,13 @@  discard block
 block discarded – undo
540 540
 
541 541
 		// send messages
542 542
 		/** @type EE_Registration_Processor $registration_processor */
543
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
543
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
544 544
 		$registration_processor->trigger_registration_update_notifications(
545 545
 			$transaction->primary_registration(),
546 546
 			$update_params
547 547
 		);
548 548
 
549
-		do_action( 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params );
549
+		do_action('AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params);
550 550
 		return $update_params;
551 551
 	}
552 552
 
@@ -564,23 +564,23 @@  discard block
 block discarded – undo
564 564
 	 * @throws \EE_Error
565 565
 	 * @return boolean
566 566
 	 */
567
-	private function _call_method_on_registrations_via_Registration_Processor( $method_name,  EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL ) {
567
+	private function _call_method_on_registrations_via_Registration_Processor($method_name, EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL) {
568 568
 		$response = FALSE;
569 569
 		/** @type EE_Registration_Processor $registration_processor */
570
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
570
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
571 571
 		// check that method exists
572
-		if ( ! method_exists( $registration_processor, $method_name )) {
573
-			throw new EE_Error( __( 'Method does not exist.', 'event_espresso' ));
572
+		if ( ! method_exists($registration_processor, $method_name)) {
573
+			throw new EE_Error(__('Method does not exist.', 'event_espresso'));
574 574
 		}
575 575
 		// make sure some query params are set for retrieving registrations
576
-		$this->_set_registration_query_params( $registration_query_params );
576
+		$this->_set_registration_query_params($registration_query_params);
577 577
 		// loop through cached registrations
578
-		foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) {
579
-			if ( $registration instanceof EE_Registration ) {
580
-				if ( $additional_param ) {
581
-					$response = $registration_processor->{$method_name}( $registration, $additional_param ) ? TRUE : $response;
578
+		foreach ($transaction->registrations($this->_registration_query_params) as $registration) {
579
+			if ($registration instanceof EE_Registration) {
580
+				if ($additional_param) {
581
+					$response = $registration_processor->{$method_name}($registration, $additional_param) ? TRUE : $response;
582 582
 				} else {
583
-					$response = $registration_processor->{$method_name}( $registration ) ? TRUE : $response;
583
+					$response = $registration_processor->{$method_name}($registration) ? TRUE : $response;
584 584
 				}
585 585
 			}
586 586
 		}
@@ -605,46 +605,46 @@  discard block
 block discarded – undo
605 605
 	public function set_transaction_payment_method_based_on_registration_statuses(
606 606
 		EE_Registration $edited_registration
607 607
 	) {
608
-		if ( $edited_registration instanceof EE_Registration ) {
608
+		if ($edited_registration instanceof EE_Registration) {
609 609
 			$transaction = $edited_registration->transaction();
610
-			if ( $transaction instanceof EE_Transaction ) {
610
+			if ($transaction instanceof EE_Transaction) {
611 611
 				$all_not_approved = true;
612
-				foreach ( $transaction->registrations() as $registration ) {
613
-					if ( $registration instanceof EE_Registration ) {
612
+				foreach ($transaction->registrations() as $registration) {
613
+					if ($registration instanceof EE_Registration) {
614 614
 						// if any REG != "Not Approved" then toggle to false
615 615
 						$all_not_approved = $registration->is_not_approved() ? $all_not_approved : false;
616 616
 					}
617 617
 				}
618 618
 				// if ALL Registrations are "Not Approved"
619
-				if ( $all_not_approved ) {
620
-					$transaction->set_payment_method_ID( null );
619
+				if ($all_not_approved) {
620
+					$transaction->set_payment_method_ID(null);
621 621
 					$transaction->save();
622 622
 				} else {
623
-					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart );
624
-					if ( ! empty( $available_payment_methods ) ) {
623
+					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart);
624
+					if ( ! empty($available_payment_methods)) {
625 625
 						$PMD_ID = 0;
626
-						foreach ( $available_payment_methods as $available_payment_method ) {
627
-							if ( $available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default() ) {
626
+						foreach ($available_payment_methods as $available_payment_method) {
627
+							if ($available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default()) {
628 628
 								$PMD_ID = $available_payment_method->ID();
629 629
 								break;
630 630
 							}
631 631
 						}
632
-						if ( ! $PMD_ID ) {
633
-							$first_payment_method = reset( $available_payment_methods );
634
-							if ( $first_payment_method instanceof EE_Payment_Method ) {
632
+						if ( ! $PMD_ID) {
633
+							$first_payment_method = reset($available_payment_methods);
634
+							if ($first_payment_method instanceof EE_Payment_Method) {
635 635
 								$PMD_ID = $first_payment_method->ID();
636 636
 							} else {
637 637
 								EE_Error::add_error(
638
-									__( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ),
638
+									__('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'),
639 639
 									__FILE__, __LINE__, __FUNCTION__
640 640
 								);
641 641
 							}
642 642
 						}
643
-						$transaction->set_payment_method_ID( $PMD_ID );
643
+						$transaction->set_payment_method_ID($PMD_ID);
644 644
 						$transaction->save();
645 645
 					} else {
646 646
 						EE_Error::add_error(
647
-							__( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ),
647
+							__('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'),
648 648
 							__FILE__, __LINE__, __FUNCTION__
649 649
 						);
650 650
 					}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Base.core.php 1 patch
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * All children of this must call parent::__construct() at the end of their constructor or suffer the consequences!
118 118
 	 */
119 119
 	public function __construct() {
120
-		$this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages',$this->_migration_stages);
121
-		foreach($this->_migration_stages as $migration_stage){
122
-			if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) {
120
+		$this->_migration_stages = apply_filters('FHEE__'.get_class($this).'__construct__migration_stages', $this->_migration_stages);
121
+		foreach ($this->_migration_stages as $migration_stage) {
122
+			if ($migration_stage instanceof EE_Data_Migration_Script_Stage) {
123 123
 				$migration_stage->_construct_finalize($this);
124 124
 			}
125 125
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * Place to add hooks and filters for tweaking the migrations page, in order
133 133
 	 * to customize it
134 134
 	 */
135
-	public function migration_page_hooks(){
135
+	public function migration_page_hooks() {
136 136
 		//by default none are added because we normally like the default look of the migration page
137 137
 	}
138 138
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @param int|string $new_pk eg posts.ID
148 148
 	 * @return void
149 149
 	 */
150
-	public function set_mapping($old_table,$old_pk,$new_table,$new_pk){
150
+	public function set_mapping($old_table, $old_pk, $new_table, $new_pk) {
151 151
 		//make sure it has the needed keys
152
-		if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){
152
+		if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) {
153 153
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
154 154
 		}
155 155
 		$this->_mappings[$old_table][$new_table][$old_pk] = $new_pk;
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts
166 166
 	 * @return mixed the primary key on the new table
167 167
 	 */
168
-	public function get_mapping_new_pk($old_table,$old_pk,$new_table){
169
-		if( ! isset($this->_mappings[$old_table]) ||
170
-			! isset($this->_mappings[$old_table][$new_table])){
168
+	public function get_mapping_new_pk($old_table, $old_pk, $new_table) {
169
+		if ( ! isset($this->_mappings[$old_table]) ||
170
+			! isset($this->_mappings[$old_table][$new_table])) {
171 171
 			//try fetching the option
172 172
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
173 173
 		}
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 	 * @param mixed $new_pk
185 185
 	 * @return mixed
186 186
 	 */
187
-	public function get_mapping_old_pk($old_table,$new_table,$new_pk){
188
-		if( ! isset($this->_mappings[$old_table]) ||
189
-			! isset($this->_mappings[$old_table][$new_table])){
187
+	public function get_mapping_old_pk($old_table, $new_table, $new_pk) {
188
+		if ( ! isset($this->_mappings[$old_table]) ||
189
+			! isset($this->_mappings[$old_table][$new_table])) {
190 190
 			//try fetching the option
191 191
 			$this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table);
192 192
 		}
193
-		if(isset($this->_mappings[$old_table][$new_table])){
193
+		if (isset($this->_mappings[$old_table][$new_table])) {
194 194
 			$new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]);
195
-			if(isset($new_pk_to_old_pk[$new_pk])){
195
+			if (isset($new_pk_to_old_pk[$new_pk])) {
196 196
 				return $new_pk_to_old_pk[$new_pk];
197 197
 			}
198 198
 		}
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param string $new_table_name
208 208
 	 * @return array
209 209
 	 */
210
-	protected function _get_mapping_option($old_table_name,$new_table_name){
211
-		$option =  get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array());
210
+	protected function _get_mapping_option($old_table_name, $new_table_name) {
211
+		$option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array());
212 212
 		return $option;
213 213
 	}
214 214
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	 * @param array $mapping_array
222 222
 	 * @return boolean success of updating option
223 223
 	 */
224
-	protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){
224
+	protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) {
225 225
 //		echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>";
226
-		$success =  update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array);
226
+		$success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array);
227 227
 		return $success;
228 228
 	}
229 229
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param string $new_table_name
236 236
 	 * @return string
237 237
 	 */
238
-	protected function _get_mapping_option_name($old_table_name,$new_table_name){
238
+	protected function _get_mapping_option_name($old_table_name, $new_table_name) {
239 239
 		global $wpdb;
240
-		$old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name);
241
-		$new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name);
240
+		$old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name);
241
+		$new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name);
242 242
 		$migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
243
-		return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 );
243
+		return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64);
244 244
 	}
245 245
 
246 246
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete.
258 258
 	 * @return int
259 259
 	 */
260
-	protected function _count_records_to_migrate(){
260
+	protected function _count_records_to_migrate() {
261 261
 		$count = 0;
262
-		foreach($this->stages() as $stage){
263
-			$count+= $stage->count_records_to_migrate();
262
+		foreach ($this->stages() as $stage) {
263
+			$count += $stage->count_records_to_migrate();
264 264
 		}
265 265
 		return $count;
266 266
 	}
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 	 * by just setting a transient and updating it after each migration_step
273 273
 	 * @return int
274 274
 	 */
275
-	public function count_records_migrated(){
275
+	public function count_records_migrated() {
276 276
 		$count = 0;
277
-		foreach($this->stages() as $stage){
278
-			$count+= $stage->count_records_migrated();
277
+		foreach ($this->stages() as $stage) {
278
+			$count += $stage->count_records_migrated();
279 279
 		}
280 280
 		$this->_records_migrated = $count;
281 281
 		return $count;
@@ -289,24 +289,24 @@  discard block
 block discarded – undo
289 289
 	 * @throws EE_Error
290 290
 	 * @throws Exception
291 291
 	 */
292
-	public function migration_step($num_records_to_migrate_limit){
292
+	public function migration_step($num_records_to_migrate_limit) {
293 293
 		//reset the feedback message
294 294
 		$this->_feedback_message = '';
295 295
 		//if we haven't yet done the 1st schema changes, do them now. buffer any output
296 296
 		$this->_maybe_do_schema_changes(true);
297 297
 
298
-		$num_records_actually_migrated =0;
298
+		$num_records_actually_migrated = 0;
299 299
 		$records_migrated_per_stage = array();
300 300
 		//setup the 'stage' variable, which should hold the last run stage of the migration  (or none at all if nothing runs)
301 301
 		$stage = null;
302 302
 		//get the next stage that isn't complete
303
-		foreach($this->stages() as $stage){
304
-			if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){
305
-				try{
303
+		foreach ($this->stages() as $stage) {
304
+			if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) {
305
+				try {
306 306
 					$records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated);
307 307
 					$num_records_actually_migrated += $records_migrated_during_stage;
308 308
 					$records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage;
309
-				}catch(Exception $e){
309
+				} catch (Exception $e) {
310 310
 					//yes if we catch an exception here, we consider that migration stage borked.
311 311
 					$stage->set_status(EE_Data_Migration_Manager::status_fatal_error);
312 312
 					$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 					throw $e;
315 315
 				}
316 316
 				//check that the migration stage didn't mark itself as having a fatal error
317
-				if($stage->is_broken()){
317
+				if ($stage->is_broken()) {
318 318
 					$this->set_broken();
319 319
 					throw new EE_Error($stage->get_last_error());
320 320
 				}
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 			//once we've migrated all the number we intended to (possibly from different stages), stop migrating
323 323
 			//or if we had a fatal error
324 324
 			//or if the current script stopped early- its not done, but it's done all it thinks we should do on this step
325
-			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){
325
+			if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) {
326 326
 				break;
327 327
 			}
328 328
 		}
329 329
 		//check if we're all done this data migration...
330 330
 		//which is indicated by being done early AND the last stage claims to be done
331
-		if($stage == NULL){
331
+		if ($stage == NULL) {
332 332
 			//this migration script apparently has NO stages... which is super weird, but whatever
333 333
 			$this->set_completed();
334 334
 			$this->_maybe_do_schema_changes(false);
335
-		}else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){
335
+		} else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) {
336 336
 			//apparently we're done, because we couldn't migrate the number we intended to
337 337
 			$this->set_completed();
338 338
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
339 339
 			//do schema changes for after the migration now
340 340
 			//first double-check we haven't already done this
341 341
 			$this->_maybe_do_schema_changes(false);
342
-		}else{
342
+		} else {
343 343
 			//update feedback message, keeping in mind that we show them with the most recent at the top
344 344
 			$this->_update_feedback_message(array_reverse($records_migrated_per_stage));
345 345
 		}
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 	 * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage
354 354
 	 * @return void
355 355
 	 */
356
-	private function _update_feedback_message($records_migrated_per_stage){
356
+	private function _update_feedback_message($records_migrated_per_stage) {
357 357
 		$feedback_message_array = array();
358
-		foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){
359
-			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ;
358
+		foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) {
359
+			$feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name);
360 360
 		}
361
-		$this->_feedback_message .= implode("<br>",$feedback_message_array);
361
+		$this->_feedback_message .= implode("<br>", $feedback_message_array);
362 362
 	}
363 363
 
364 364
 
@@ -370,27 +370,27 @@  discard block
 block discarded – undo
370 370
 	 * @throws Exception
371 371
 	 * @return void
372 372
 	 */
373
-	private function _maybe_do_schema_changes($before = true){
373
+	private function _maybe_do_schema_changes($before = true) {
374 374
 		//so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran
375
-		$property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran';
376
-		if ( ! $this->{$property_name} ){
377
-			try{
375
+		$property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran';
376
+		if ( ! $this->{$property_name} ) {
377
+			try {
378 378
 				ob_start();
379
-				if($before){
379
+				if ($before) {
380 380
 					$this->schema_changes_before_migration();
381
-				}else{
381
+				} else {
382 382
 					$this->schema_changes_after_migration();
383 383
 				}
384 384
 				$output = ob_get_contents();
385 385
 				ob_end_clean();
386
-			}catch(Exception $e){
386
+			} catch (Exception $e) {
387 387
 				$this->set_status(EE_Data_Migration_Manager::status_fatal_error);
388 388
 				throw $e;
389 389
 			}
390 390
 			//record that we've done these schema changes
391 391
 			$this->{$property_name} = true;
392 392
 			//if there were any warnings etc, record them as non-fatal errors
393
-			if( $output ){
393
+			if ($output) {
394 394
 				//there were some warnings
395 395
 				$this->_errors[] = $output;
396 396
 			}
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 	 * @param string $table_definition_sql
418 418
 	 * @param string $engine_string
419 419
 	 */
420
-	protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){
420
+	protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') {
421 421
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name );
422
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  true ) );
422
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true));
423 423
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name  );
424 424
 	}
425 425
 
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 	 * @param string $table_definition_sql
434 434
 	 * @param string $engine_string
435 435
 	 */
436
-	protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
436
+	protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
437 437
 //		EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name );
438
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
438
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
439 439
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name  );
440 440
 	}
441 441
 
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 	 * @param string $table_name
447 447
 	 * @return boolean
448 448
 	 */
449
-	protected function _old_table_exists( $table_name ) {
450
-		EE_Registry::instance()->load_helper( 'Activation' );
451
-		return EEH_Activation::table_exists( $table_name );
449
+	protected function _old_table_exists($table_name) {
450
+		EE_Registry::instance()->load_helper('Activation');
451
+		return EEH_Activation::table_exists($table_name);
452 452
 	}
453 453
 
454 454
 
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
 	 * @param string $table_name
459 459
 	 * @return boolean
460 460
 	 */
461
-	protected function _delete_table_if_empty( $table_name ) {
462
-		EE_Registry::instance()->load_helper( 'Activation' );
463
-		return EEH_Activation::delete_db_table_if_empty( $table_name );
461
+	protected function _delete_table_if_empty($table_name) {
462
+		EE_Registry::instance()->load_helper('Activation');
463
+		return EEH_Activation::delete_db_table_if_empty($table_name);
464 464
 	}
465 465
 
466 466
 
@@ -479,9 +479,9 @@  discard block
 block discarded – undo
479 479
 	 * @param string $table_definition_sql
480 480
 	 * @param string $engine_string
481 481
 	 */
482
-	protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
482
+	protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
483 483
 //		EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name );
484
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
484
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
485 485
 //		EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
486 486
 	}
487 487
 
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
 	 * @param string $table_definition_sql
497 497
 	 * @param string $engine_string
498 498
 	 */
499
-	protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){
500
-		if( $this->_currently_migrating() ) {
499
+	protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') {
500
+		if ($this->_currently_migrating()) {
501 501
 			//if we're doing a migration, and this table apparently already exists, then we don't need do anything right?
502 502
 //			EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name );
503 503
 			return;
504 504
 		}
505
-		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(  false ) );
505
+		$this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false));
506 506
 	}
507 507
 
508 508
 	/**
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 	protected function _currently_migrating() {
513 513
 		//we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM)
514 514
 		return $this->_migrating &&
515
-					$this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) &&
515
+					$this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) &&
516 516
 					EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance;
517 517
 	}
518 518
 
@@ -523,17 +523,17 @@  discard block
 block discarded – undo
523 523
 	 * @param boolean $table_is_new
524 524
 	 * @return boolean
525 525
 	 */
526
-	protected function _pre_existing_table_should_be_dropped( $table_is_new ) {
527
-		if( $table_is_new ) {
528
-			if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation  || $this->_currently_migrating() ){
526
+	protected function _pre_existing_table_should_be_dropped($table_is_new) {
527
+		if ($table_is_new) {
528
+			if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) {
529 529
 				return true;
530
-			}else{
530
+			} else {
531 531
 				return false;
532 532
 			}
533
-		}else{
534
-			if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){
533
+		} else {
534
+			if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) {
535 535
 				return true;
536
-			}else{
536
+			} else {
537 537
 				return false;
538 538
 			}
539 539
 		}
@@ -546,13 +546,13 @@  discard block
 block discarded – undo
546 546
 	 * @param string $engine_string
547 547
 	 * @param boolean $drop_pre_existing_tables
548 548
 	 */
549
-	private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){
549
+	private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) {
550 550
 		EE_Registry::instance()->load_helper('Activation');
551
-		try{
552
-			EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables);
553
-		}catch( EE_Error $e ) {
554
-			$message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString();
555
-			$this->add_error( $message  );
551
+		try {
552
+			EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables);
553
+		} catch (EE_Error $e) {
554
+			$message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString();
555
+			$this->add_error($message);
556 556
 			$this->_feedback_message .= $message;
557 557
 		}
558 558
 	}
@@ -564,15 +564,15 @@  discard block
 block discarded – undo
564 564
 	 * @return int one of EE_System::_req_type_* constants
565 565
 	 * @throws EE_Error
566 566
 	 */
567
-	private function _get_req_type_for_plugin_corresponding_to_this_dms(){
568
-		if($this->slug() == 'Core'){
567
+	private function _get_req_type_for_plugin_corresponding_to_this_dms() {
568
+		if ($this->slug() == 'Core') {
569 569
 			return EE_System::instance()->detect_req_type();
570
-		}else{//it must be for an addon
570
+		} else {//it must be for an addon
571 571
 			$addon_name = $this->slug();
572
-			if( EE_Registry::instance()->get_addon_by_name($addon_name)){
572
+			if (EE_Registry::instance()->get_addon_by_name($addon_name)) {
573 573
 				return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type();
574
-			}else{
575
-				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ;
574
+			} else {
575
+				throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))));
576 576
 			}
577 577
 		}
578 578
 	}
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 	 * returns an array of strings describing errors by all the script's stages
584 584
 	 * @return array
585 585
 	 */
586
-	public function get_errors(){
586
+	public function get_errors() {
587 587
 		$all_errors = $this->_errors;
588
-		if( ! is_array($all_errors)){
588
+		if ( ! is_array($all_errors)) {
589 589
 			$all_errors = array();
590 590
 		}
591
-		foreach($this->stages() as $stage){
592
-			$all_errors = array_merge($stage->get_errors(),$all_errors);
591
+		foreach ($this->stages() as $stage) {
592
+			$all_errors = array_merge($stage->get_errors(), $all_errors);
593 593
 		}
594 594
 		return $all_errors;
595 595
 	}
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * Indicates whether or not this migration script should continue
601 601
 	 * @return boolean
602 602
 	 */
603
-	public function can_continue(){
604
-		return in_array($this->get_status(),  EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
603
+	public function can_continue() {
604
+		return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script);
605 605
 	}
606 606
 
607 607
 
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * get ordered by the indexes
614 614
 	 * @return EE_Data_Migration_Script_Stage[]
615 615
 	 */
616
-	protected function stages(){
617
-		$stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages );
616
+	protected function stages() {
617
+		$stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages);
618 618
 		ksort($stages);
619 619
 		return $stages;
620 620
 	}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	 * can be displayed to the user
627 627
 	 * @return string
628 628
 	 */
629
-	public function get_feedback_message(){
629
+	public function get_feedback_message() {
630 630
 		return $this->_feedback_message;
631 631
 	}
632 632
 
@@ -638,16 +638,16 @@  discard block
 block discarded – undo
638 638
 	 * possible that this class is defined when it goes to sleep, but NOT available when it
639 639
 	 * awakes (eg, this class is part of an addon that is deactivated at some point).
640 640
 	 */
641
-	public function properties_as_array(){
641
+	public function properties_as_array() {
642 642
 		$properties = parent::properties_as_array();
643 643
 		$properties['_migration_stages'] = array();
644
-		foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){
644
+		foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) {
645 645
 			$properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array();
646 646
 		}
647 647
 		unset($properties['_mappings']);
648 648
 
649
-		foreach($this->_mappings as $old_table_name => $mapping_to_new_table){
650
-			foreach($mapping_to_new_table as $new_table_name => $mapping){
649
+		foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) {
650
+			foreach ($mapping_to_new_table as $new_table_name => $mapping) {
651 651
 				$this->_set_mapping_option($old_table_name, $new_table_name, $mapping);
652 652
 			}
653 653
 		}
@@ -662,19 +662,19 @@  discard block
 block discarded – undo
662 662
 	 * @param array $array_of_properties like what's produced from properties_as_array() method
663 663
 	 * @return void
664 664
 	 */
665
-	public function instantiate_from_array_of_properties($array_of_properties){
665
+	public function instantiate_from_array_of_properties($array_of_properties) {
666 666
 		$stages_properties_arrays = $array_of_properties['_migration_stages'];
667 667
 		unset($array_of_properties['_migration_stages']);
668 668
 		unset($array_of_properties['class']);
669
-		foreach($array_of_properties as $property_name => $property_value){
669
+		foreach ($array_of_properties as $property_name => $property_value) {
670 670
 			$this->{$property_name} = $property_value;
671 671
 		}
672 672
 		//_migration_stages are already instantiated, but have only default data
673
-		foreach($this->_migration_stages as $stage){
674
-			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays);
673
+		foreach ($this->_migration_stages as $stage) {
674
+			$stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays);
675 675
 			//SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by
676 676
 			//an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet)
677
-			if($stage_data){
677
+			if ($stage_data) {
678 678
 				$stage->instantiate_from_array_of_properties($stage_data);
679 679
 			}
680 680
 		}
@@ -690,9 +690,9 @@  discard block
 block discarded – undo
690 690
 	 * @param array $migration_stage_data_arrays
691 691
 	 * @return null
692 692
 	 */
693
-	private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){
694
-		foreach($migration_stage_data_arrays as $migration_stage_data_array){
695
-			if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){
693
+	private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) {
694
+		foreach ($migration_stage_data_arrays as $migration_stage_data_array) {
695
+			if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) {
696 696
 				return $migration_stage_data_array;
697 697
 			}
698 698
 		}
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
 	 * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin
709 709
 	 * that will be updated to. Eg array('Core','4.1.0')
710 710
 	 */
711
-	public final function migrates_to_version(){
712
-		return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) );
711
+	public final function migrates_to_version() {
712
+		return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this));
713 713
 	}
714 714
 
715 715
 
@@ -721,10 +721,10 @@  discard block
 block discarded – undo
721 721
 	 * Or 'Core' for core (non-addon).
722 722
 	 * @return string
723 723
 	 */
724
-	public function slug(){
724
+	public function slug() {
725 725
 		$migrates_to_version_info = $this->migrates_to_version();
726 726
 		//the slug is the first part of the array
727
-		return $migrates_to_version_info[ 'slug' ];
727
+		return $migrates_to_version_info['slug'];
728 728
 	}
729 729
 
730 730
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 * the database up so it can run), then you can set "A" to priority 3 or something.
739 739
 	 * @return int
740 740
 	 */
741
-	public function priority(){
741
+	public function priority() {
742 742
 		return $this->_priority;
743 743
 	}
744 744
 
@@ -751,18 +751,18 @@  discard block
 block discarded – undo
751 751
 	 * @param boolean $migrating
752 752
 	 * @return void
753 753
 	 */
754
-	public function set_migrating( $migrating = TRUE ){
754
+	public function set_migrating($migrating = TRUE) {
755 755
 		$this->_migrating = $migrating;
756 756
 	}
757 757
 
758 758
 	/**
759 759
 	 * Marks that we think this migration class can continue to migrate
760 760
 	 */
761
-	public function reattempt(){
761
+	public function reattempt() {
762 762
 		parent::reattempt();
763 763
 		//also, we want to reattempt any stages that were marked as borked
764
-		foreach( $this->stages() as $stage ) {
765
-			if( $stage->is_broken() ) {
764
+		foreach ($this->stages() as $stage) {
765
+			if ($stage->is_broken()) {
766 766
 				$stage->reattempt();
767 767
 			}
768 768
 		}
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 	 * @param string $timezone
34 34
 	 * @param array $date_formats
35 35
 	 */
36
-	protected function __construct( $fieldValues = NULL, $bydb = FALSE, $timezone = NULL, $date_formats = array() ) {
37
-		if ( !isset( $fieldValues[ 'ATT_full_name' ] ) ) {
38
-			$fname = isset( $fieldValues[ 'ATT_fname' ] ) ? $fieldValues[ 'ATT_fname' ] . ' ' : '';
39
-			$lname = isset( $fieldValues[ 'ATT_lname' ] ) ? $fieldValues[ 'ATT_lname' ] : '';
40
-			$fieldValues[ 'ATT_full_name' ] = $fname . $lname;
36
+	protected function __construct($fieldValues = NULL, $bydb = FALSE, $timezone = NULL, $date_formats = array()) {
37
+		if ( ! isset($fieldValues['ATT_full_name'])) {
38
+			$fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
39
+			$lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
40
+			$fieldValues['ATT_full_name'] = $fname.$lname;
41 41
 		}
42
-		if ( !isset( $fieldValues[ 'ATT_slug' ] ) ) {
42
+		if ( ! isset($fieldValues['ATT_slug'])) {
43 43
 			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
44
-			$fieldValues[ 'ATT_slug' ] = sanitize_title( $fieldValues[ 'ATT_full_name' ] );
44
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
45 45
 		}
46
-		if ( !isset( $fieldValues[ 'ATT_short_bio' ] ) && isset( $fieldValues[ 'ATT_bio' ] ) ) {
47
-			$fieldValues[ 'ATT_short_bio' ] = substr( $fieldValues[ 'ATT_bio' ], 0, 50 );
46
+		if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
47
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
48 48
 		}
49
-		parent::__construct( $fieldValues, $bydb, $timezone, $date_formats );
49
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
50 50
 	}
51 51
 
52 52
 
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 *                             		    date_format and the second value is the time format
61 61
 	 * @return EE_Attendee
62 62
 	 */
63
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
64
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
65
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
63
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
64
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
65
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
66 66
 	}
67 67
 
68 68
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 *                          		the website will be used.
74 74
 	 * @return EE_Attendee
75 75
 	 */
76
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
77
-		return new self( $props_n_values, TRUE, $timezone );
76
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
77
+		return new self($props_n_values, TRUE, $timezone);
78 78
 	}
79 79
 
80 80
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @access        public
86 86
 	 * @param string $fname
87 87
 	 */
88
-	public function set_fname( $fname = '' ) {
89
-		$this->set( 'ATT_fname', $fname );
88
+	public function set_fname($fname = '') {
89
+		$this->set('ATT_fname', $fname);
90 90
 	}
91 91
 
92 92
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @access        public
98 98
 	 * @param string $lname
99 99
 	 */
100
-	public function set_lname( $lname = '' ) {
101
-		$this->set( 'ATT_lname', $lname );
100
+	public function set_lname($lname = '') {
101
+		$this->set('ATT_lname', $lname);
102 102
 	}
103 103
 
104 104
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @access        public
110 110
 	 * @param string $address
111 111
 	 */
112
-	public function set_address( $address = '' ) {
113
-		$this->set( 'ATT_address', $address );
112
+	public function set_address($address = '') {
113
+		$this->set('ATT_address', $address);
114 114
 	}
115 115
 
116 116
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @access        public
122 122
 	 * @param        string $address2
123 123
 	 */
124
-	public function set_address2( $address2 = '' ) {
125
-		$this->set( 'ATT_address2', $address2 );
124
+	public function set_address2($address2 = '') {
125
+		$this->set('ATT_address2', $address2);
126 126
 	}
127 127
 
128 128
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @access        public
134 134
 	 * @param        string $city
135 135
 	 */
136
-	public function set_city( $city = '' ) {
137
-		$this->set( 'ATT_city', $city );
136
+	public function set_city($city = '') {
137
+		$this->set('ATT_city', $city);
138 138
 	}
139 139
 
140 140
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 * @access        public
146 146
 	 * @param        int $STA_ID
147 147
 	 */
148
-	public function set_state( $STA_ID = 0 ) {
149
-		$this->set( 'STA_ID', $STA_ID );
148
+	public function set_state($STA_ID = 0) {
149
+		$this->set('STA_ID', $STA_ID);
150 150
 	}
151 151
 
152 152
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * @access        public
158 158
 	 * @param        string $CNT_ISO
159 159
 	 */
160
-	public function set_country( $CNT_ISO = '' ) {
161
-		$this->set( 'CNT_ISO', $CNT_ISO );
160
+	public function set_country($CNT_ISO = '') {
161
+		$this->set('CNT_ISO', $CNT_ISO);
162 162
 	}
163 163
 
164 164
 
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 * @access        public
170 170
 	 * @param        string $zip
171 171
 	 */
172
-	public function set_zip( $zip = '' ) {
173
-		$this->set( 'ATT_zip', $zip );
172
+	public function set_zip($zip = '') {
173
+		$this->set('ATT_zip', $zip);
174 174
 	}
175 175
 
176 176
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @access        public
182 182
 	 * @param        string $email
183 183
 	 */
184
-	public function set_email( $email = '' ) {
185
-		$this->set( 'ATT_email', $email );
184
+	public function set_email($email = '') {
185
+		$this->set('ATT_email', $email);
186 186
 	}
187 187
 
188 188
 
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	 * @access        public
194 194
 	 * @param        string $phone
195 195
 	 */
196
-	public function set_phone( $phone = '' ) {
197
-		$this->set( 'ATT_phone', $phone );
196
+	public function set_phone($phone = '') {
197
+		$this->set('ATT_phone', $phone);
198 198
 	}
199 199
 
200 200
 
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @access        public
206 206
 	 * @param        bool $ATT_deleted
207 207
 	 */
208
-	public function set_deleted( $ATT_deleted = FALSE ) {
209
-		$this->set( 'ATT_deleted', $ATT_deleted );
208
+	public function set_deleted($ATT_deleted = FALSE) {
209
+		$this->set('ATT_deleted', $ATT_deleted);
210 210
 	}
211 211
 
212 212
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @return int
220 220
 	 */
221 221
 	public function wp_user() {
222
-		return $this->get( 'ATT_author' );
222
+		return $this->get('ATT_author');
223 223
 	}
224 224
 
225 225
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return string
231 231
 	 */
232 232
 	public function fname() {
233
-		return $this->get( 'ATT_fname' );
233
+		return $this->get('ATT_fname');
234 234
 	}
235 235
 
236 236
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	 * @param bool $apply_html_entities
251 251
 	 * @return string
252 252
 	 */
253
-	public function full_name( $apply_html_entities = FALSE ) {
254
-		$full_name = $this->fname() . ' ' . $this->lname();
255
-		return $apply_html_entities ? htmlentities( $full_name, ENT_QUOTES, 'UTF-8' ) : $full_name;
253
+	public function full_name($apply_html_entities = FALSE) {
254
+		$full_name = $this->fname().' '.$this->lname();
255
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256 256
 	}
257 257
 
258 258
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @return string
264 264
 	 */
265 265
 	public function lname() {
266
-		return $this->get( 'ATT_lname' );
266
+		return $this->get('ATT_lname');
267 267
 	}
268 268
 
269 269
 
@@ -277,26 +277,26 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function full_address_as_array() {
279 279
 		$full_address_array = array();
280
-		$initial_address_fields = array( 'ATT_address', 'ATT_address2', 'ATT_city', );
281
-		foreach ( $initial_address_fields as $address_field_name ) {
282
-			$address_fields_value = $this->get( $address_field_name );
283
-			if ( !empty( $address_fields_value ) ) {
284
-				$full_address_array[ ] = $address_fields_value;
280
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
281
+		foreach ($initial_address_fields as $address_field_name) {
282
+			$address_fields_value = $this->get($address_field_name);
283
+			if ( ! empty($address_fields_value)) {
284
+				$full_address_array[] = $address_fields_value;
285 285
 			}
286 286
 		}
287 287
 		//now handle state and country
288 288
 		$state_obj = $this->state_obj();
289
-		if ( !empty( $state_obj ) ) {
290
-			$full_address_array[ ] = $state_obj->name();
289
+		if ( ! empty($state_obj)) {
290
+			$full_address_array[] = $state_obj->name();
291 291
 		}
292 292
 		$country_obj = $this->country_obj();
293
-		if ( !empty( $country_obj ) ) {
294
-			$full_address_array[ ] = $country_obj->name();
293
+		if ( ! empty($country_obj)) {
294
+			$full_address_array[] = $country_obj->name();
295 295
 		}
296 296
 		//lastly get the xip
297 297
 		$zip_value = $this->zip();
298
-		if ( !empty( $zip_value ) ) {
299
-			$full_address_array[ ] = $zip_value;
298
+		if ( ! empty($zip_value)) {
299
+			$full_address_array[] = $zip_value;
300 300
 		}
301 301
 		return $full_address_array;
302 302
 	}
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return string
309 309
 	 */
310 310
 	public function address() {
311
-		return $this->get( 'ATT_address' );
311
+		return $this->get('ATT_address');
312 312
 	}
313 313
 
314 314
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @return string
319 319
 	 */
320 320
 	public function address2() {
321
-		return $this->get( 'ATT_address2' );
321
+		return $this->get('ATT_address2');
322 322
 	}
323 323
 
324 324
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @return string
329 329
 	 */
330 330
 	public function city() {
331
-		return $this->get( 'ATT_city' );
331
+		return $this->get('ATT_city');
332 332
 	}
333 333
 
334 334
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 * @return string
339 339
 	 */
340 340
 	public function state_ID() {
341
-		return $this->get( 'STA_ID' );
341
+		return $this->get('STA_ID');
342 342
 	}
343 343
 
344 344
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @return string
348 348
 	 */
349 349
 	public function state_abbrev() {
350
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __( 'Unknown', 'event_espresso' );
350
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __('Unknown', 'event_espresso');
351 351
 	}
352 352
 
353 353
 
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
 	 * @return EE_State
358 358
 	 */
359 359
 	public function state_obj() {
360
-		return $this->get_first_related( 'State' );
360
+		return $this->get_first_related('State');
361 361
 	}
362 362
 
363 363
 	/**
364 364
 	 * Returns the state's name, otherwise 'Unknown'
365 365
 	 * @return string
366 366
 	 */
367
-	public function state_name(){
368
-		if( $this->state_obj() ){
367
+	public function state_name() {
368
+		if ($this->state_obj()) {
369 369
 			return $this->state_obj()->name();
370
-		}else{
371
-			return __( 'Unknown', 'event_espresso' );
370
+		} else {
371
+			return __('Unknown', 'event_espresso');
372 372
 		}
373 373
 	}
374 374
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 * @return string
382 382
 	 */
383 383
 	public function state() {
384
-		if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) {
384
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
385 385
 			return $this->state_abbrev();
386 386
 		} else {
387 387
 			return $this->state_name();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @return string
396 396
 	 */
397 397
 	public function country_ID() {
398
-		return $this->get( 'CNT_ISO' );
398
+		return $this->get('CNT_ISO');
399 399
 	}
400 400
 
401 401
 
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 	 * @return EE_Country
406 406
 	 */
407 407
 	public function country_obj() {
408
-		return $this->get_first_related( 'Country' );
408
+		return $this->get_first_related('Country');
409 409
 	}
410 410
 
411 411
 	/**
412 412
 	 * Returns the country's name if known, otherwise 'Unknown'
413 413
 	 * @return string
414 414
 	 */
415
-	public function country_name(){
416
-		if( $this->country_obj() ){
415
+	public function country_name() {
416
+		if ($this->country_obj()) {
417 417
 			return $this->country_obj()->name();
418
-		}else{
419
-			return __( 'Unknown', 'event_espresso' );
418
+		} else {
419
+			return __('Unknown', 'event_espresso');
420 420
 		}
421 421
 	}
422 422
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @return string
430 430
 	 */
431 431
 	public function country() {
432
-		if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) {
432
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
433 433
 			return $this->country_ID();
434 434
 		} else {
435 435
 			return $this->country_name();
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 * @return string
444 444
 	 */
445 445
 	public function zip() {
446
-		return $this->get( 'ATT_zip' );
446
+		return $this->get('ATT_zip');
447 447
 	}
448 448
 
449 449
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 * @return string
454 454
 	 */
455 455
 	public function email() {
456
-		return $this->get( 'ATT_email' );
456
+		return $this->get('ATT_email');
457 457
 	}
458 458
 
459 459
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 	 * @return string
464 464
 	 */
465 465
 	public function phone() {
466
-		return $this->get( 'ATT_phone' );
466
+		return $this->get('ATT_phone');
467 467
 	}
468 468
 
469 469
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	 * @return        bool
474 474
 	 */
475 475
 	public function deleted() {
476
-		return $this->get( 'ATT_deleted' );
476
+		return $this->get('ATT_deleted');
477 477
 	}
478 478
 
479 479
 
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
 	 * @param array $query_params
484 484
 	 * @return EE_Registration[]
485 485
 	 */
486
-	public function get_registrations( $query_params = array() ) {
487
-		return $this->get_many_related( 'Registration', $query_params );
486
+	public function get_registrations($query_params = array()) {
487
+		return $this->get_many_related('Registration', $query_params);
488 488
 	}
489 489
 
490 490
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	 * @return EE_Registration
495 495
 	 */
496 496
 	public function get_most_recent_registration() {
497
-		return $this->get_first_related( 'Registration', array( 'order_by' => array( 'REG_date' => 'DESC' ) ) ); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
497
+		return $this->get_first_related('Registration', array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
498 498
 	}
499 499
 
500 500
 
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	 * @param int $event_id
505 505
 	 * @return EE_Registration
506 506
 	 */
507
-	public function get_most_recent_registration_for_event( $event_id ) {
508
-		return $this->get_first_related( 'Registration', array(array( 'EVT_ID' => $event_id ), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
507
+	public function get_most_recent_registration_for_event($event_id) {
508
+		return $this->get_first_related('Registration', array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))); //, '=', 'OBJECT_K' );
509 509
 	}
510 510
 
511 511
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 * @return array
516 516
 	 */
517 517
 	public function events() {
518
-		return $this->get_many_related( 'Event' );
518
+		return $this->get_many_related('Event');
519 519
 	}
520 520
 
521 521
 	/**
@@ -524,17 +524,17 @@  discard block
 block discarded – undo
524 524
 	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
525 525
 	 * @return EE_Form_Section_Proper
526 526
 	 */
527
-	public function billing_info_for_payment_method($payment_method){
527
+	public function billing_info_for_payment_method($payment_method) {
528 528
 		$pm_type = $payment_method->type_obj();
529
-		if( ! $pm_type instanceof EE_PMT_Base ){
529
+		if ( ! $pm_type instanceof EE_PMT_Base) {
530 530
 			return NULL;
531 531
 		}
532
-		$billing_info =  $this->get_post_meta( $this->get_billing_info_postmeta_name( $payment_method ), true );
533
-		if ( ! $billing_info){
532
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
533
+		if ( ! $billing_info) {
534 534
 			return NULL;
535 535
 		}
536 536
 		$billing_form = $pm_type->billing_form();
537
-		$billing_form->receive_form_submission( array( $billing_form->name() => $billing_info ), FALSE );
537
+		$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), FALSE);
538 538
 		return $billing_form;
539 539
 	}
540 540
 
@@ -544,10 +544,10 @@  discard block
 block discarded – undo
544 544
 	 * @param EE_Payment_Method $payment_method
545 545
 	 * @return string
546 546
 	 */
547
-	public function get_billing_info_postmeta_name($payment_method){
548
-		if( $payment_method->type_obj() instanceof EE_PMT_Base ){
549
-			return 'billing_info_' . $payment_method->type_obj()->system_name();
550
-		}else{
547
+	public function get_billing_info_postmeta_name($payment_method) {
548
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
549
+			return 'billing_info_'.$payment_method->type_obj()->system_name();
550
+		} else {
551 551
 			return NULL;
552 552
 		}
553 553
 	}
@@ -558,13 +558,13 @@  discard block
 block discarded – undo
558 558
 	 * @param EE_Payment_Method $payment_method
559 559
 	 * @return boolean
560 560
 	 */
561
-	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method){
562
-		if( ! $billing_form instanceof EE_Billing_Attendee_Info_Form ){
563
-			EE_Error::add_error( __( 'Cannot save billing info because there is none.', 'event_espresso' ) );
561
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) {
562
+		if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
563
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
564 564
 			return false;
565 565
 		}
566 566
 		$billing_form->clean_sensitive_data();
567
-		return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name( $payment_method ), $billing_form->input_values( true ) );
567
+		return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method), $billing_form->input_values(true));
568 568
 	}
569 569
 
570 570
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Change_Log.class.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_Change_Log extends EE_Base_Class{
28
+class EE_Change_Log extends EE_Base_Class {
29 29
 
30 30
 	/**
31 31
 	 *
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *                             		    date_format and the second value is the time format
37 37
 	 * @return EE_Attendee
38 38
 	 */
39
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
40
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
41
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
39
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
40
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
41
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
42 42
 	}
43 43
 
44 44
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 *                          		the website will be used.
50 50
 	 * @return EE_Attendee
51 51
 	 */
52
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
53
-		return new self( $props_n_values, TRUE, $timezone );
52
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
53
+		return new self($props_n_values, TRUE, $timezone);
54 54
 	}
55 55
 	/**
56 56
 	 * Gets message
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	 * Gets the model object attached to this log
148 148
 	 * @return EE_Base_Class
149 149
 	 */
150
-	function object(){
150
+	function object() {
151 151
 		$model_name_of_related_obj = $this->OBJ_type();
152 152
 		$is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
153
-		if( ! $is_model_name ){
153
+		if ( ! $is_model_name) {
154 154
 			return null;
155
-		}else{
155
+		} else {
156 156
 			return $this->get_first_related($model_name_of_related_obj);
157 157
 		}
158 158
 	}
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 	 * @param boolean $save
166 166
 	 * @return boolean if $save=true, NULL is $save=false
167 167
 	 */
168
-	function set_object($object, $save = TRUE ) {
169
-		if($object instanceof EE_Base_Class){
168
+	function set_object($object, $save = TRUE) {
169
+		if ($object instanceof EE_Base_Class) {
170 170
 			$this->set_OBJ_type($object->get_model()->get_this_model_name());
171 171
 			$this->set_OBJ_ID($object->ID());
172
-		}else{
172
+		} else {
173 173
 			$this->set_OBJ_type(NULL);
174 174
 			$this->set_OBJ_ID(NULL);
175 175
 		}
176
-		if($save){
176
+		if ($save) {
177 177
 			return $this->save();
178
-		}else{
178
+		} else {
179 179
 			return NULL;
180 180
 		}
181 181
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Checkin.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3 3
 /**
4 4
  * Event Espresso
5 5
  *
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @subpackage		includes/classes/EE_Checkin.class.php
24 24
  * @author				Darren Ethier
25 25
  */
26
-class EE_Checkin extends EE_Base_Class{
26
+class EE_Checkin extends EE_Base_Class {
27 27
 
28 28
 	/**
29 29
 	 *
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	 *                             		    date_format and the second value is the time format
35 35
 	 * @return EE_Checkin
36 36
 	 */
37
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
38
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
39
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
37
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
38
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
39
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
40 40
 	}
41 41
 
42 42
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 *                          		the website will be used.
48 48
 	 * @return EE_Checkin
49 49
 	 */
50
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
51
-		return new self( $props_n_values, TRUE, $timezone );
50
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
51
+		return new self($props_n_values, TRUE, $timezone);
52 52
 	}
53 53
 
54 54
 
Please login to merge, or discard this patch.
core/db_classes/EE_Currency.class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_Currency extends EE_Base_Class{
28
+class EE_Currency extends EE_Base_Class {
29 29
 
30 30
 		/** Currency COde @var CUR_code*/ protected $_CUR_code = NULL;
31 31
 		/** Currency Name Singular @var CUR_single*/ protected $_CUR_single = NULL;
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 *                             		    date_format and the second value is the time format
44 44
 	 * @return EE_Attendee
45 45
 	 */
46
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
47
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
48
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
46
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
47
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
48
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
49 49
 	}
50 50
 
51 51
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 *                          		the website will be used.
57 57
 	 * @return EE_Attendee
58 58
 	 */
59
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
60
-		return new self( $props_n_values, TRUE, $timezone );
59
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
60
+		return new self($props_n_values, TRUE, $timezone);
61 61
 	}
62 62
 	/**
63 63
 	 * Gets code
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * Gets a prettier name
160 160
 	 * @return string
161 161
 	 */
162
-	function name(){
163
-		return sprintf(__("%s (%s)", "event_espresso"),$this->code(),$this->plural_name());
162
+	function name() {
163
+		return sprintf(__("%s (%s)", "event_espresso"), $this->code(), $this->plural_name());
164 164
 	}
165 165
 
166 166
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Currency_Payment_Method.class.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * ------------------------------------------------------------------------
28 28
  */
29
-class EE_Currency_Payment_Method extends EE_Base_Class{
29
+class EE_Currency_Payment_Method extends EE_Base_Class {
30 30
 
31 31
 	/** Currency to Payment Method Link ID @var CPM_ID*/
32 32
 	protected $_CPM_ID = NULL;
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 *                             		    date_format and the second value is the time format
49 49
 	 * @return EE_Attendee
50 50
 	 */
51
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
52
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
53
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
51
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
52
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
53
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
54 54
 	}
55 55
 
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 *                          		the website will be used.
62 62
 	 * @return EE_Attendee
63 63
 	 */
64
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
65
-		return new self( $props_n_values, TRUE, $timezone );
64
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
65
+		return new self($props_n_values, TRUE, $timezone);
66 66
 	}
67 67
 
68 68
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Datetime.class.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 *                             		    date_format and the second value is the time format
75 75
 	 * @return EE_Datetime
76 76
 	 */
77
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
78
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
79
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
77
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
78
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
79
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
80 80
 	}
81 81
 
82 82
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *                          		the website will be used.
88 88
 	 * @return EE_Datetime
89 89
 	 */
90
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
91
-		return new self( $props_n_values, TRUE, $timezone );
90
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
91
+		return new self($props_n_values, TRUE, $timezone);
92 92
 	}
93 93
 
94 94
 
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	/**
97 97
 	 * @param $name
98 98
 	 */
99
-	public function set_name( $name ) {
100
-		$this->set( 'DTT_name', $name );
99
+	public function set_name($name) {
100
+		$this->set('DTT_name', $name);
101 101
 	}
102 102
 
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @param $description
107 107
 	 */
108
-	public function set_description( $description ) {
109
-		$this->set( 'DTT_description', $description );
108
+	public function set_description($description) {
109
+		$this->set('DTT_description', $description);
110 110
 	}
111 111
 
112 112
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @access        public
120 120
 	 * @param        string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
121 121
 	 */
122
-	public function set_start_date( $date ) {
123
-		$this->_set_date_for( $date, 'DTT_EVT_start' );
122
+	public function set_start_date($date) {
123
+		$this->_set_date_for($date, 'DTT_EVT_start');
124 124
 	}
125 125
 
126 126
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @access        public
134 134
 	 * @param        string $time a string representation of the event time ex:  9am  or  7:30 PM
135 135
 	 */
136
-	public function set_start_time( $time ) {
137
-		$this->_set_time_for( $time, 'DTT_EVT_start' );
136
+	public function set_start_time($time) {
137
+		$this->_set_time_for($time, 'DTT_EVT_start');
138 138
 	}
139 139
 
140 140
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 * @access        public
148 148
 	 * @param        string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
149 149
 	 */
150
-	public function set_end_date( $date ) {
151
-		$this->_set_date_for( $date, 'DTT_EVT_end' );
150
+	public function set_end_date($date) {
151
+		$this->_set_date_for($date, 'DTT_EVT_end');
152 152
 	}
153 153
 
154 154
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @access        public
162 162
 	 * @param        string $time a string representation of the event time ex:  9am  or  7:30 PM
163 163
 	 */
164
-	public function set_end_time( $time ) {
165
-		$this->_set_time_for( $time, 'DTT_EVT_end' );
164
+	public function set_end_time($time) {
165
+		$this->_set_time_for($time, 'DTT_EVT_end');
166 166
 	}
167 167
 
168 168
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @access        public
176 176
 	 * @param        int $reg_limit
177 177
 	 */
178
-	public function set_reg_limit( $reg_limit ) {
179
-		$this->set( 'DTT_reg_limit', $reg_limit );
178
+	public function set_reg_limit($reg_limit) {
179
+		$this->set('DTT_reg_limit', $reg_limit);
180 180
 	}
181 181
 
182 182
 
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 	 * @access        public
188 188
 	 * @param        int $sold
189 189
 	 */
190
-	public function set_sold( $sold ) {
190
+	public function set_sold($sold) {
191 191
 		// sold can not go below zero
192
-		$sold = max( 0, $sold );
193
-		$this->set( 'DTT_sold', $sold );
192
+		$sold = max(0, $sold);
193
+		$this->set('DTT_sold', $sold);
194 194
 	}
195 195
 
196 196
 
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * increments sold by amount passed by $qty
200 200
 	 * @param int $qty
201 201
 	 */
202
-	function increase_sold( $qty = 1 ) {
202
+	function increase_sold($qty = 1) {
203 203
 		$sold = $this->sold() + $qty;
204
-		$this->set_sold( $sold );
204
+		$this->set_sold($sold);
205 205
 	}
206 206
 
207 207
 
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * decrements (subtracts) sold amount passed by $qty
211 211
 	 * @param int $qty
212 212
 	 */
213
-	function decrease_sold( $qty = 1 ) {
213
+	function decrease_sold($qty = 1) {
214 214
 		$sold = $this->sold() - $qty;
215
-		$this->set_sold( $sold );
215
+		$this->set_sold($sold);
216 216
 	}
217 217
 
218 218
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @return string
223 223
 	 */
224 224
 	public function name() {
225
-		return $this->get( 'DTT_name' );
225
+		return $this->get('DTT_name');
226 226
 	}
227 227
 
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return string
233 233
 	 */
234 234
 	public function description() {
235
-		return $this->get( 'DTT_description' );
235
+		return $this->get('DTT_description');
236 236
 	}
237 237
 
238 238
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @return boolean          TRUE if is primary, FALSE if not.
243 243
 	 */
244 244
 	public function is_primary() {
245
-		return $this->get( 'DTT_is_primary' );
245
+		return $this->get('DTT_is_primary');
246 246
 	}
247 247
 
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return int         The order of the datetime for this event.
253 253
 	 */
254 254
 	public function order() {
255
-		return $this->get( 'DTT_order' );
255
+		return $this->get('DTT_order');
256 256
 	}
257 257
 
258 258
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return int
263 263
 	 */
264 264
 	public function parent() {
265
-		return $this->get( 'DTT_parent' );
265
+		return $this->get('DTT_parent');
266 266
 	}
267 267
 
268 268
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 	 * @param    bool   $echo         - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats)
279 279
 	 * @return    string|bool|void  string on success, FALSE on fail
280 280
 	 */
281
-	private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) {
281
+	private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) {
282 282
 		$field_name = "DTT_EVT_{$start_or_end}";
283
-		$dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo );
284
-		if ( ! $echo ) {
283
+		$dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo);
284
+		if ( ! $echo) {
285 285
 			return $dtt;
286 286
 		}
287 287
 		return '';
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
298 298
 	 * @return        mixed        string on success, FALSE on fail
299 299
 	 */
300
-	public function start_date( $dt_frmt = NULL ) {
301
-		return $this->_show_datetime( 'D', 'start', $dt_frmt );
300
+	public function start_date($dt_frmt = NULL) {
301
+		return $this->_show_datetime('D', 'start', $dt_frmt);
302 302
 	}
303 303
 
304 304
 
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 	 * Echoes start_date()
308 308
 	 * @param string $dt_frmt
309 309
 	 */
310
-	public function e_start_date( $dt_frmt = NULL ) {
311
-		$this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE );
310
+	public function e_start_date($dt_frmt = NULL) {
311
+		$this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE);
312 312
 	}
313 313
 
314 314
 
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
322 322
 	 * @return        mixed        string on success, FALSE on fail
323 323
 	 */
324
-	public function end_date( $dt_frmt = NULL ) {
325
-		return $this->_show_datetime( 'D', 'end', $dt_frmt );
324
+	public function end_date($dt_frmt = NULL) {
325
+		return $this->_show_datetime('D', 'end', $dt_frmt);
326 326
 	}
327 327
 
328 328
 
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * Echoes the end date. See end_date()
332 332
 	 * @param string $dt_frmt
333 333
 	 */
334
-	public function e_end_date( $dt_frmt = NULL ) {
335
-		$this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE );
334
+	public function e_end_date($dt_frmt = NULL) {
335
+		$this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE);
336 336
 	}
337 337
 
338 338
 
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 	 * @param        string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
346 346
 	 * @return        mixed        string on success, FALSE on fail
347 347
 	 */
348
-	public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
349
-		$dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt;
350
-		$start = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) );
351
-		$end = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) );
352
-		return $start != $end ? $start . $conjunction . $end : $start;
348
+	public function date_range($dt_frmt = NULL, $conjunction = ' - ') {
349
+		$dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
350
+		$start = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt));
351
+		$end = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt));
352
+		return $start != $end ? $start.$conjunction.$end : $start;
353 353
 	}
354 354
 
355 355
 
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @param null   $dt_frmt
359 359
 	 * @param string $conjunction
360 360
 	 */
361
-	public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
362
-		echo $this->date_range( $dt_frmt, $conjunction );
361
+	public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') {
362
+		echo $this->date_range($dt_frmt, $conjunction);
363 363
 	}
364 364
 
365 365
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
372 372
 	 * @return        mixed        string on success, FALSE on fail
373 373
 	 */
374
-	public function start_time( $tm_format = NULL ) {
375
-		return $this->_show_datetime( 'T', 'start', NULL, $tm_format );
374
+	public function start_time($tm_format = NULL) {
375
+		return $this->_show_datetime('T', 'start', NULL, $tm_format);
376 376
 	}
377 377
 
378 378
 
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	/**
381 381
 	 * @param null $tm_format
382 382
 	 */
383
-	public function e_start_time( $tm_format = NULL ) {
384
-		$this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE );
383
+	public function e_start_time($tm_format = NULL) {
384
+		$this->_show_datetime('T', 'start', NULL, $tm_format, TRUE);
385 385
 	}
386 386
 
387 387
 
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
394 394
 	 * @return        mixed        string on success, FALSE on fail
395 395
 	 */
396
-	public function end_time( $tm_format = NULL ) {
397
-		return $this->_show_datetime( 'T', 'end', NULL, $tm_format );
396
+	public function end_time($tm_format = NULL) {
397
+		return $this->_show_datetime('T', 'end', NULL, $tm_format);
398 398
 	}
399 399
 
400 400
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 	/**
403 403
 	 * @param null $tm_format
404 404
 	 */
405
-	public function e_end_time( $tm_format = NULL ) {
406
-		$this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE );
405
+	public function e_end_time($tm_format = NULL) {
406
+		$this->_show_datetime('T', 'end', NULL, $tm_format, TRUE);
407 407
 	}
408 408
 
409 409
 
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 	 * @param        string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
417 417
 	 * @return        mixed        string on success, FALSE on fail
418 418
 	 */
419
-	public function time_range( $tm_format = NULL, $conjunction = ' - ' ) {
420
-		$tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt;
419
+	public function time_range($tm_format = NULL, $conjunction = ' - ') {
420
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
421 421
 
422
-		$start = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) );
423
-		$end = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_end',  $tm_format ) );
424
-		return $start != $end ? $start . $conjunction . $end : $start;
422
+		$start = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_start', $tm_format));
423
+		$end = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_end', $tm_format));
424
+		return $start != $end ? $start.$conjunction.$end : $start;
425 425
 	}
426 426
 
427 427
 
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	 * @param null   $tm_format
431 431
 	 * @param string $conjunction
432 432
 	 */
433
-	public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) {
434
-		echo $this->time_range( $tm_format, $conjunction );
433
+	public function e_time_range($tm_format = NULL, $conjunction = ' - ') {
434
+		echo $this->time_range($tm_format, $conjunction);
435 435
 	}
436 436
 
437 437
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	 * @param 	string 	$tm_format - string representation of time format defaults to 'g:i a'
445 445
 	 * @return 	mixed 	string on success, FALSE on fail
446 446
 	 */
447
-	public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) {
448
-		return $this->_show_datetime( '', 'start', $dt_format, $tm_format );
447
+	public function start_date_and_time($dt_format = NULL, $tm_format = NULL) {
448
+		return $this->_show_datetime('', 'start', $dt_format, $tm_format);
449 449
 	}
450 450
 
451 451
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @param null $dt_frmt
455 455
 	 * @param null $tm_format
456 456
 	 */
457
-	public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) {
458
-		$this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE );
457
+	public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) {
458
+		$this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE);
459 459
 	}
460 460
 
461 461
 
@@ -469,11 +469,11 @@  discard block
 block discarded – undo
469 469
 	 * @param bool   $round_up
470 470
 	 * @return float|int|mixed
471 471
 	 */
472
-	public function length( $units = 'seconds', $round_up = FALSE ) {
473
-		$start = $this->get_raw( 'DTT_EVT_start' );
474
-		$end = $this->get_raw( 'DTT_EVT_end' );
472
+	public function length($units = 'seconds', $round_up = FALSE) {
473
+		$start = $this->get_raw('DTT_EVT_start');
474
+		$end = $this->get_raw('DTT_EVT_end');
475 475
 		$length_in_units = $end - $start;
476
-		switch ( $units ) {
476
+		switch ($units) {
477 477
 			//NOTE: We purposefully don't use "break;" in order to chain the divisions
478 478
 			/** @noinspection PhpMissingBreakStatementInspection */
479 479
 			case 'days':
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 				$length_in_units /= 60;
487 487
 			case 'seconds':
488 488
 			default:
489
-				$length_in_units = ceil( $length_in_units );
489
+				$length_in_units = ceil($length_in_units);
490 490
 		}
491
-		if ( $round_up ) {
492
-			$length_in_units = max( $length_in_units, 1 );
491
+		if ($round_up) {
492
+			$length_in_units = max($length_in_units, 1);
493 493
 		}
494 494
 		return $length_in_units;
495 495
 	}
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 	 * @param bool | string 	$tm_format - string representation of time format defaults to 'g:i a'
505 505
 	 * @return 	mixed        		string on success, FALSE on fail
506 506
 	 */
507
-	public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
508
-		return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format );
507
+	public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
508
+		return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
509 509
 	}
510 510
 
511 511
 
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 	 * @param bool $dt_frmt
515 515
 	 * @param bool $tm_format
516 516
 	 */
517
-	public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
518
-		$this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE );
517
+	public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
518
+		$this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE);
519 519
 	}
520 520
 
521 521
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 * @return        int
528 528
 	 */
529 529
 	public function start() {
530
-		return $this->get_raw( 'DTT_EVT_start' );
530
+		return $this->get_raw('DTT_EVT_start');
531 531
 	}
532 532
 
533 533
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 * @return        int
540 540
 	 */
541 541
 	public function end() {
542
-		return $this->get_raw( 'DTT_EVT_end' );
542
+		return $this->get_raw('DTT_EVT_end');
543 543
 	}
544 544
 
545 545
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 	 * @return        mixed        int on success, FALSE on fail
552 552
 	 */
553 553
 	public function reg_limit() {
554
-		return $this->get_raw( 'DTT_reg_limit' );
554
+		return $this->get_raw('DTT_reg_limit');
555 555
 	}
556 556
 
557 557
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @return        mixed        int on success, FALSE on fail
564 564
 	 */
565 565
 	public function sold() {
566
-		return $this->get_raw( 'DTT_sold' );
566
+		return $this->get_raw('DTT_sold');
567 567
 	}
568 568
 
569 569
 
@@ -592,15 +592,15 @@  discard block
 block discarded – undo
592 592
 	 * 																	the spaces remaining for this particular datetime, hence the flag.
593 593
 	 * @return 	int
594 594
 	 */
595
-	public function spaces_remaining( $consider_tickets = FALSE ) {
595
+	public function spaces_remaining($consider_tickets = FALSE) {
596 596
 		// tickets remaining available for purchase
597 597
 		//no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
598 598
 		$dtt_remaining = $this->reg_limit() - $this->sold();
599
-		if ( ! $consider_tickets ) {
599
+		if ( ! $consider_tickets) {
600 600
 			return $dtt_remaining;
601 601
 		}
602 602
 		$tickets_remaining = $this->tickets_remaining();
603
-		return min( $dtt_remaining, $tickets_remaining );
603
+		return min($dtt_remaining, $tickets_remaining);
604 604
 	}
605 605
 
606 606
 
@@ -611,19 +611,19 @@  discard block
 block discarded – undo
611 611
 	 * @param array $query_params like EEM_Base::get_all's
612 612
 	 * @return int
613 613
 	 */
614
-	public function tickets_remaining( $query_params = array() ) {
614
+	public function tickets_remaining($query_params = array()) {
615 615
 		$sum = 0;
616
-		$tickets = $this->tickets( $query_params );
617
-		if ( ! empty( $tickets ) ) {
618
-			foreach ( $tickets as $ticket ) {
619
-				if ( $ticket instanceof EE_Ticket ) {
616
+		$tickets = $this->tickets($query_params);
617
+		if ( ! empty($tickets)) {
618
+			foreach ($tickets as $ticket) {
619
+				if ($ticket instanceof EE_Ticket) {
620 620
 					// get the actual amount of tickets that can be sold
621
-					$qty = $ticket->qty( 'saleable' );
622
-					if ( $qty === EE_INF ) {
621
+					$qty = $ticket->qty('saleable');
622
+					if ($qty === EE_INF) {
623 623
 						return EE_INF;
624 624
 					}
625 625
 					// no negative ticket quantities plz
626
-					if ( $qty > 0 ) {
626
+					if ($qty > 0) {
627 627
 						$sum += $qty;
628 628
 					}
629 629
 				}
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @param array $query_params like EEM_Base::get_all's
641 641
 	 * @return int
642 642
 	 */
643
-	public function sum_tickets_initially_available( $query_params = array() ) {
644
-		return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' );
643
+	public function sum_tickets_initially_available($query_params = array()) {
644
+		return $this->sum_related('Ticket', $query_params, 'TKT_qty');
645 645
 	}
646 646
 
647 647
 
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 * @return int
654 654
 	 */
655 655
 	public function total_tickets_available_at_this_datetime() {
656
-		return $this->spaces_remaining( true );
656
+		return $this->spaces_remaining(true);
657 657
 	}
658 658
 
659 659
 
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	 * @return boolean
665 665
 	 */
666 666
 	public function is_upcoming() {
667
-		return ( $this->get_raw( 'DTT_EVT_start' ) > time() );
667
+		return ($this->get_raw('DTT_EVT_start') > time());
668 668
 	}
669 669
 
670 670
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 	 * @return boolean
675 675
 	 */
676 676
 	public function is_active() {
677
-		return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() );
677
+		return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
678 678
 	}
679 679
 
680 680
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 * @return boolean
685 685
 	 */
686 686
 	public function is_expired() {
687
-		return ( $this->get_raw( 'DTT_EVT_end' ) < time() );
687
+		return ($this->get_raw('DTT_EVT_end') < time());
688 688
 	}
689 689
 
690 690
 
@@ -695,16 +695,16 @@  discard block
 block discarded – undo
695 695
 	 */
696 696
 	public function get_active_status() {
697 697
 		$total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
698
-		if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) {
698
+		if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) {
699 699
 			return EE_Datetime::sold_out;
700 700
 		}
701
-		if ( $this->is_expired() ) {
701
+		if ($this->is_expired()) {
702 702
 			return EE_Datetime::expired;
703 703
 		}
704
-		if ( $this->is_upcoming() ) {
704
+		if ($this->is_upcoming()) {
705 705
 			return EE_Datetime::upcoming;
706 706
 		}
707
-		if ( $this->is_active() ) {
707
+		if ($this->is_active()) {
708 708
 			return EE_Datetime::active;
709 709
 		}
710 710
 		return NULL;
@@ -718,24 +718,24 @@  discard block
 block discarded – undo
718 718
 	 * @param  boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
719 719
 	 * @return string
720 720
 	 */
721
-	public function get_dtt_display_name( $use_dtt_name = FALSE ) {
722
-		if ( $use_dtt_name ) {
721
+	public function get_dtt_display_name($use_dtt_name = FALSE) {
722
+		if ($use_dtt_name) {
723 723
 			$dtt_name = $this->name();
724
-			if ( !empty( $dtt_name ) ) {
724
+			if ( ! empty($dtt_name)) {
725 725
 				return $dtt_name;
726 726
 			}
727 727
 		}
728 728
 		//first condition is to see if the months are different
729
-		if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) {
730
-			$display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' );
729
+		if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) {
730
+			$display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a');
731 731
 			//next condition is if its the same month but different day
732 732
 		}
733 733
 		else {
734
-			if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) {
735
-				$display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' );
734
+			if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) {
735
+				$display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y');
736 736
 			}
737 737
 			else {
738
-				$display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' );
738
+				$display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a');
739 739
 			}
740 740
 		}
741 741
 		return $display_date;
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 *@param array $query_params see EEM_Base::get_all()
750 750
 	 * @return EE_Ticket[]
751 751
 	 */
752
-	public function tickets( $query_params = array() ) {
753
-		return $this->get_many_related( 'Ticket', $query_params );
752
+	public function tickets($query_params = array()) {
753
+		return $this->get_many_related('Ticket', $query_params);
754 754
 	}
755 755
 
756 756
 
@@ -760,21 +760,21 @@  discard block
 block discarded – undo
760 760
 	 * @param array $query_params like EEM_Base::get_all's
761 761
 	 * @return EE_Ticket[]
762 762
 	 */
763
-	public function ticket_types_available_for_purchase( $query_params = array() ) {
763
+	public function ticket_types_available_for_purchase($query_params = array()) {
764 764
 		// first check if datetime is valid
765
-		if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) {
765
+		if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) {
766 766
 			return array();
767 767
 		}
768
-		if ( empty( $query_params ) ) {
768
+		if (empty($query_params)) {
769 769
 			$query_params = array(
770 770
 				array(
771
-					'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ),
772
-					'TKT_end_date'   => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ),
771
+					'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')),
772
+					'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
773 773
 					'TKT_deleted'    => false
774 774
 				)
775 775
 			);
776 776
 		}
777
-		return $this->tickets( $query_params );
777
+		return $this->tickets($query_params);
778 778
 	}
779 779
 
780 780
 
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 	 * @return EE_Event
785 785
 	 */
786 786
 	public function event() {
787
-		return $this->get_first_related( 'Event' );
787
+		return $this->get_first_related('Event');
788 788
 	}
789 789
 
790 790
 
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 	 */
797 797
 	public function update_sold() {
798 798
 		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
799
-			array( array(
799
+			array(array(
800 800
 				'STS_ID' 					=> EEM_Registration::status_id_approved,
801 801
 				'REG_deleted' 				=> 0,
802 802
 				'Ticket.Datetime.DTT_ID' 	=> $this->ID(),
803
-			) )
803
+			))
804 804
 		);
805
-		$this->set( 'DTT_sold', $count_regs_for_this_datetime );
805
+		$this->set('DTT_sold', $count_regs_for_this_datetime);
806 806
 		$this->save();
807 807
 		return $count_regs_for_this_datetime;
808 808
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Datetime_Ticket.class.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *                             		    date_format and the second value is the time format
36 36
 	 * @return EE_Attendee
37 37
 	 */
38
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
39
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
40
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
38
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
39
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
40
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
41 41
 	}
42 42
 
43 43
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *                          		the website will be used.
49 49
 	 * @return EE_Attendee
50 50
 	 */
51
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
52
-		return new self( $props_n_values, TRUE, $timezone );
51
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
52
+		return new self($props_n_values, TRUE, $timezone);
53 53
 	}
54 54
 } //end EE_Datetime_Ticket class
Please login to merge, or discard this patch.