Completed
Branch FET-10486-add-timestamp-checki... (786b14)
by
unknown
79:06 queued 65:28
created
services/commands/registration/CopyRegistrationPaymentsCommandHandler.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\commands\CommandInterface;
8 8
 
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -26,40 +26,40 @@  discard block
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    /**
30
-     * @var CopyRegistrationService $copy_registration_service
31
-     */
32
-    private $copy_registration_service;
33
-
34
-
35
-
36
-    /**
37
-     * Command constructor
38
-     *
39
-     * @param CopyRegistrationService $copy_registration_service
40
-     */
41
-    public function __construct(CopyRegistrationService $copy_registration_service)
42
-    {
43
-        $this->copy_registration_service = $copy_registration_service;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * @param \EventEspresso\core\services\commands\CommandInterface $command
50
-     * @return boolean
51
-     */
52
-    public function handle(CommandInterface $command)
53
-    {
54
-        /** @var CopyRegistrationPaymentsCommand $command */
55
-        if ( ! $command instanceof CopyRegistrationPaymentsCommand) {
56
-            throw new InvalidEntityException(get_class($command), 'CopyRegistrationPaymentsCommand');
57
-        }
58
-        return $this->copy_registration_service->copyPaymentDetails(
59
-            $command->targetRegistration(),
60
-            $command->registrationToCopy()
61
-        );
62
-    }
29
+	/**
30
+	 * @var CopyRegistrationService $copy_registration_service
31
+	 */
32
+	private $copy_registration_service;
33
+
34
+
35
+
36
+	/**
37
+	 * Command constructor
38
+	 *
39
+	 * @param CopyRegistrationService $copy_registration_service
40
+	 */
41
+	public function __construct(CopyRegistrationService $copy_registration_service)
42
+	{
43
+		$this->copy_registration_service = $copy_registration_service;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * @param \EventEspresso\core\services\commands\CommandInterface $command
50
+	 * @return boolean
51
+	 */
52
+	public function handle(CommandInterface $command)
53
+	{
54
+		/** @var CopyRegistrationPaymentsCommand $command */
55
+		if ( ! $command instanceof CopyRegistrationPaymentsCommand) {
56
+			throw new InvalidEntityException(get_class($command), 'CopyRegistrationPaymentsCommand');
57
+		}
58
+		return $this->copy_registration_service->copyPaymentDetails(
59
+			$command->targetRegistration(),
60
+			$command->registrationToCopy()
61
+		);
62
+	}
63 63
 
64 64
 
65 65
 
Please login to merge, or discard this patch.
registration/UpdateRegistrationAndTransactionAfterChangeCommandHandler.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\commands\CommandHandler;
7 7
 use EventEspresso\core\services\commands\CommandInterface;
8 8
 
9
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
10
-	exit( 'No direct script access allowed' );
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 	 * @param \EventEspresso\core\services\commands\CommandInterface $command
49 49
 	 * @return boolean
50 50
 	 */
51
-	public function handle( CommandInterface $command )
51
+	public function handle(CommandInterface $command)
52 52
 	{
53 53
 		/** @var UpdateRegistrationAndTransactionAfterChangeCommand $command */
54
-		if ( ! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand ) {
54
+		if ( ! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand) {
55 55
 			throw new InvalidEntityException(
56 56
 				get_class($command),
57 57
 				'UpdateRegistrationAndTransactionAfterChangeCommand'
Please login to merge, or discard this patch.
core/exceptions/ExceptionLogger.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\exceptions;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param \Exception $exception
26 26
 	 */
27
-	public function __construct( \Exception $exception ) {
28
-		$this->log( $exception );
27
+	public function __construct(\Exception $exception) {
28
+		$this->log($exception);
29 29
 	}
30 30
 
31 31
 
@@ -36,22 +36,22 @@  discard block
 block discarded – undo
36 36
 	 * @param \Exception $exception
37 37
 	 * @param int        $time
38 38
 	 */
39
-	public function log( \Exception $exception, $time = 0 ) {
40
-		if ( ! $time ) {
39
+	public function log(\Exception $exception, $time = 0) {
40
+		if ( ! $time) {
41 41
 			$time = time();
42 42
 		}
43 43
 		$exception_log = '----------------------------------------------------------------------------------------';
44 44
 		$exception_log .= PHP_EOL;
45
-		$exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . ']  Exception Details' . PHP_EOL;
46
-		$exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL;
47
-		$exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL;
48
-		$exception_log .= 'File: ' . $exception->getFile() . PHP_EOL;
49
-		$exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL;
50
-		$exception_log .= 'Stack trace: ' . PHP_EOL;
51
-		$exception_log .= $exception->getTraceAsString() . PHP_EOL;
45
+		$exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
46
+		$exception_log .= 'Message: '.$exception->getMessage().PHP_EOL;
47
+		$exception_log .= 'Code: '.$exception->getCode().PHP_EOL;
48
+		$exception_log .= 'File: '.$exception->getFile().PHP_EOL;
49
+		$exception_log .= 'Line No: '.$exception->getLine().PHP_EOL;
50
+		$exception_log .= 'Stack trace: '.PHP_EOL;
51
+		$exception_log .= $exception->getTraceAsString().PHP_EOL;
52 52
 		$exception_log .= '----------------------------------------------------------------------------------------';
53
-		$exception_log .=  PHP_EOL;
54
-		error_log( $exception_log );
53
+		$exception_log .= PHP_EOL;
54
+		error_log($exception_log);
55 55
 	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 3 patches
Doc Comments   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
 
146 146
 	/**
147
-	 * @return null
147
+	 * @return EE_Line_Item_Display
148 148
 	 */
149 149
 	public function line_item_display() {
150 150
 		return $this->line_item_display;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
 
155 155
 	/**
156
-	 * @param null $line_item_display
156
+	 * @param EE_Line_Item_Display $line_item_display
157 157
 	 */
158 158
 	public function set_line_item_display( $line_item_display ) {
159 159
 		$this->line_item_display = $line_item_display;
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 	 *    _apply_registration_payments_to_amount_owing
840 840
 	 *
841 841
 	 * @access protected
842
-	 * @param array $registrations
842
+	 * @param EE_Base_Class[] $registrations
843 843
 	 */
844 844
 	protected function _apply_registration_payments_to_amount_owing( array $registrations ) {
845 845
 		$payments = array();
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 	 * get_billing_form_html_for_payment_method
1113 1113
 	 *
1114 1114
 	 * @access public
1115
-	 * @return string
1115
+	 * @return boolean
1116 1116
 	 * @throws \EE_Error
1117 1117
 	 */
1118 1118
 	public function get_billing_form_html_for_payment_method() {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 	 *
1177 1177
 	 * @access private
1178 1178
 	 * @param EE_Payment_Method $payment_method
1179
-	 * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML
1179
+	 * @return EE_Billing_Info_Form
1180 1180
 	 * @throws \EE_Error
1181 1181
 	 */
1182 1182
 	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	 * switch_payment_method
1281 1281
 	 *
1282 1282
 	 * @access public
1283
-	 * @return string
1283
+	 * @return boolean
1284 1284
 	 * @throws \EE_Error
1285 1285
 	 */
1286 1286
 	public function switch_payment_method() {
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 	/**
1488 1488
 	 * process_reg_step
1489 1489
 	 *
1490
-	 * @return boolean
1490
+	 * @return null|boolean
1491 1491
 	 * @throws \EE_Error
1492 1492
 	 */
1493 1493
 	public function process_reg_step() {
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 	 *    update_reg_step
1614 1614
 	 *    this is the final step after a user  revisits the site to retry a payment
1615 1615
 	 *
1616
-	 * @return boolean
1616
+	 * @return null|boolean
1617 1617
 	 * @throws \EE_Error
1618 1618
 	 */
1619 1619
 	public function update_reg_step() {
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 	 *
1982 1982
 	 * @access    private
1983 1983
 	 * @type    EE_Payment_Method $payment_method
1984
-	 * @return    mixed    EE_Payment | boolean
1984
+	 * @return    EE_Payment|null    EE_Payment | boolean
1985 1985
 	 * @throws \EE_Error
1986 1986
 	 */
1987 1987
 	private function _attempt_payment( EE_Payment_Method $payment_method ) {
@@ -2112,7 +2112,7 @@  discard block
 block discarded – undo
2112 2112
 	 * _post_payment_processing
2113 2113
 	 *
2114 2114
 	 * @access private
2115
-	 * @param EE_Payment|bool $payment
2115
+	 * @param EE_Payment $payment
2116 2116
 	 * @return bool
2117 2117
 	 * @throws \EE_Error
2118 2118
 	 */
@@ -2301,7 +2301,7 @@  discard block
 block discarded – undo
2301 2301
 	 *        or present the payment options again
2302 2302
 	 *
2303 2303
 	 * @access private
2304
-	 * @return EE_Payment | FALSE
2304
+	 * @return boolean | FALSE
2305 2305
 	 * @throws \EE_Error
2306 2306
 	 */
2307 2307
 	public function process_gateway_response() {
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 	 * _redirect_wayward_request
2435 2435
 	 *
2436 2436
 	 * @access private
2437
-	 * @param \EE_Registration|null $primary_registrant
2438
-	 * @return bool
2437
+	 * @param EE_Registration $primary_registrant
2438
+	 * @return false|null
2439 2439
 	 * @throws \EE_Error
2440 2440
 	 */
2441 2441
 	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
Please login to merge, or discard this patch.
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -286,41 +286,41 @@  discard block
 block discarded – undo
286 286
 			$this->checkout->revisit
287 287
 		);
288 288
 		foreach ( $registrations as $REG_ID => $registration ) {
289
-            /** @var $registration EE_Registration */
290
-            // has this registration lost it's space ?
289
+			/** @var $registration EE_Registration */
290
+			// has this registration lost it's space ?
291 291
 			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
292 292
 				$insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
293 293
 				continue;
294 294
 			}
295
-            // event requires admin approval
296
-            if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
297
-                // add event to list of events with pre-approval reg status
298
-                $registrations_requiring_pre_approval[$REG_ID] = $registration;
299
-                do_action(
300
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
301
-                    $registration->event(),
302
-                    $this
303
-                );
304
-                continue;
305
-            }
306
-            if (
295
+			// event requires admin approval
296
+			if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
297
+				// add event to list of events with pre-approval reg status
298
+				$registrations_requiring_pre_approval[$REG_ID] = $registration;
299
+				do_action(
300
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
301
+					$registration->event(),
302
+					$this
303
+				);
304
+				continue;
305
+			}
306
+			if (
307 307
 				// returning registrant
308 308
 				$this->checkout->revisit
309 309
 				// anything other than Approved
310 310
 				&& $registration->status_ID() !== EEM_Registration::status_id_approved
311
-                && (
312
-                    $registration->event()->is_sold_out()
313
-                    || $registration->event()->is_sold_out( true )
314
-                )
315
-            ) {
316
-                // add event to list of events that are sold out
317
-                $sold_out_events[ $registration->event()->ID() ] = $registration->event();
318
-                do_action(
319
-                    'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
320
-                    $registration->event(),
321
-                    $this
322
-                );
323
-                continue;
311
+				&& (
312
+					$registration->event()->is_sold_out()
313
+					|| $registration->event()->is_sold_out( true )
314
+				)
315
+			) {
316
+				// add event to list of events that are sold out
317
+				$sold_out_events[ $registration->event()->ID() ] = $registration->event();
318
+				do_action(
319
+					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
320
+					$registration->event(),
321
+					$this
322
+				);
323
+				continue;
324 324
 			}
325 325
 			// are they allowed to pay now and is there monies owing?
326 326
 			if ( $registration->owes_monies_and_can_pay() ) {
@@ -428,11 +428,11 @@  discard block
 block discarded – undo
428 428
 			new EE_Billable_Line_Item_Filter(
429 429
 				EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
430 430
 					EE_Registry::instance()->SSN->checkout()->transaction->registrations(
431
-                        EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
432
-                    )
431
+						EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
432
+					)
433 433
 				)
434 434
 			)
435
-        );
435
+		);
436 436
 		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
437 437
 		return $line_item_filter_collection;
438 438
 	}
@@ -481,38 +481,38 @@  discard block
 block discarded – undo
481 481
 	 * @throws \EE_Error
482 482
 	 */
483 483
 	public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) {
484
-        // registrations per event
484
+		// registrations per event
485 485
 		$event_reg_count = array();
486 486
 		// spaces left per event
487 487
 		$event_spaces_remaining = array();
488
-        // tickets left sorted by ID
489
-        $tickets_remaining = array();
490
-        // registrations that have lost their space
488
+		// tickets left sorted by ID
489
+		$tickets_remaining = array();
490
+		// registrations that have lost their space
491 491
 		$ejected_registrations = array();
492 492
 		foreach ( $registrations as $REG_ID => $registration ) {
493 493
 			if ( $registration->status_ID() === EEM_Registration::status_id_approved ) {
494 494
 				continue;
495 495
 			}
496 496
 			$EVT_ID = $registration->event_ID();
497
-            $ticket = $registration->ticket();
498
-            if ( ! isset($tickets_remaining[$ticket->ID()])) {
499
-                $tickets_remaining[$ticket->ID()] = $ticket->remaining();
500
-            }
501
-            if ($tickets_remaining[$ticket->ID()] > 0) {
502
-                if ( ! isset($event_reg_count[$EVT_ID])) {
503
-                    $event_reg_count[$EVT_ID] = 0;
504
-                }
505
-                $event_reg_count[$EVT_ID]++;
506
-                if ( ! isset($event_spaces_remaining[$EVT_ID])) {
507
-                    $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale();
508
-                }
509
-            }
497
+			$ticket = $registration->ticket();
498
+			if ( ! isset($tickets_remaining[$ticket->ID()])) {
499
+				$tickets_remaining[$ticket->ID()] = $ticket->remaining();
500
+			}
501
+			if ($tickets_remaining[$ticket->ID()] > 0) {
502
+				if ( ! isset($event_reg_count[$EVT_ID])) {
503
+					$event_reg_count[$EVT_ID] = 0;
504
+				}
505
+				$event_reg_count[$EVT_ID]++;
506
+				if ( ! isset($event_spaces_remaining[$EVT_ID])) {
507
+					$event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale();
508
+				}
509
+			}
510 510
 			if (
511 511
 				$revisit
512 512
 				&& (
513
-                    $tickets_remaining[$ticket->ID()] === 0
514
-				    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
515
-                )
513
+					$tickets_remaining[$ticket->ID()] === 0
514
+					|| $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
515
+				)
516 516
 			) {
517 517
 				$ejected_registrations[ $REG_ID ] = $registration->event();
518 518
 				if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) {
@@ -581,9 +581,9 @@  discard block
 block discarded – undo
581 581
 				'layout_strategy'		=> new EE_Template_Layout(
582 582
 					array(
583 583
 						'layout_template_file' => SPCO_REG_STEPS_PATH
584
-						                          . $this->_slug
585
-						                          . DS
586
-						                          . 'sold_out_events.template.php',
584
+												  . $this->_slug
585
+												  . DS
586
+												  . 'sold_out_events.template.php',
587 587
 						'template_args'        => apply_filters(
588 588
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
589 589
 							array(
@@ -636,9 +636,9 @@  discard block
 block discarded – undo
636 636
 				'layout_strategy' => new EE_Template_Layout(
637 637
 					array(
638 638
 						'layout_template_file' => SPCO_REG_STEPS_PATH
639
-						                          . $this->_slug
640
-						                          . DS
641
-						                          . 'sold_out_events.template.php',
639
+												  . $this->_slug
640
+												  . DS
641
+												  . 'sold_out_events.template.php',
642 642
 						'template_args'        => apply_filters(
643 643
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args',
644 644
 							array(
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
 				'layout_strategy'		=> new EE_Template_Layout(
687 687
 					array(
688 688
 						'layout_template_file' => SPCO_REG_STEPS_PATH
689
-						                          . $this->_slug
690
-						                          . DS
691
-						                          . 'events_requiring_pre_approval.template.php', // layout_template
689
+												  . $this->_slug
690
+												  . DS
691
+												  . 'events_requiring_pre_approval.template.php', // layout_template
692 692
 						'template_args'        => apply_filters(
693 693
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
694 694
 							array(
@@ -726,9 +726,9 @@  discard block
 block discarded – undo
726 726
 				'layout_strategy' 	=> new EE_Template_Layout(
727 727
 					array(
728 728
 						'layout_template_file' => SPCO_REG_STEPS_PATH
729
-						                          . $this->_slug
730
-						                          . DS
731
-						                          . 'no_payment_required.template.php', // layout_template
729
+												  . $this->_slug
730
+												  . DS
731
+												  . 'no_payment_required.template.php', // layout_template
732 732
 						'template_args'        => apply_filters(
733 733
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
734 734
 							array(
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
957 957
 				}
958 958
 				$payment_methods_billing_info[ $payment_method->slug()
959
-				                               . '-info' ] = $this->_payment_method_billing_info(
959
+											   . '-info' ] = $this->_payment_method_billing_info(
960 960
 					$payment_method
961 961
 				);
962 962
 			}
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 		// fill form with attendee info if applicable
1145 1145
 		if (
1146 1146
 			$payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
1147
-		    && $this->checkout->transaction_has_primary_registrant()
1147
+			&& $this->checkout->transaction_has_primary_registrant()
1148 1148
 		) {
1149 1149
 			$payment_method_billing_form->populate_from_attendee(
1150 1150
 				$this->checkout->transaction->primary_registration()->attendee()
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 		// and debug content
1154 1154
 		if (
1155 1155
 			$payment_method_billing_form instanceof EE_Billing_Info_Form
1156
-		    && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1156
+			&& $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1157 1157
 		) {
1158 1158
 			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1159 1159
 				$payment_method_billing_form
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 		}
1329 1329
 		// and debug content
1330 1330
 		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form
1331
-		     && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1331
+			 && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1332 1332
 		) {
1333 1333
 			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
1334 1334
 				$this->checkout->billing_form
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
 		}
1499 1499
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1500 1500
 		if ( ! empty( $attendee_data['ATT_fname'] )
1501
-		     && ! empty( $attendee_data['ATT_lname'] )
1502
-		     && ! empty( $attendee_data['ATT_email'] )
1501
+			 && ! empty( $attendee_data['ATT_lname'] )
1502
+			 && ! empty( $attendee_data['ATT_email'] )
1503 1503
 		) {
1504 1504
 			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1505 1505
 				array(
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 			$payment_status = $payment->status();
1747 1747
 			if (
1748 1748
 				$payment_status === EEM_Payment::status_id_approved
1749
-			    || $payment_status === EEM_Payment::status_id_pending
1749
+				|| $payment_status === EEM_Payment::status_id_pending
1750 1750
 			) {
1751 1751
 				return true;
1752 1752
 			} else {
@@ -1972,8 +1972,8 @@  discard block
 block discarded – undo
1972 1972
 			return false;
1973 1973
 		}
1974 1974
 		if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' )
1975
-		       instanceof
1976
-		       EE_Attendee
1975
+			   instanceof
1976
+			   EE_Attendee
1977 1977
 		) {
1978 1978
 			EE_Error::add_error(
1979 1979
 				sprintf(
@@ -2691,19 +2691,19 @@  discard block
 block discarded – undo
2691 2691
 
2692 2692
 
2693 2693
 
2694
-    /**
2695
-     *    __sleep
2696
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
2697
-     * EE_Checkout will handle the reimplementation of itself upon waking,
2698
-     * but we won't bother with the reg form, because if needed, it will be regenerated anyways
2699
-     *
2700
-     * @return array
2701
-     */
2702
-    public function __sleep()
2703
-    {
2704
-        // remove the reg form and the checkout
2705
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2706
-    }
2694
+	/**
2695
+	 *    __sleep
2696
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization
2697
+	 * EE_Checkout will handle the reimplementation of itself upon waking,
2698
+	 * but we won't bother with the reg form, because if needed, it will be regenerated anyways
2699
+	 *
2700
+	 * @return array
2701
+	 */
2702
+	public function __sleep()
2703
+	{
2704
+		// remove the reg form and the checkout
2705
+		return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2706
+	}
2707 2707
 
2708 2708
 
2709 2709
 
Please login to merge, or discard this patch.
Spacing   +363 added lines, -363 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
 
@@ -38,32 +38,32 @@  discard block
 block discarded – undo
38 38
 	public static function set_hooks() {
39 39
 		add_filter(
40 40
 			'FHEE__SPCO__EE_Line_Item_Filter_Collection',
41
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' )
41
+			array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
42 42
 		);
43 43
 		add_action(
44 44
 			'wp_ajax_switch_spco_billing_form',
45
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )
45
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
46 46
 		);
47 47
 		add_action(
48 48
 			'wp_ajax_nopriv_switch_spco_billing_form',
49
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )
49
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
50 50
 		);
51
-		add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) );
51
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
52 52
 		add_action(
53 53
 			'wp_ajax_nopriv_save_payer_details',
54
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )
54
+			array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
55 55
 		);
56 56
 		add_action(
57 57
 			'wp_ajax_get_transaction_details_for_gateways',
58
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
58
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
59 59
 		);
60 60
 		add_action(
61 61
 			'wp_ajax_nopriv_get_transaction_details_for_gateways',
62
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
62
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
63 63
 		);
64 64
 		add_filter(
65 65
 			'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
66
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ),
66
+			array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
67 67
 			10,
68 68
 			1
69 69
 		);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @throws \EE_Error
78 78
 	 */
79 79
 	public static function switch_spco_billing_form() {
80
-		EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' );
80
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
81 81
 	}
82 82
 
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @throws \EE_Error
89 89
 	 */
90 90
 	public static function save_payer_details() {
91
-		EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' );
91
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
92 92
 	}
93 93
 
94 94
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @throws \EE_Error
100 100
 	 */
101 101
 	public static function get_transaction_details() {
102
-		EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' );
102
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
103 103
 	}
104 104
 
105 105
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 * @access    public
127 127
 	 * @param    EE_Checkout $checkout
128 128
 	 */
129
-	public function __construct( EE_Checkout $checkout ) {
129
+	public function __construct(EE_Checkout $checkout) {
130 130
 		$this->_slug = 'payment_options';
131
-		$this->_name = __( 'Payment Options', 'event_espresso' );
132
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
131
+		$this->_name = __('Payment Options', 'event_espresso');
132
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php';
133 133
 		$this->checkout = $checkout;
134 134
 		$this->_reset_success_message();
135 135
 		$this->set_instructions(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	/**
155 155
 	 * @param null $line_item_display
156 156
 	 */
157
-	public function set_line_item_display( $line_item_display ) {
157
+	public function set_line_item_display($line_item_display) {
158 158
 		$this->line_item_display = $line_item_display;
159 159
 	}
160 160
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
 	 * @param boolean $handle_IPN_in_this_request
174 174
 	 */
175
-	public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) {
176
-		$this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN );
175
+	public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) {
176
+		$this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177 177
 	}
178 178
 
179 179
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 	public function enqueue_styles_and_scripts() {
209 209
 		$transaction = $this->checkout->transaction;
210 210
 		//if the transaction isn't set or nothing is owed on it, don't enqueue any JS
211
-		if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) {
211
+		if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
212 212
 			return;
213 213
 		}
214
-		foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) {
214
+		foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) {
215 215
 			$type_obj = $payment_method->type_obj();
216
-			if( $type_obj instanceof EE_PMT_Base ) {
217
-				$billing_form = $type_obj->generate_new_billing_form( $transaction );
218
-				if( $billing_form instanceof EE_Form_Section_Proper ) {
216
+			if ($type_obj instanceof EE_PMT_Base) {
217
+				$billing_form = $type_obj->generate_new_billing_form($transaction);
218
+				if ($billing_form instanceof EE_Form_Section_Proper) {
219 219
 					$billing_form->enqueue_js();
220 220
 				}
221 221
 			}
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 			// 	$ 0.00 transactions (no payment required)
241 241
 			! $this->checkout->payment_required()
242 242
 			// but do NOT remove if current action being called belongs to this reg step
243
-			&& ! is_callable( array( $this, $this->checkout->action ) )
243
+			&& ! is_callable(array($this, $this->checkout->action))
244 244
 			&& ! $this->completed()
245 245
 		) {
246 246
 			// and if so, then we no longer need the Payment Options step
247
-			if ( $this->is_current_step() ) {
247
+			if ($this->is_current_step()) {
248 248
 				$this->checkout->generate_reg_form = false;
249 249
 			}
250
-			$this->checkout->remove_reg_step( $this->_slug );
250
+			$this->checkout->remove_reg_step($this->_slug);
251 251
 			// DEBUG LOG
252 252
 			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
253 253
 			return false;
254 254
 		}
255 255
 		// load EEM_Payment_Method
256
-		EE_Registry::instance()->load_model( 'Payment_Method' );
256
+		EE_Registry::instance()->load_model('Payment_Method');
257 257
 		// get all active payment methods
258 258
 		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
259 259
 			$this->checkout->transaction,
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 		$insufficient_spaces_available = array();
281 281
 		$no_payment_required = true;
282 282
 		// loop thru registrations to gather info
283
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
283
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
284 284
 		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
285 285
 			$registrations,
286 286
 			$this->checkout->revisit
287 287
 		);
288
-		foreach ( $registrations as $REG_ID => $registration ) {
288
+		foreach ($registrations as $REG_ID => $registration) {
289 289
             /** @var $registration EE_Registration */
290 290
             // has this registration lost it's space ?
291
-			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
292
-				$insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
291
+			if (isset($ejected_registrations[$REG_ID])) {
292
+				$insufficient_spaces_available[$registration->event()->ID()] = $registration->event();
293 293
 				continue;
294 294
 			}
295 295
             // event requires admin approval
@@ -310,11 +310,11 @@  discard block
 block discarded – undo
310 310
 				&& $registration->status_ID() !== EEM_Registration::status_id_approved
311 311
                 && (
312 312
                     $registration->event()->is_sold_out()
313
-                    || $registration->event()->is_sold_out( true )
313
+                    || $registration->event()->is_sold_out(true)
314 314
                 )
315 315
             ) {
316 316
                 // add event to list of events that are sold out
317
-                $sold_out_events[ $registration->event()->ID() ] = $registration->event();
317
+                $sold_out_events[$registration->event()->ID()] = $registration->event();
318 318
                 do_action(
319 319
                     'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
320 320
                     $registration->event(),
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
                 continue;
324 324
 			}
325 325
 			// are they allowed to pay now and is there monies owing?
326
-			if ( $registration->owes_monies_and_can_pay() ) {
327
-				$registrations_requiring_payment[ $REG_ID ] = $registration;
326
+			if ($registration->owes_monies_and_can_pay()) {
327
+				$registrations_requiring_payment[$REG_ID] = $registration;
328 328
 				do_action(
329 329
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
330 330
 					$registration->event(),
@@ -335,29 +335,29 @@  discard block
 block discarded – undo
335 335
 				&& $registration->status_ID() !== EEM_Registration::status_id_not_approved
336 336
 				&& $registration->ticket()->is_free()
337 337
 			) {
338
-				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
338
+				$registrations_for_free_events[$registration->event()->ID()] = $registration;
339 339
 			}
340 340
 		}
341 341
 		$subsections = array();
342 342
 		// now decide which template to load
343
-		if ( ! empty( $sold_out_events ) ) {
344
-			$subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events );
343
+		if ( ! empty($sold_out_events)) {
344
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
345 345
 		}
346
-		if ( ! empty( $insufficient_spaces_available ) ) {
346
+		if ( ! empty($insufficient_spaces_available)) {
347 347
 			$subsections['insufficient_space'] = $this->_insufficient_spaces_available(
348 348
 				$insufficient_spaces_available
349 349
 			);
350 350
 		}
351
-		if ( ! empty( $registrations_requiring_pre_approval ) ) {
351
+		if ( ! empty($registrations_requiring_pre_approval)) {
352 352
 			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
353 353
 				$registrations_requiring_pre_approval
354 354
 			);
355 355
 		}
356
-		if ( ! empty( $registrations_for_free_events ) ) {
357
-			$subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events );
356
+		if ( ! empty($registrations_for_free_events)) {
357
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
358 358
 		}
359
-		if ( ! empty( $registrations_requiring_payment ) ) {
360
-			if ( $this->checkout->amount_owing > 0 ) {
359
+		if ( ! empty($registrations_requiring_payment)) {
360
+			if ($this->checkout->amount_owing > 0) {
361 361
 				// autoload Line_Item_Display classes
362 362
 				EEH_Autoloader::register_line_item_filter_autoloaders();
363 363
 				$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
@@ -370,15 +370,15 @@  discard block
 block discarded – undo
370 370
 				/** @var EE_Line_Item $filtered_line_item_tree */
371 371
 				$filtered_line_item_tree = $line_item_filter_processor->process();
372 372
 				EEH_Autoloader::register_line_item_display_autoloaders();
373
-				$this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) );
373
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
374 374
 				$subsections['payment_options'] = $this->_display_payment_options(
375 375
 					$this->line_item_display->display_line_item(
376 376
 						$filtered_line_item_tree,
377
-						array( 'registrations' => $registrations )
377
+						array('registrations' => $registrations)
378 378
 					)
379 379
 				);
380 380
 				$this->checkout->amount_owing = $filtered_line_item_tree->total();
381
-				$this->_apply_registration_payments_to_amount_owing( $registrations );
381
+				$this->_apply_registration_payments_to_amount_owing($registrations);
382 382
 			}
383 383
 			$no_payment_required = false;
384 384
 		} else {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		$this->_save_selected_method_of_payment();
388 388
 
389 389
 		$subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
390
-		$subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required );
390
+		$subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
391 391
 
392 392
 		return new EE_Form_Section_Proper(
393 393
 			array(
@@ -414,14 +414,14 @@  discard block
 block discarded – undo
414 414
 	 * @return \EE_Line_Item_Filter_Collection
415 415
 	 * @throws \EE_Error
416 416
 	 */
417
-	public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) {
418
-		if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) {
417
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) {
418
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
419 419
 			return $line_item_filter_collection;
420 420
 		}
421
-		if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) {
421
+		if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
422 422
 			return $line_item_filter_collection;
423 423
 		}
424
-		if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) {
424
+		if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
425 425
 			return $line_item_filter_collection;
426 426
 		}
427 427
 		$line_item_filter_collection->add(
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				)
434 434
 			)
435 435
         );
436
-		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
436
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
437 437
 		return $line_item_filter_collection;
438 438
 	}
439 439
 
@@ -449,15 +449,15 @@  discard block
 block discarded – undo
449 449
 	 * @return \EE_Registration[]
450 450
 	 * @throws \EE_Error
451 451
 	 */
452
-	public static function remove_ejected_registrations( array $registrations ) {
452
+	public static function remove_ejected_registrations(array $registrations) {
453 453
 		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
454 454
 			$registrations,
455 455
 			EE_Registry::instance()->SSN->checkout()->revisit
456 456
 		);
457
-		foreach ( $registrations as $REG_ID => $registration ) {
457
+		foreach ($registrations as $REG_ID => $registration) {
458 458
 			// has this registration lost it's space ?
459
-			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
460
-				unset( $registrations[ $REG_ID ] );
459
+			if (isset($ejected_registrations[$REG_ID])) {
460
+				unset($registrations[$REG_ID]);
461 461
 				continue;
462 462
 			}
463 463
 		}
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @return array
481 481
 	 * @throws \EE_Error
482 482
 	 */
483
-	public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) {
483
+	public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) {
484 484
         // registrations per event
485 485
 		$event_reg_count = array();
486 486
 		// spaces left per event
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
         $tickets_remaining = array();
490 490
         // registrations that have lost their space
491 491
 		$ejected_registrations = array();
492
-		foreach ( $registrations as $REG_ID => $registration ) {
493
-			if ( $registration->status_ID() === EEM_Registration::status_id_approved ) {
492
+		foreach ($registrations as $REG_ID => $registration) {
493
+			if ($registration->status_ID() === EEM_Registration::status_id_approved) {
494 494
 				continue;
495 495
 			}
496 496
 			$EVT_ID = $registration->event_ID();
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 				$revisit
512 512
 				&& (
513 513
                     $tickets_remaining[$ticket->ID()] === 0
514
-				    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
514
+				    || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID]
515 515
                 )
516 516
 			) {
517
-				$ejected_registrations[ $REG_ID ] = $registration->event();
518
-				if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) {
517
+				$ejected_registrations[$REG_ID] = $registration->event();
518
+				if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
519 519
 					/** @type EE_Registration_Processor $registration_processor */
520
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
520
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
521 521
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
522 522
 					$registration_processor->manually_update_registration_status(
523 523
 						$registration,
@@ -552,8 +552,8 @@  discard block
 block discarded – undo
552 552
 	 * @return void
553 553
 	 */
554 554
 	protected function _hide_reg_step_submit_button_if_revisit() {
555
-		if ( $this->checkout->revisit ) {
556
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' );
555
+		if ($this->checkout->revisit) {
556
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
557 557
 		}
558 558
 	}
559 559
 
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
 	 * @return \EE_Form_Section_Proper
568 568
 	 * @throws \EE_Error
569 569
 	 */
570
-	private function _sold_out_events( $sold_out_events_array = array() ) {
570
+	private function _sold_out_events($sold_out_events_array = array()) {
571 571
 		// set some defaults
572 572
 		$this->checkout->selected_method_of_payment = 'events_sold_out';
573 573
 		$sold_out_events = '';
574
-		foreach ( $sold_out_events_array as $sold_out_event ) {
574
+		foreach ($sold_out_events_array as $sold_out_event) {
575 575
 			$sold_out_events .= EEH_HTML::li(
576
-				EEH_HTML::span( '  ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )
576
+				EEH_HTML::span('  '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
577 577
 			);
578 578
 		}
579 579
 		return new EE_Form_Section_Proper(
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 								'sold_out_events_msg' => apply_filters(
592 592
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
593 593
 									sprintf(
594
-										__( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso' ),
594
+										__('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso'),
595 595
 										'<strong>',
596 596
 										'</strong>',
597 597
 										'<br />'
@@ -616,14 +616,14 @@  discard block
 block discarded – undo
616 616
 	 * @return \EE_Form_Section_Proper
617 617
 	 * @throws \EE_Error
618 618
 	 */
619
-	private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) {
619
+	private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) {
620 620
 		// set some defaults
621 621
 		$this->checkout->selected_method_of_payment = 'invoice';
622 622
 		$insufficient_space_events = '';
623
-		foreach ( $insufficient_spaces_events_array as $event ) {
624
-			if ( $event instanceof EE_Event ) {
623
+		foreach ($insufficient_spaces_events_array as $event) {
624
+			if ($event instanceof EE_Event) {
625 625
 				$insufficient_space_events .= EEH_HTML::li(
626
-					EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )
626
+					EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
627 627
 				);
628 628
 			}
629 629
 		}
@@ -667,17 +667,17 @@  discard block
 block discarded – undo
667 667
 	 * @return \EE_Form_Section_Proper
668 668
 	 * @throws \EE_Error
669 669
 	 */
670
-	private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) {
670
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) {
671 671
 		$events_requiring_pre_approval = '';
672
-		foreach ( $registrations_requiring_pre_approval as $registration ) {
673
-			if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) {
674
-				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
672
+		foreach ($registrations_requiring_pre_approval as $registration) {
673
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
674
+				$events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
675 675
 					EEH_HTML::span(
676 676
 						'',
677 677
 						'',
678 678
 						'dashicons dashicons-marker ee-icon-size-16 orange-text'
679 679
 					)
680
-					. EEH_HTML::span( $registration->event()->name(), '', 'orange-text' )
680
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
681 681
 				);
682 682
 			}
683 683
 		}
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 						'template_args'        => apply_filters(
693 693
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
694 694
 							array(
695
-								'events_requiring_pre_approval'     => implode( '', $events_requiring_pre_approval ),
695
+								'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
696 696
 								'events_requiring_pre_approval_msg' => apply_filters(
697 697
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
698 698
 									__(
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 	 * @return \EE_Form_Section_Proper
718 718
 	 * @throws \EE_Error
719 719
 	 */
720
-	private function _no_payment_required( $registrations_for_free_events = array() ) {
720
+	private function _no_payment_required($registrations_for_free_events = array()) {
721 721
 		// set some defaults
722 722
 		$this->checkout->selected_method_of_payment = 'no_payment_required';
723 723
 		// generate no_payment_required form
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 								'ticket_count'                  => array(),
738 738
 								'registrations_for_free_events' => $registrations_for_free_events,
739 739
 								'no_payment_required_msg'       => EEH_HTML::p(
740
-									__( 'This is a free event, so no billing will occur.', 'event_espresso' )
740
+									__('This is a free event, so no billing will occur.', 'event_espresso')
741 741
 								)
742 742
 							)
743 743
 						),
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	 * @return \EE_Form_Section_Proper
757 757
 	 * @throws \EE_Error
758 758
 	 */
759
-	private function _display_payment_options( $transaction_details = '' ) {
759
+	private function _display_payment_options($transaction_details = '') {
760 760
 		// has method_of_payment been set by no-js user?
761 761
 		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
762 762
 		// build payment options form
@@ -768,14 +768,14 @@  discard block
 block discarded – undo
768 768
 						'before_payment_options' => apply_filters(
769 769
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
770 770
 							new EE_Form_Section_Proper(
771
-								array( 'layout_strategy' => new EE_Div_Per_Section_Layout() )
771
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
772 772
 							)
773 773
 						),
774 774
 						'payment_options'        => $this->_setup_payment_options(),
775 775
 						'after_payment_options'  => apply_filters(
776 776
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
777 777
 							new EE_Form_Section_Proper(
778
-								array( 'layout_strategy' => new EE_Div_Per_Section_Layout() )
778
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
779 779
 							)
780 780
 						),
781 781
 					),
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
 	 * @return \EE_Form_Section_Proper
807 807
 	 * @throws \EE_Error
808 808
 	 */
809
-	private function _extra_hidden_inputs( $no_payment_required = true ) {
809
+	private function _extra_hidden_inputs($no_payment_required = true) {
810 810
 		return new EE_Form_Section_Proper(
811 811
 			array(
812
-				'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
812
+				'html_id'         => 'ee-'.$this->slug().'-extra-hidden-inputs',
813 813
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
814 814
 				'subsections'     => array(
815 815
 					'spco_no_payment_required' => new EE_Hidden_Input(
@@ -841,16 +841,16 @@  discard block
 block discarded – undo
841 841
 	 * @access protected
842 842
 	 * @param array $registrations
843 843
 	 */
844
-	protected function _apply_registration_payments_to_amount_owing( array $registrations ) {
844
+	protected function _apply_registration_payments_to_amount_owing(array $registrations) {
845 845
 		$payments = array();
846
-		foreach ( $registrations as $registration ) {
847
-			if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
846
+		foreach ($registrations as $registration) {
847
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
848 848
 				$payments += $registration->registration_payments();
849 849
 			}
850 850
 		}
851
-		if ( ! empty( $payments ) ) {
852
-			foreach ( $payments as $payment ) {
853
-				if ( $payment instanceof EE_Registration_Payment ) {
851
+		if ( ! empty($payments)) {
852
+			foreach ($payments as $payment) {
853
+				if ($payment instanceof EE_Registration_Payment) {
854 854
 					$this->checkout->amount_owing -= $payment->amount();
855 855
 				}
856 856
 			}
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 	 * @param    bool $force_reset
867 867
 	 * @return    void
868 868
 	 */
869
-	private function _reset_selected_method_of_payment( $force_reset = false ) {
869
+	private function _reset_selected_method_of_payment($force_reset = false) {
870 870
 		$reset_payment_method = $force_reset
871 871
 			? true
872
-			: sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) );
873
-		if ( $reset_payment_method ) {
872
+			: sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
873
+		if ($reset_payment_method) {
874 874
 			$this->checkout->selected_method_of_payment = null;
875 875
 			$this->checkout->payment_method = null;
876 876
 			$this->checkout->billing_form = null;
@@ -889,12 +889,12 @@  discard block
 block discarded – undo
889 889
 	 * @param string $selected_method_of_payment
890 890
 	 * @return  void
891 891
 	 */
892
-	private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) {
893
-		$selected_method_of_payment = ! empty( $selected_method_of_payment )
892
+	private function _save_selected_method_of_payment($selected_method_of_payment = '') {
893
+		$selected_method_of_payment = ! empty($selected_method_of_payment)
894 894
 			? $selected_method_of_payment
895 895
 			: $this->checkout->selected_method_of_payment;
896 896
 		EE_Registry::instance()->SSN->set_session_data(
897
-			array( 'selected_method_of_payment' => $selected_method_of_payment )
897
+			array('selected_method_of_payment' => $selected_method_of_payment)
898 898
 		);
899 899
 	}
900 900
 
@@ -910,19 +910,19 @@  discard block
 block discarded – undo
910 910
 		// load payment method classes
911 911
 		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
912 912
 		// switch up header depending on number of available payment methods
913
-		$payment_method_header = count( $this->checkout->available_payment_methods ) > 1
913
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
914 914
 			? apply_filters(
915 915
 				'FHEE__registration_page_payment_options__method_of_payment_hdr',
916
-				__( 'Please Select Your Method of Payment', 'event_espresso' )
916
+				__('Please Select Your Method of Payment', 'event_espresso')
917 917
 			)
918 918
 			: apply_filters(
919 919
 				'FHEE__registration_page_payment_options__method_of_payment_hdr',
920
-				__( 'Method of Payment', 'event_espresso' )
920
+				__('Method of Payment', 'event_espresso')
921 921
 			);
922 922
 		$available_payment_methods = array(
923 923
 			// display the "Payment Method" header
924 924
 			'payment_method_header' => new EE_Form_Section_HTML(
925
-				EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' )
925
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
926 926
 			)
927 927
 		);
928 928
 		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
@@ -931,32 +931,32 @@  discard block
 block discarded – undo
931 931
 		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
932 932
 		$payment_methods_billing_info = array(
933 933
 			new EE_Form_Section_HTML(
934
-				EEH_HTML::div( '<br />', '', '', 'clear:both;' )
934
+				EEH_HTML::div('<br />', '', '', 'clear:both;')
935 935
 			)
936 936
 		);
937 937
 		// loop through payment methods
938
-		foreach ( $this->checkout->available_payment_methods as $payment_method ) {
939
-			if ( $payment_method instanceof EE_Payment_Method ) {
938
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
939
+			if ($payment_method instanceof EE_Payment_Method) {
940 940
 				$payment_method_button = EEH_HTML::img(
941 941
 					$payment_method->button_url(),
942 942
 					$payment_method->name(),
943
-					'spco-payment-method-' . $payment_method->slug() . '-btn-img',
943
+					'spco-payment-method-'.$payment_method->slug().'-btn-img',
944 944
 					'spco-payment-method-btn-img'
945 945
 				);
946 946
 				// check if any payment methods are set as default
947 947
 				// if payment method is already selected OR nothing is selected and this payment method should be open_by_default
948 948
 				if (
949
-					( $this->checkout->selected_method_of_payment === $payment_method->slug() )
950
-					|| ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )
949
+					($this->checkout->selected_method_of_payment === $payment_method->slug())
950
+					|| ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
951 951
 				) {
952 952
 					$this->checkout->selected_method_of_payment = $payment_method->slug();
953 953
 					$this->_save_selected_method_of_payment();
954
-					$default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
954
+					$default_payment_method_option[$payment_method->slug()] = $payment_method_button;
955 955
 				} else {
956
-					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
956
+					$available_payment_method_options[$payment_method->slug()] = $payment_method_button;
957 957
 				}
958
-				$payment_methods_billing_info[ $payment_method->slug()
959
-				                               . '-info' ] = $this->_payment_method_billing_info(
958
+				$payment_methods_billing_info[$payment_method->slug()
959
+				                               . '-info'] = $this->_payment_method_billing_info(
960 960
 					$payment_method
961 961
 				);
962 962
 			}
@@ -986,12 +986,12 @@  discard block
 block discarded – undo
986 986
 	 * @return EE_Payment_Method[]
987 987
 	 */
988 988
 	protected function _get_available_payment_methods() {
989
-		if ( ! empty( $this->checkout->available_payment_methods ) ) {
989
+		if ( ! empty($this->checkout->available_payment_methods)) {
990 990
 			return $this->checkout->available_payment_methods;
991 991
 		}
992 992
 		$available_payment_methods = array();
993 993
 		// load EEM_Payment_Method
994
-		EE_Registry::instance()->load_model( 'Payment_Method' );
994
+		EE_Registry::instance()->load_model('Payment_Method');
995 995
 		/** @type EEM_Payment_Method $EEM_Payment_Method */
996 996
 		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
997 997
 		// get all active payment methods
@@ -999,9 +999,9 @@  discard block
 block discarded – undo
999 999
 			$this->checkout->transaction,
1000 1000
 			EEM_Payment_Method::scope_cart
1001 1001
 		);
1002
-		foreach ( $payment_methods as $payment_method ) {
1003
-			if ( $payment_method instanceof EE_Payment_Method ) {
1004
-				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
1002
+		foreach ($payment_methods as $payment_method) {
1003
+			if ($payment_method instanceof EE_Payment_Method) {
1004
+				$available_payment_methods[$payment_method->slug()] = $payment_method;
1005 1005
 			}
1006 1006
 		}
1007 1007
 		return $available_payment_methods;
@@ -1016,14 +1016,14 @@  discard block
 block discarded – undo
1016 1016
 	 * @param    array $available_payment_method_options
1017 1017
 	 * @return    \EE_Form_Section_Proper
1018 1018
 	 */
1019
-	private function _available_payment_method_inputs( $available_payment_method_options = array() ) {
1019
+	private function _available_payment_method_inputs($available_payment_method_options = array()) {
1020 1020
 		// generate inputs
1021 1021
 		return new EE_Form_Section_Proper(
1022 1022
 			array(
1023 1023
 				'html_id'         => 'ee-available-payment-method-inputs',
1024 1024
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1025 1025
 				'subsections'     => array(
1026
-					'' => new EE_Radio_Button_Input (
1026
+					'' => new EE_Radio_Button_Input(
1027 1027
 						$available_payment_method_options,
1028 1028
 						array(
1029 1029
 							'html_name'          => 'selected_method_of_payment',
@@ -1048,28 +1048,28 @@  discard block
 block discarded – undo
1048 1048
 	 * @return    \EE_Form_Section_Proper
1049 1049
 	 * @throws \EE_Error
1050 1050
 	 */
1051
-	private function _payment_method_billing_info( EE_Payment_Method $payment_method ) {
1051
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method) {
1052 1052
 		$currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1053 1053
 			? true
1054 1054
 			: false;
1055 1055
 		// generate the billing form for payment method
1056 1056
 		$billing_form = $currently_selected
1057
-			? $this->_get_billing_form_for_payment_method( $payment_method )
1057
+			? $this->_get_billing_form_for_payment_method($payment_method)
1058 1058
 			: new EE_Form_Section_HTML();
1059 1059
 		$this->checkout->billing_form = $currently_selected
1060 1060
 			? $billing_form
1061 1061
 			: $this->checkout->billing_form;
1062 1062
 		// it's all in the details
1063 1063
 		$info_html = EEH_HTML::h3(
1064
-			__( 'Important information regarding your payment', 'event_espresso' ),
1064
+			__('Important information regarding your payment', 'event_espresso'),
1065 1065
 			'',
1066 1066
 			'spco-payment-method-hdr'
1067 1067
 		);
1068 1068
 		// add some info regarding the step, either from what's saved in the admin,
1069 1069
 		// or a default string depending on whether the PM has a billing form or not
1070
-		if ( $payment_method->description() ) {
1070
+		if ($payment_method->description()) {
1071 1071
 			$payment_method_info = $payment_method->description();
1072
-		} elseif ( $billing_form instanceof EE_Billing_Info_Form ) {
1072
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
1073 1073
 			$payment_method_info = sprintf(
1074 1074
 				__(
1075 1075
 					'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 			);
1080 1080
 		} else {
1081 1081
 			$payment_method_info = sprintf(
1082
-				__( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ),
1082
+				__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1083 1083
 				$this->submit_button_text()
1084 1084
 			);
1085 1085
 		}
@@ -1093,13 +1093,13 @@  discard block
 block discarded – undo
1093 1093
 		);
1094 1094
 		return new EE_Form_Section_Proper(
1095 1095
 			array(
1096
-				'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1096
+				'html_id'         => 'spco-payment-method-info-'.$payment_method->slug(),
1097 1097
 				'html_class'      => 'spco-payment-method-info-dv',
1098 1098
 				// only display the selected or default PM
1099 1099
 				'html_style'      => $currently_selected ? '' : 'display:none;',
1100 1100
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1101 1101
 				'subsections'     => array(
1102
-					'info'         => new EE_Form_Section_HTML( $info_html ),
1102
+					'info'         => new EE_Form_Section_HTML($info_html),
1103 1103
 					'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML()
1104 1104
 				)
1105 1105
 			)
@@ -1117,15 +1117,15 @@  discard block
 block discarded – undo
1117 1117
 	 */
1118 1118
 	public function get_billing_form_html_for_payment_method() {
1119 1119
 		// how have they chosen to pay?
1120
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1120
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1121 1121
 		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1122
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
1122
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1123 1123
 			return false;
1124 1124
 		}
1125
-		if ( apply_filters(
1125
+		if (apply_filters(
1126 1126
 			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1127 1127
 			false
1128
-		) ) {
1128
+		)) {
1129 1129
 			EE_Error::add_success(
1130 1130
 				apply_filters(
1131 1131
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 			);
1141 1141
 		}
1142 1142
 		// now generate billing form for selected method of payment
1143
-		$payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
1143
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1144 1144
 		// fill form with attendee info if applicable
1145 1145
 		if (
1146 1146
 			$payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
@@ -1162,10 +1162,10 @@  discard block
 block discarded – undo
1162 1162
 		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1163 1163
 			? $payment_method_billing_form->get_html()
1164 1164
 			: '';
1165
-		$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) );
1165
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1166 1166
 		// localize validation rules for main form
1167 1167
 		$this->checkout->current_step->reg_form->localize_validation_rules();
1168
-		$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
1168
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1169 1169
 		return true;
1170 1170
 	}
1171 1171
 
@@ -1179,18 +1179,18 @@  discard block
 block discarded – undo
1179 1179
 	 * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML
1180 1180
 	 * @throws \EE_Error
1181 1181
 	 */
1182
-	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
1182
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) {
1183 1183
 		$billing_form = $payment_method->type_obj()->billing_form(
1184 1184
 			$this->checkout->transaction,
1185
-			array( 'amount_owing' => $this->checkout->amount_owing )
1185
+			array('amount_owing' => $this->checkout->amount_owing)
1186 1186
 		);
1187
-		if ( $billing_form instanceof EE_Billing_Info_Form ) {
1187
+		if ($billing_form instanceof EE_Billing_Info_Form) {
1188 1188
 			if (
1189 1189
 				apply_filters(
1190 1190
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1191 1191
 					false
1192 1192
 				)
1193
-				&& EE_Registry::instance()->REQ->is_set( 'payment_method' )
1193
+				&& EE_Registry::instance()->REQ->is_set('payment_method')
1194 1194
 			) {
1195 1195
 				EE_Error::add_success(
1196 1196
 					apply_filters(
@@ -1232,15 +1232,15 @@  discard block
 block discarded – undo
1232 1232
 		$request_param = 'selected_method_of_payment'
1233 1233
 	) {
1234 1234
 		// is selected_method_of_payment set in the request ?
1235
-		$selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false );
1236
-		if ( $selected_method_of_payment ) {
1235
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1236
+		if ($selected_method_of_payment) {
1237 1237
 			// sanitize it
1238
-			$selected_method_of_payment = is_array( $selected_method_of_payment )
1239
-				? array_shift( $selected_method_of_payment )
1238
+			$selected_method_of_payment = is_array($selected_method_of_payment)
1239
+				? array_shift($selected_method_of_payment)
1240 1240
 				: $selected_method_of_payment;
1241
-			$selected_method_of_payment = sanitize_text_field( $selected_method_of_payment );
1241
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1242 1242
 			// store it in the session so that it's available for all subsequent requests including AJAX
1243
-			$this->_save_selected_method_of_payment( $selected_method_of_payment );
1243
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
1244 1244
 		} else {
1245 1245
 			// or is is set in the session ?
1246 1246
 			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 			);
1249 1249
 		}
1250 1250
 		// do ya really really gotta have it?
1251
-		if ( empty( $selected_method_of_payment ) && $required ) {
1251
+		if (empty($selected_method_of_payment) && $required) {
1252 1252
 			EE_Error::add_error(
1253 1253
 				sprintf(
1254 1254
 					__(
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 					),
1258 1258
 					'<br/>',
1259 1259
 					'<br/>',
1260
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1260
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1261 1261
 				),
1262 1262
 				__FILE__,
1263 1263
 				__FUNCTION__,
@@ -1284,13 +1284,13 @@  discard block
 block discarded – undo
1284 1284
 	 * @throws \EE_Error
1285 1285
 	 */
1286 1286
 	public function switch_payment_method() {
1287
-		if ( ! $this->_verify_payment_method_is_set() ) {
1287
+		if ( ! $this->_verify_payment_method_is_set()) {
1288 1288
 			return false;
1289 1289
 		}
1290
-		if ( apply_filters(
1290
+		if (apply_filters(
1291 1291
 			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1292 1292
 			false
1293
-		) ) {
1293
+		)) {
1294 1294
 			EE_Error::add_success(
1295 1295
 				apply_filters(
1296 1296
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 			);
1306 1306
 		}
1307 1307
 		// generate billing form for selected method of payment if it hasn't been done already
1308
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1308
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1309 1309
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1310 1310
 				$this->checkout->payment_method
1311 1311
 			);
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 			);
1328 1328
 		}
1329 1329
 		// and debug content
1330
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form
1330
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1331 1331
 		     && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1332 1332
 		) {
1333 1333
 			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
@@ -1335,15 +1335,15 @@  discard block
 block discarded – undo
1335 1335
 			);
1336 1336
 		}
1337 1337
 		// get html and validation rules for form
1338
-		if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) {
1338
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1339 1339
 			$this->checkout->json_response->set_return_data(
1340
-				array( 'payment_method_info' => $this->checkout->billing_form->get_html() )
1340
+				array('payment_method_info' => $this->checkout->billing_form->get_html())
1341 1341
 			);
1342 1342
 			// localize validation rules for main form
1343
-			$this->checkout->billing_form->localize_validation_rules( true );
1344
-			$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
1343
+			$this->checkout->billing_form->localize_validation_rules(true);
1344
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1345 1345
 		} else {
1346
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) );
1346
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1347 1347
 		}
1348 1348
 		//prevents advancement to next step
1349 1349
 		$this->checkout->continue_reg = false;
@@ -1360,18 +1360,18 @@  discard block
 block discarded – undo
1360 1360
 	 */
1361 1361
 	protected function _verify_payment_method_is_set() {
1362 1362
 		// generate billing form for selected method of payment if it hasn't been done already
1363
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1363
+		if (empty($this->checkout->selected_method_of_payment)) {
1364 1364
 			// how have they chosen to pay?
1365
-			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1365
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1366 1366
 		} else {
1367 1367
 			// choose your own adventure based on method_of_payment
1368
-			switch ( $this->checkout->selected_method_of_payment ) {
1368
+			switch ($this->checkout->selected_method_of_payment) {
1369 1369
 				case 'events_sold_out' :
1370 1370
 					EE_Error::add_attention(
1371 1371
 						apply_filters(
1372 1372
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
1373
-							__( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
1374
-								'event_espresso' )
1373
+							__('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
1374
+								'event_espresso')
1375 1375
 						),
1376 1376
 						__FILE__, __FUNCTION__, __LINE__
1377 1377
 					);
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 					EE_Error::add_attention(
1382 1382
 						apply_filters(
1383 1383
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
1384
-							__( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' )
1384
+							__('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso')
1385 1385
 						),
1386 1386
 						__FILE__, __FUNCTION__, __LINE__
1387 1387
 					);
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 					EE_Error::add_attention(
1392 1392
 						apply_filters(
1393 1393
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
1394
-							__( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' )
1394
+							__('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso')
1395 1395
 						),
1396 1396
 						__FILE__, __FUNCTION__, __LINE__
1397 1397
 					);
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 			}
1402 1402
 		}
1403 1403
 		// verify payment method
1404
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
1404
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1405 1405
 			// get payment method for selected method of payment
1406 1406
 			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1407 1407
 		}
@@ -1420,25 +1420,25 @@  discard block
 block discarded – undo
1420 1420
 	 * @throws \EE_Error
1421 1421
 	 */
1422 1422
 	public function save_payer_details_via_ajax() {
1423
-		if ( ! $this->_verify_payment_method_is_set() ) {
1423
+		if ( ! $this->_verify_payment_method_is_set()) {
1424 1424
 			return;
1425 1425
 		}
1426 1426
 		// generate billing form for selected method of payment if it hasn't been done already
1427
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1427
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1428 1428
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1429 1429
 				$this->checkout->payment_method
1430 1430
 			);
1431 1431
 		}
1432 1432
 		// generate primary attendee from payer info if applicable
1433
-		if ( ! $this->checkout->transaction_has_primary_registrant() ) {
1433
+		if ( ! $this->checkout->transaction_has_primary_registrant()) {
1434 1434
 			$attendee = $this->_create_attendee_from_request_data();
1435
-			if ( $attendee instanceof EE_Attendee ) {
1436
-				foreach ( $this->checkout->transaction->registrations() as $registration ) {
1437
-					if ( $registration->is_primary_registrant() ) {
1435
+			if ($attendee instanceof EE_Attendee) {
1436
+				foreach ($this->checkout->transaction->registrations() as $registration) {
1437
+					if ($registration->is_primary_registrant()) {
1438 1438
 						$this->checkout->primary_attendee_obj = $attendee;
1439
-						$registration->_add_relation_to( $attendee, 'Attendee' );
1440
-						$registration->set_attendee_id( $attendee->ID() );
1441
-						$registration->update_cache_after_object_save( 'Attendee', $attendee );
1439
+						$registration->_add_relation_to($attendee, 'Attendee');
1440
+						$registration->set_attendee_id($attendee->ID());
1441
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1442 1442
 					}
1443 1443
 				}
1444 1444
 			}
@@ -1456,50 +1456,50 @@  discard block
 block discarded – undo
1456 1456
 	 */
1457 1457
 	protected function _create_attendee_from_request_data() {
1458 1458
 		// get State ID
1459
-		$STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : '';
1460
-		if ( ! empty( $STA_ID ) ) {
1459
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1460
+		if ( ! empty($STA_ID)) {
1461 1461
 			// can we get state object from name ?
1462
-			EE_Registry::instance()->load_model( 'State' );
1463
-			$state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' );
1464
-			$STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID;
1462
+			EE_Registry::instance()->load_model('State');
1463
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1464
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1465 1465
 		}
1466 1466
 		// get Country ISO
1467
-		$CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : '';
1468
-		if ( ! empty( $CNT_ISO ) ) {
1467
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1468
+		if ( ! empty($CNT_ISO)) {
1469 1469
 			// can we get country object from name ?
1470
-			EE_Registry::instance()->load_model( 'Country' );
1470
+			EE_Registry::instance()->load_model('Country');
1471 1471
 			$country = EEM_Country::instance()->get_col(
1472
-				array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ),
1472
+				array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1473 1473
 				'CNT_ISO'
1474 1474
 			);
1475
-			$CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO;
1475
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1476 1476
 		}
1477 1477
 		// grab attendee data
1478 1478
 		$attendee_data = array(
1479
-			'ATT_fname'    => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '',
1480
-			'ATT_lname'    => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '',
1481
-			'ATT_email'    => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '',
1482
-			'ATT_address'  => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '',
1483
-			'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '',
1484
-			'ATT_city'     => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '',
1479
+			'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1480
+			'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1481
+			'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1482
+			'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1483
+			'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1484
+			'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1485 1485
 			'STA_ID'       => $STA_ID,
1486 1486
 			'CNT_ISO'      => $CNT_ISO,
1487
-			'ATT_zip'      => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '',
1488
-			'ATT_phone'    => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '',
1487
+			'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1488
+			'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1489 1489
 		);
1490 1490
 		// validate the email address since it is the most important piece of info
1491
-		if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) {
1491
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1492 1492
 			EE_Error::add_error(
1493
-				__( 'An invalid email address was submitted.', 'event_espresso' ),
1493
+				__('An invalid email address was submitted.', 'event_espresso'),
1494 1494
 				__FILE__,
1495 1495
 				__FUNCTION__,
1496 1496
 				__LINE__
1497 1497
 			);
1498 1498
 		}
1499 1499
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1500
-		if ( ! empty( $attendee_data['ATT_fname'] )
1501
-		     && ! empty( $attendee_data['ATT_lname'] )
1502
-		     && ! empty( $attendee_data['ATT_email'] )
1500
+		if ( ! empty($attendee_data['ATT_fname'])
1501
+		     && ! empty($attendee_data['ATT_lname'])
1502
+		     && ! empty($attendee_data['ATT_email'])
1503 1503
 		) {
1504 1504
 			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1505 1505
 				array(
@@ -1508,19 +1508,19 @@  discard block
 block discarded – undo
1508 1508
 					'ATT_email' => $attendee_data['ATT_email']
1509 1509
 				)
1510 1510
 			);
1511
-			if ( $existing_attendee instanceof EE_Attendee ) {
1511
+			if ($existing_attendee instanceof EE_Attendee) {
1512 1512
 				return $existing_attendee;
1513 1513
 			}
1514 1514
 		}
1515 1515
 		// no existing attendee? kk let's create a new one
1516 1516
 		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
1517
-		$attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] )
1517
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1518 1518
 			? $attendee_data['ATT_fname']
1519 1519
 			: $attendee_data['ATT_email'];
1520
-		$attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] )
1520
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1521 1521
 			? $attendee_data['ATT_lname']
1522 1522
 			: $attendee_data['ATT_email'];
1523
-		return EE_Attendee::new_instance( $attendee_data );
1523
+		return EE_Attendee::new_instance($attendee_data);
1524 1524
 	}
1525 1525
 
1526 1526
 
@@ -1538,26 +1538,26 @@  discard block
 block discarded – undo
1538 1538
 		// how have they chosen to pay?
1539 1539
 		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1540 1540
 			? 'no_payment_required'
1541
-			: $this->_get_selected_method_of_payment( true );
1541
+			: $this->_get_selected_method_of_payment(true);
1542 1542
 		// choose your own adventure based on method_of_payment
1543
-		switch ( $this->checkout->selected_method_of_payment ) {
1543
+		switch ($this->checkout->selected_method_of_payment) {
1544 1544
 
1545 1545
 			case 'events_sold_out' :
1546 1546
 				$this->checkout->redirect = true;
1547 1547
 				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1548
-				$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1548
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1549 1549
 				// mark this reg step as completed
1550 1550
 				$this->set_completed();
1551 1551
 				return false;
1552 1552
 				break;
1553 1553
 
1554 1554
 			case 'payments_closed' :
1555
-				if ( apply_filters(
1555
+				if (apply_filters(
1556 1556
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1557 1557
 					false
1558
-				) ) {
1558
+				)) {
1559 1559
 					EE_Error::add_success(
1560
-						__( 'no payment required at this time.', 'event_espresso' ),
1560
+						__('no payment required at this time.', 'event_espresso'),
1561 1561
 						__FILE__,
1562 1562
 						__FUNCTION__,
1563 1563
 						__LINE__
@@ -1569,12 +1569,12 @@  discard block
 block discarded – undo
1569 1569
 				break;
1570 1570
 
1571 1571
 			case 'no_payment_required' :
1572
-				if ( apply_filters(
1572
+				if (apply_filters(
1573 1573
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1574 1574
 					false
1575
-				) ) {
1575
+				)) {
1576 1576
 					EE_Error::add_success(
1577
-						__( 'no payment required.', 'event_espresso' ),
1577
+						__('no payment required.', 'event_espresso'),
1578 1578
 						__FILE__,
1579 1579
 						__FUNCTION__,
1580 1580
 						__LINE__
@@ -1594,15 +1594,15 @@  discard block
 block discarded – undo
1594 1594
 					EE_Registry::instance()->SSN->checkout()->revisit
1595 1595
 				);
1596 1596
 				// calculate difference between the two arrays
1597
-				$registrations = array_diff( $registrations, $ejected_registrations );
1598
-				if ( empty( $registrations ) ) {
1597
+				$registrations = array_diff($registrations, $ejected_registrations);
1598
+				if (empty($registrations)) {
1599 1599
 					$this->_redirect_because_event_sold_out();
1600 1600
 					return false;
1601 1601
 				}
1602 1602
 				$payment_successful = $this->_process_payment();
1603
-				if ( $payment_successful ) {
1603
+				if ($payment_successful) {
1604 1604
 					$this->checkout->continue_reg = true;
1605
-					$this->_maybe_set_completed( $this->checkout->payment_method );
1605
+					$this->_maybe_set_completed($this->checkout->payment_method);
1606 1606
 				} else {
1607 1607
 					$this->checkout->continue_reg = false;
1608 1608
 				}
@@ -1623,10 +1623,10 @@  discard block
 block discarded – undo
1623 1623
 		$this->checkout->continue_reg = false;
1624 1624
 		// set redirect URL
1625 1625
 		$this->checkout->redirect_url = add_query_arg(
1626
-			array( 'e_reg_url_link' => $this->checkout->reg_url_link ),
1626
+			array('e_reg_url_link' => $this->checkout->reg_url_link),
1627 1627
 			$this->checkout->current_step->reg_step_url()
1628 1628
 		);
1629
-		$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1629
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1630 1630
 	}
1631 1631
 
1632 1632
 
@@ -1639,8 +1639,8 @@  discard block
 block discarded – undo
1639 1639
 	 * @return void
1640 1640
 	 * @throws \EE_Error
1641 1641
 	 */
1642
-	protected function _maybe_set_completed( EE_Payment_Method $payment_method ) {
1643
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1642
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method) {
1643
+		switch ($payment_method->type_obj()->payment_occurs()) {
1644 1644
 			case EE_PMT_Base::offsite :
1645 1645
 				break;
1646 1646
 			case EE_PMT_Base::onsite :
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 	public function update_reg_step() {
1664 1664
 		$success = true;
1665 1665
 		// if payment required
1666
-		if ( $this->checkout->transaction->total() > 0 ) {
1666
+		if ($this->checkout->transaction->total() > 0) {
1667 1667
 			do_action(
1668 1668
 				'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1669 1669
 				$this->checkout->transaction
@@ -1671,13 +1671,13 @@  discard block
 block discarded – undo
1671 1671
 			// attempt payment via payment method
1672 1672
 			$success = $this->process_reg_step();
1673 1673
 		}
1674
-		if ( $success && ! $this->checkout->redirect ) {
1674
+		if ($success && ! $this->checkout->redirect) {
1675 1675
 			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1676 1676
 				$this->checkout->transaction->ID()
1677 1677
 			);
1678 1678
 			// set return URL
1679 1679
 			$this->checkout->redirect_url = add_query_arg(
1680
-				array( 'e_reg_url_link' => $this->checkout->reg_url_link ),
1680
+				array('e_reg_url_link' => $this->checkout->reg_url_link),
1681 1681
 				$this->checkout->thank_you_page_url
1682 1682
 			);
1683 1683
 		}
@@ -1695,36 +1695,36 @@  discard block
 block discarded – undo
1695 1695
 	 */
1696 1696
 	private function _process_payment() {
1697 1697
 		// basically confirm that the event hasn't sold out since they hit the page
1698
-		if ( ! $this->_last_second_ticket_verifications() ) {
1698
+		if ( ! $this->_last_second_ticket_verifications()) {
1699 1699
 			return false;
1700 1700
 		}
1701 1701
 		// ya gotta make a choice man
1702
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1702
+		if (empty($this->checkout->selected_method_of_payment)) {
1703 1703
 			$this->checkout->json_response->set_plz_select_method_of_payment(
1704
-				__( 'Please select a method of payment before proceeding.', 'event_espresso' )
1704
+				__('Please select a method of payment before proceeding.', 'event_espresso')
1705 1705
 			);
1706 1706
 			return false;
1707 1707
 		}
1708 1708
 		// get EE_Payment_Method object
1709
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1709
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1710 1710
 			return false;
1711 1711
 		}
1712 1712
 		// setup billing form
1713
-		if ( $this->checkout->payment_method->is_on_site() ) {
1713
+		if ($this->checkout->payment_method->is_on_site()) {
1714 1714
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1715 1715
 				$this->checkout->payment_method
1716 1716
 			);
1717 1717
 			// bad billing form ?
1718
-			if ( ! $this->_billing_form_is_valid() ) {
1718
+			if ( ! $this->_billing_form_is_valid()) {
1719 1719
 				return false;
1720 1720
 			}
1721 1721
 		}
1722 1722
 		// ensure primary registrant has been fully processed
1723
-		if ( ! $this->_setup_primary_registrant_prior_to_payment() ) {
1723
+		if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1724 1724
 			return false;
1725 1725
 		}
1726 1726
 		// if session is close to expiring (under 10 minutes by default)
1727
-		if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) {
1727
+		if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1728 1728
 			// add some time to session expiration so that payment can be completed
1729 1729
 			EE_Registry::instance()->SSN->extend_expiration();
1730 1730
 		}
@@ -1733,12 +1733,12 @@  discard block
 block discarded – undo
1733 1733
 		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved
1734 1734
 		//$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params );
1735 1735
 		// attempt payment
1736
-		$payment = $this->_attempt_payment( $this->checkout->payment_method );
1736
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1737 1737
 		// process results
1738
-		$payment = $this->_validate_payment( $payment );
1739
-		$payment = $this->_post_payment_processing( $payment );
1738
+		$payment = $this->_validate_payment($payment);
1739
+		$payment = $this->_post_payment_processing($payment);
1740 1740
 		// verify payment
1741
-		if ( $payment instanceof EE_Payment ) {
1741
+		if ($payment instanceof EE_Payment) {
1742 1742
 			// store that for later
1743 1743
 			$this->checkout->payment = $payment;
1744 1744
 			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
 			} else {
1753 1753
 				return false;
1754 1754
 			}
1755
-		} else if ( $payment === true ) {
1755
+		} else if ($payment === true) {
1756 1756
 			// please note that offline payment methods will NOT make a payment,
1757 1757
 			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1758 1758
 			$this->checkout->payment = $payment;
@@ -1772,22 +1772,22 @@  discard block
 block discarded – undo
1772 1772
 	 */
1773 1773
 	protected function _last_second_ticket_verifications() {
1774 1774
 		// don't bother re-validating if not a return visit
1775
-		if ( ! $this->checkout->revisit ) {
1775
+		if ( ! $this->checkout->revisit) {
1776 1776
 			return true;
1777 1777
 		}
1778 1778
 		$registrations = $this->checkout->transaction->registrations();
1779
-		if ( empty( $registrations ) ) {
1779
+		if (empty($registrations)) {
1780 1780
 			return false;
1781 1781
 		}
1782
-		foreach ( $registrations as $registration ) {
1783
-			if ( $registration instanceof EE_Registration ) {
1782
+		foreach ($registrations as $registration) {
1783
+			if ($registration instanceof EE_Registration) {
1784 1784
 				$event = $registration->event_obj();
1785
-				if ( $event instanceof EE_Event && $event->is_sold_out( true ) ) {
1785
+				if ($event instanceof EE_Event && $event->is_sold_out(true)) {
1786 1786
 					EE_Error::add_error(
1787 1787
 						apply_filters(
1788 1788
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1789 1789
 							sprintf(
1790
-								__( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ),
1790
+								__('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'),
1791 1791
 								$event->name()
1792 1792
 							)
1793 1793
 						),
@@ -1817,7 +1817,7 @@  discard block
 block discarded – undo
1817 1817
 		);
1818 1818
 		$html = $payment_method_billing_info->get_html();
1819 1819
 		$html .= $this->checkout->redirect_form;
1820
-		EE_Registry::instance()->REQ->add_output( $html );
1820
+		EE_Registry::instance()->REQ->add_output($html);
1821 1821
 		return true;
1822 1822
 	}
1823 1823
 
@@ -1831,28 +1831,28 @@  discard block
 block discarded – undo
1831 1831
 	 * @throws \EE_Error
1832 1832
 	 */
1833 1833
 	private function _billing_form_is_valid() {
1834
-		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1834
+		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1835 1835
 			return true;
1836 1836
 		}
1837
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) {
1838
-			if ( $this->checkout->billing_form->was_submitted() ) {
1837
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1838
+			if ($this->checkout->billing_form->was_submitted()) {
1839 1839
 				$this->checkout->billing_form->receive_form_submission();
1840
-				if ( $this->checkout->billing_form->is_valid() ) {
1840
+				if ($this->checkout->billing_form->is_valid()) {
1841 1841
 					return true;
1842 1842
 				}
1843 1843
 				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1844 1844
 				$error_strings = array();
1845
-				foreach ( $validation_errors as $validation_error ) {
1846
-					if ( $validation_error instanceof EE_Validation_Error ) {
1845
+				foreach ($validation_errors as $validation_error) {
1846
+					if ($validation_error instanceof EE_Validation_Error) {
1847 1847
 						$form_section = $validation_error->get_form_section();
1848
-						if ( $form_section instanceof EE_Form_Input_Base ) {
1848
+						if ($form_section instanceof EE_Form_Input_Base) {
1849 1849
 							$label = $form_section->html_label_text();
1850
-						} elseif ( $form_section instanceof EE_Form_Section_Base ) {
1850
+						} elseif ($form_section instanceof EE_Form_Section_Base) {
1851 1851
 							$label = $form_section->name();
1852 1852
 						} else {
1853
-							$label = __( 'Validation Error', 'event_espresso' );
1853
+							$label = __('Validation Error', 'event_espresso');
1854 1854
 						}
1855
-						$error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() );
1855
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
1856 1856
 					}
1857 1857
 				}
1858 1858
 				EE_Error::add_error(
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 							'event_espresso'
1863 1863
 						),
1864 1864
 						'<br/>',
1865
-						implode( '<br/>', $error_strings )
1865
+						implode('<br/>', $error_strings)
1866 1866
 					),
1867 1867
 					__FILE__,
1868 1868
 					__FUNCTION__,
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
 			}
1882 1882
 		} else {
1883 1883
 			EE_Error::add_error(
1884
-				__( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ),
1884
+				__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'),
1885 1885
 				__FILE__,
1886 1886
 				__FUNCTION__,
1887 1887
 				__LINE__
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
 		// save the TXN ( which clears cached copy of primary_registration)
1921 1921
 		$this->checkout->transaction->save();
1922 1922
 		// grab TXN ID and save it to the primary_registration
1923
-		$primary_registration->set_transaction_id( $this->checkout->transaction->ID() );
1923
+		$primary_registration->set_transaction_id($this->checkout->transaction->ID());
1924 1924
 		// save what we have so far
1925 1925
 		$primary_registration->save();
1926 1926
 		return true;
@@ -1938,7 +1938,7 @@  discard block
 block discarded – undo
1938 1938
 	private function _capture_primary_registration_data_from_billing_form() {
1939 1939
 		// convert billing form data into an attendee
1940 1940
 		$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
1941
-		if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
1941
+		if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
1942 1942
 			EE_Error::add_error(
1943 1943
 				sprintf(
1944 1944
 					__(
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 						'event_espresso'
1947 1947
 					),
1948 1948
 					'<br/>',
1949
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1949
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1950 1950
 				),
1951 1951
 				__FILE__,
1952 1952
 				__FUNCTION__,
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 			return false;
1956 1956
 		}
1957 1957
 		$primary_registration = $this->checkout->transaction->primary_registration();
1958
-		if ( ! $primary_registration instanceof EE_Registration ) {
1958
+		if ( ! $primary_registration instanceof EE_Registration) {
1959 1959
 			EE_Error::add_error(
1960 1960
 				sprintf(
1961 1961
 					__(
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 						'event_espresso'
1964 1964
 					),
1965 1965
 					'<br/>',
1966
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1966
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1967 1967
 				),
1968 1968
 				__FILE__,
1969 1969
 				__FUNCTION__,
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
 			);
1972 1972
 			return false;
1973 1973
 		}
1974
-		if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' )
1974
+		if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
1975 1975
 		       instanceof
1976 1976
 		       EE_Attendee
1977 1977
 		) {
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 						'event_espresso'
1983 1983
 					),
1984 1984
 					'<br/>',
1985
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1985
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1986 1986
 				),
1987 1987
 				__FILE__,
1988 1988
 				__FUNCTION__,
@@ -1991,9 +1991,9 @@  discard block
 block discarded – undo
1991 1991
 			return false;
1992 1992
 		}
1993 1993
 		/** @type EE_Registration_Processor $registration_processor */
1994
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1994
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1995 1995
 		// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1996
-		$registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration );
1996
+		$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
1997 1997
 		return true;
1998 1998
 	}
1999 1999
 
@@ -2008,22 +2008,22 @@  discard block
 block discarded – undo
2008 2008
 	 * @throws \EE_Error
2009 2009
 	 */
2010 2010
 	private function _get_payment_method_for_selected_method_of_payment() {
2011
-		if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) {
2011
+		if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
2012 2012
 			$this->_redirect_because_event_sold_out();
2013 2013
 			return null;
2014 2014
 		}
2015 2015
 		// get EE_Payment_Method object
2016
-		if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) {
2017
-			$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
2016
+		if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
2017
+			$payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
2018 2018
 		} else {
2019 2019
 			// load EEM_Payment_Method
2020
-			EE_Registry::instance()->load_model( 'Payment_Method' );
2020
+			EE_Registry::instance()->load_model('Payment_Method');
2021 2021
 			/** @type EEM_Payment_Method $EEM_Payment_Method */
2022 2022
 			$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
2023
-			$payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment );
2023
+			$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
2024 2024
 		}
2025 2025
 		// verify $payment_method
2026
-		if ( ! $payment_method instanceof EE_Payment_Method ) {
2026
+		if ( ! $payment_method instanceof EE_Payment_Method) {
2027 2027
 			// not a payment
2028 2028
 			EE_Error::add_error(
2029 2029
 				sprintf(
@@ -2032,7 +2032,7 @@  discard block
 block discarded – undo
2032 2032
 						'event_espresso'
2033 2033
 					),
2034 2034
 					'<br/>',
2035
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2035
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2036 2036
 				),
2037 2037
 				__FILE__,
2038 2038
 				__FUNCTION__,
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
 			return null;
2042 2042
 		}
2043 2043
 		// and verify it has a valid Payment_Method Type object
2044
-		if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) {
2044
+		if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
2045 2045
 			// not a payment
2046 2046
 			EE_Error::add_error(
2047 2047
 				sprintf(
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 						'event_espresso'
2051 2051
 					),
2052 2052
 					'<br/>',
2053
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2053
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2054 2054
 				),
2055 2055
 				__FILE__,
2056 2056
 				__FUNCTION__,
@@ -2071,29 +2071,29 @@  discard block
 block discarded – undo
2071 2071
 	 * @return    mixed    EE_Payment | boolean
2072 2072
 	 * @throws \EE_Error
2073 2073
 	 */
2074
-	private function _attempt_payment( EE_Payment_Method $payment_method ) {
2074
+	private function _attempt_payment(EE_Payment_Method $payment_method) {
2075 2075
 		$payment = null;
2076 2076
 		$this->checkout->transaction->save();
2077
-		$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
2078
-		if ( ! $payment_processor instanceof EE_Payment_Processor ) {
2077
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2078
+		if ( ! $payment_processor instanceof EE_Payment_Processor) {
2079 2079
 			return false;
2080 2080
 		}
2081 2081
 		try {
2082
-			$payment_processor->set_revisit( $this->checkout->revisit );
2082
+			$payment_processor->set_revisit($this->checkout->revisit);
2083 2083
 			// generate payment object
2084 2084
 			$payment = $payment_processor->process_payment(
2085 2085
 				$payment_method,
2086 2086
 				$this->checkout->transaction,
2087 2087
 				$this->checkout->amount_owing,
2088 2088
 				$this->checkout->billing_form,
2089
-				$this->_get_return_url( $payment_method ),
2089
+				$this->_get_return_url($payment_method),
2090 2090
 				'CART',
2091 2091
 				$this->checkout->admin_request,
2092 2092
 				true,
2093 2093
 				$this->reg_step_url()
2094 2094
 			);
2095
-		} catch ( Exception $e ) {
2096
-			$this->_handle_payment_processor_exception( $e );
2095
+		} catch (Exception $e) {
2096
+			$this->_handle_payment_processor_exception($e);
2097 2097
 		}
2098 2098
 		return $payment;
2099 2099
 	}
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 	 * @return void
2109 2109
 	 * @throws \EE_Error
2110 2110
 	 */
2111
-	protected function _handle_payment_processor_exception( Exception $e ) {
2111
+	protected function _handle_payment_processor_exception(Exception $e) {
2112 2112
 		EE_Error::add_error(
2113 2113
 			sprintf(
2114 2114
 				__(
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
 					'event_espresso'
2117 2117
 				),
2118 2118
 				'<br/>',
2119
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' ),
2119
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
2120 2120
 				$e->getMessage(),
2121 2121
 				$e->getFile(),
2122 2122
 				$e->getLine()
@@ -2137,9 +2137,9 @@  discard block
 block discarded – undo
2137 2137
 	 * @return string
2138 2138
 	 * @throws \EE_Error
2139 2139
 	 */
2140
-	protected function _get_return_url( EE_Payment_Method $payment_method ) {
2140
+	protected function _get_return_url(EE_Payment_Method $payment_method) {
2141 2141
 		$return_url = '';
2142
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
2142
+		switch ($payment_method->type_obj()->payment_occurs()) {
2143 2143
 			case EE_PMT_Base::offsite :
2144 2144
 				$return_url = add_query_arg(
2145 2145
 					array(
@@ -2168,12 +2168,12 @@  discard block
 block discarded – undo
2168 2168
 	 * @return EE_Payment | FALSE
2169 2169
 	 * @throws \EE_Error
2170 2170
 	 */
2171
-	private function _validate_payment( $payment = null ) {
2172
-		if ( $this->checkout->payment_method->is_off_line() ) {
2171
+	private function _validate_payment($payment = null) {
2172
+		if ($this->checkout->payment_method->is_off_line()) {
2173 2173
 			return true;
2174 2174
 		}
2175 2175
 		// verify payment object
2176
-		if ( ! $payment instanceof EE_Payment ) {
2176
+		if ( ! $payment instanceof EE_Payment) {
2177 2177
 			// not a payment
2178 2178
 			EE_Error::add_error(
2179 2179
 				sprintf(
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 						'event_espresso'
2183 2183
 					),
2184 2184
 					'<br/>',
2185
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2185
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2186 2186
 				),
2187 2187
 				__FILE__,
2188 2188
 				__FUNCTION__,
@@ -2203,27 +2203,27 @@  discard block
 block discarded – undo
2203 2203
 	 * @return bool
2204 2204
 	 * @throws \EE_Error
2205 2205
 	 */
2206
-	private function _post_payment_processing( $payment = null ) {
2206
+	private function _post_payment_processing($payment = null) {
2207 2207
 		// Off-Line payment?
2208
-		if ( $payment === true ) {
2208
+		if ($payment === true) {
2209 2209
 			//$this->_setup_redirect_for_next_step();
2210 2210
 			return true;
2211 2211
 		// On-Site payment?
2212
-		} else if ( $this->checkout->payment_method->is_on_site() ) {
2213
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) {
2212
+		} else if ($this->checkout->payment_method->is_on_site()) {
2213
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2214 2214
 				//$this->_setup_redirect_for_next_step();
2215 2215
 				$this->checkout->continue_reg = false;
2216 2216
 			}
2217 2217
 		// Off-Site payment?
2218
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
2218
+		} else if ($this->checkout->payment_method->is_off_site()) {
2219 2219
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2220
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ) {
2221
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
2220
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2221
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2222 2222
 				$this->checkout->redirect = true;
2223 2223
 				$this->checkout->redirect_form = $payment->redirect_form();
2224
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
2224
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2225 2225
 				// set JSON response
2226
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
2226
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2227 2227
 				// set cron job for finalizing the TXN
2228 2228
 				// in case the user does not return from the off-site gateway
2229 2229
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 					$this->checkout->transaction->ID()
2232 2232
 				);
2233 2233
 				// and lastly, let's bump the payment status to pending
2234
-				$payment->set_status( EEM_Payment::status_id_pending );
2234
+				$payment->set_status(EEM_Payment::status_id_pending);
2235 2235
 				$payment->save();
2236 2236
 			} else {
2237 2237
 				// not a payment
@@ -2243,7 +2243,7 @@  discard block
 block discarded – undo
2243 2243
 							'event_espresso'
2244 2244
 						),
2245 2245
 						'<br/>',
2246
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2246
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
2247 2247
 					),
2248 2248
 					__FILE__,
2249 2249
 					__FUNCTION__,
@@ -2281,21 +2281,21 @@  discard block
 block discarded – undo
2281 2281
 	 * @return bool
2282 2282
 	 * @throws \EE_Error
2283 2283
 	 */
2284
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
2284
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
2285 2285
 		// off-line payment? carry on
2286
-		if ( $payment_occurs === EE_PMT_Base::offline ) {
2286
+		if ($payment_occurs === EE_PMT_Base::offline) {
2287 2287
 			return true;
2288 2288
 		}
2289 2289
 		// verify payment validity
2290
-		if ( $payment instanceof EE_Payment ) {
2291
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
2290
+		if ($payment instanceof EE_Payment) {
2291
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2292 2292
 			$msg = $payment->gateway_response();
2293 2293
 			// check results
2294
-			switch ( $payment->status() ) {
2294
+			switch ($payment->status()) {
2295 2295
 				// good payment
2296 2296
 				case EEM_Payment::status_id_approved :
2297 2297
 					EE_Error::add_success(
2298
-						__( 'Your payment was processed successfully.', 'event_espresso' ),
2298
+						__('Your payment was processed successfully.', 'event_espresso'),
2299 2299
 						__FILE__,
2300 2300
 						__FUNCTION__,
2301 2301
 						__LINE__
@@ -2304,45 +2304,45 @@  discard block
 block discarded – undo
2304 2304
 					break;
2305 2305
 				// slow payment
2306 2306
 				case EEM_Payment::status_id_pending :
2307
-					if ( empty( $msg ) ) {
2307
+					if (empty($msg)) {
2308 2308
 						$msg = __(
2309 2309
 							'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2310 2310
 							'event_espresso'
2311 2311
 						);
2312 2312
 					}
2313
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
2313
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2314 2314
 					return true;
2315 2315
 					break;
2316 2316
 				// don't wanna payment
2317 2317
 				case EEM_Payment::status_id_cancelled :
2318
-					if ( empty( $msg ) ) {
2318
+					if (empty($msg)) {
2319 2319
 						$msg = _n(
2320 2320
 							'Payment cancelled. Please try again.',
2321 2321
 							'Payment cancelled. Please try again or select another method of payment.',
2322
-							count( $this->checkout->available_payment_methods ),
2322
+							count($this->checkout->available_payment_methods),
2323 2323
 							'event_espresso'
2324 2324
 						);
2325 2325
 					}
2326
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
2326
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2327 2327
 					return false;
2328 2328
 					break;
2329 2329
 				// not enough payment
2330 2330
 				case EEM_Payment::status_id_declined :
2331
-					if ( empty( $msg ) ) {
2331
+					if (empty($msg)) {
2332 2332
 						$msg = _n(
2333 2333
 							'We\'re sorry but your payment was declined. Please try again.',
2334 2334
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2335
-							count( $this->checkout->available_payment_methods ),
2335
+							count($this->checkout->available_payment_methods),
2336 2336
 							'event_espresso'
2337 2337
 						);
2338 2338
 					}
2339
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
2339
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2340 2340
 					return false;
2341 2341
 					break;
2342 2342
 				// bad payment
2343 2343
 				case EEM_Payment::status_id_failed :
2344
-					if ( ! empty( $msg ) ) {
2345
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2344
+					if ( ! empty($msg)) {
2345
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2346 2346
 						return false;
2347 2347
 					}
2348 2348
 					// default to error below
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
 		}
2352 2352
 		// off-site payment gateway responses are too unreliable, so let's just assume that
2353 2353
 		// the payment processing is just running slower than the registrant's request
2354
-		if ( $payment_occurs === EE_PMT_Base::offsite ) {
2354
+		if ($payment_occurs === EE_PMT_Base::offsite) {
2355 2355
 			return true;
2356 2356
 		}
2357 2357
 		EE_Error::add_error(
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 					'event_espresso'
2362 2362
 				),
2363 2363
 				'<br/>',
2364
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2364
+				EE_Registry::instance()->CFG->organization->get_pretty('email')
2365 2365
 			),
2366 2366
 			__FILE__,
2367 2367
 			__FUNCTION__,
@@ -2394,13 +2394,13 @@  discard block
 block discarded – undo
2394 2394
 	public function process_gateway_response() {
2395 2395
 		$payment = null;
2396 2396
 		// how have they chosen to pay?
2397
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
2397
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2398 2398
 		// get EE_Payment_Method object
2399
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
2399
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2400 2400
 			$this->checkout->continue_reg = false;
2401 2401
 			return false;
2402 2402
 		}
2403
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
2403
+		if ( ! $this->checkout->payment_method->is_off_site()) {
2404 2404
 			return false;
2405 2405
 		}
2406 2406
 		$this->_validate_offsite_return();
@@ -2414,23 +2414,23 @@  discard block
 block discarded – undo
2414 2414
 		//	true
2415 2415
 		//);
2416 2416
 		// verify TXN
2417
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
2417
+		if ($this->checkout->transaction instanceof EE_Transaction) {
2418 2418
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2419
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
2419
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
2420 2420
 				$this->checkout->continue_reg = false;
2421 2421
 				return false;
2422 2422
 			}
2423
-			$payment = $this->_process_off_site_payment( $gateway );
2424
-			$payment = $this->_process_cancelled_payments( $payment );
2425
-			$payment = $this->_validate_payment( $payment );
2423
+			$payment = $this->_process_off_site_payment($gateway);
2424
+			$payment = $this->_process_cancelled_payments($payment);
2425
+			$payment = $this->_validate_payment($payment);
2426 2426
 			// if payment was not declined by the payment gateway or cancelled by the registrant
2427
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
2427
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2428 2428
 				//$this->_setup_redirect_for_next_step();
2429 2429
 				// store that for later
2430 2430
 				$this->checkout->payment = $payment;
2431 2431
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2432 2432
 				// because we will complete this step during the IPN processing then
2433
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) {
2433
+				if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2434 2434
 					$this->set_completed();
2435 2435
 				}
2436 2436
 				return true;
@@ -2454,21 +2454,21 @@  discard block
 block discarded – undo
2454 2454
 	 * @throws \EE_Error
2455 2455
 	 */
2456 2456
 	private function _validate_offsite_return() {
2457
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
2458
-		if ( $TXN_ID !== $this->checkout->transaction->ID() ) {
2457
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2458
+		if ($TXN_ID !== $this->checkout->transaction->ID()) {
2459 2459
 			// Houston... we might have a problem
2460 2460
 			$invalid_TXN = false;
2461 2461
 			// first gather some info
2462
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
2462
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2463 2463
 			$primary_registrant = $valid_TXN instanceof EE_Transaction
2464 2464
 				? $valid_TXN->primary_registration()
2465 2465
 				: null;
2466 2466
 			// let's start by retrieving the cart for this TXN
2467
-			$cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction );
2468
-			if ( $cart instanceof EE_Cart ) {
2467
+			$cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2468
+			if ($cart instanceof EE_Cart) {
2469 2469
 				// verify that the current cart has tickets
2470 2470
 				$tickets = $cart->get_tickets();
2471
-				if ( empty( $tickets ) ) {
2471
+				if (empty($tickets)) {
2472 2472
 					$invalid_TXN = true;
2473 2473
 				}
2474 2474
 			} else {
@@ -2478,35 +2478,35 @@  discard block
 block discarded – undo
2478 2478
 				? $primary_registrant->session_ID()
2479 2479
 				: null;
2480 2480
 			// validate current Session ID and compare against valid TXN session ID
2481
-			if ( EE_Session::instance()->id() === null ) {
2481
+			if (EE_Session::instance()->id() === null) {
2482 2482
 				$invalid_TXN = true;
2483
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
2483
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
2484 2484
 				// WARNING !!!
2485 2485
 				// this could be PayPal sending back duplicate requests (ya they do that)
2486 2486
 				// or it **could** mean someone is simply registering AGAIN after having just done so
2487 2487
 				// so now we need to determine if this current TXN looks valid or not
2488 2488
 				// has this step even been started ?
2489
-				if ( $this->checkout->transaction->reg_step_completed( $this->slug() === false )
2489
+				if ($this->checkout->transaction->reg_step_completed($this->slug() === false)
2490 2490
 				) {
2491 2491
 					// really? you're half way through this reg step, but you never started it ?
2492 2492
 					$invalid_TXN = true;
2493 2493
 				}
2494 2494
 			}
2495
-			if ( $invalid_TXN ) {
2495
+			if ($invalid_TXN) {
2496 2496
 				// is the valid TXN completed ?
2497
-				if ( $valid_TXN instanceof EE_Transaction ) {
2497
+				if ($valid_TXN instanceof EE_Transaction) {
2498 2498
 					// has this step even been started ?
2499
-					$reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() );
2500
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
2499
+					$reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2500
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
2501 2501
 						// so it **looks** like this is a double request from PayPal
2502 2502
 						// so let's try to pick up where we left off
2503 2503
 						$this->checkout->transaction = $valid_TXN;
2504
-						$this->checkout->refresh_all_entities( true );
2504
+						$this->checkout->refresh_all_entities(true);
2505 2505
 						return;
2506 2506
 					}
2507 2507
 				}
2508 2508
 				// you appear to be lost?
2509
-				$this->_redirect_wayward_request( $primary_registrant );
2509
+				$this->_redirect_wayward_request($primary_registrant);
2510 2510
 			}
2511 2511
 		}
2512 2512
 	}
@@ -2521,14 +2521,14 @@  discard block
 block discarded – undo
2521 2521
 	 * @return bool
2522 2522
 	 * @throws \EE_Error
2523 2523
 	 */
2524
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
2525
-		if ( ! $primary_registrant instanceof EE_Registration ) {
2524
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
2525
+		if ( ! $primary_registrant instanceof EE_Registration) {
2526 2526
 			// try redirecting based on the current TXN
2527 2527
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2528 2528
 				? $this->checkout->transaction->primary_registration()
2529 2529
 				: null;
2530 2530
 		}
2531
-		if ( ! $primary_registrant instanceof EE_Registration ) {
2531
+		if ( ! $primary_registrant instanceof EE_Registration) {
2532 2532
 			EE_Error::add_error(
2533 2533
 				sprintf(
2534 2534
 					__(
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 						'event_espresso'
2537 2537
 					),
2538 2538
 					'<br/>',
2539
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2539
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2540 2540
 				),
2541 2541
 				__FILE__,
2542 2542
 				__FUNCTION__,
@@ -2567,17 +2567,17 @@  discard block
 block discarded – undo
2567 2567
 	 * @return \EE_Payment
2568 2568
 	 * @throws \EE_Error
2569 2569
 	 */
2570
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
2570
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
2571 2571
 		try {
2572 2572
 			$request_data = \EE_Registry::instance()->REQ->params();
2573 2573
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2574 2574
 			$this->set_handle_IPN_in_this_request(
2575
-				$gateway->handle_IPN_in_this_request( $request_data, false )
2575
+				$gateway->handle_IPN_in_this_request($request_data, false)
2576 2576
 			);
2577
-			if ( $this->handle_IPN_in_this_request() ) {
2577
+			if ($this->handle_IPN_in_this_request()) {
2578 2578
 				// get payment details and process results
2579 2579
 				/** @type EE_Payment_Processor $payment_processor */
2580
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
2580
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2581 2581
 				$payment = $payment_processor->process_ipn(
2582 2582
 					$request_data,
2583 2583
 					$this->checkout->transaction,
@@ -2590,14 +2590,14 @@  discard block
 block discarded – undo
2590 2590
 				$payment = $this->checkout->transaction->last_payment();
2591 2591
 				//$payment_source = 'last_payment';
2592 2592
 			}
2593
-		} catch ( Exception $e ) {
2593
+		} catch (Exception $e) {
2594 2594
 			// let's just eat the exception and try to move on using any previously set payment info
2595 2595
 			$payment = $this->checkout->transaction->last_payment();
2596 2596
 			//$payment_source = 'last_payment after Exception';
2597 2597
 			// but if we STILL don't have a payment object
2598
-			if ( ! $payment instanceof EE_Payment ) {
2598
+			if ( ! $payment instanceof EE_Payment) {
2599 2599
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2600
-				$this->_handle_payment_processor_exception( $e );
2600
+				$this->_handle_payment_processor_exception($e);
2601 2601
 			}
2602 2602
 		}
2603 2603
 		// DEBUG LOG
@@ -2622,13 +2622,13 @@  discard block
 block discarded – undo
2622 2622
 	 * @return EE_Payment | FALSE
2623 2623
 	 * @throws \EE_Error
2624 2624
 	 */
2625
-	private function _process_cancelled_payments( $payment = null ) {
2625
+	private function _process_cancelled_payments($payment = null) {
2626 2626
 		if (
2627 2627
 			$payment instanceof EE_Payment
2628
-			&& isset( $_REQUEST['ee_cancel_payment'] )
2628
+			&& isset($_REQUEST['ee_cancel_payment'])
2629 2629
 			&& $payment->status() === EEM_Payment::status_id_failed
2630 2630
 		) {
2631
-			$payment->set_status( EEM_Payment::status_id_cancelled );
2631
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2632 2632
 		}
2633 2633
 		return $payment;
2634 2634
 	}
@@ -2645,14 +2645,14 @@  discard block
 block discarded – undo
2645 2645
 	public function get_transaction_details_for_gateways() {
2646 2646
 		$txn_details = array();
2647 2647
 		// ya gotta make a choice man
2648
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
2648
+		if (empty($this->checkout->selected_method_of_payment)) {
2649 2649
 			$txn_details = array(
2650
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
2650
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
2651 2651
 			);
2652 2652
 		}
2653 2653
 		// get EE_Payment_Method object
2654 2654
 		if (
2655
-			empty( $txn_details )
2655
+			empty($txn_details)
2656 2656
 			&&
2657 2657
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2658 2658
 		) {
@@ -2664,8 +2664,8 @@  discard block
 block discarded – undo
2664 2664
 				)
2665 2665
 			);
2666 2666
 		}
2667
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
2668
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
2667
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2668
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2669 2669
 			$txn_details = array(
2670 2670
 				'TXN_ID'         => $this->checkout->transaction->ID(),
2671 2671
 				'TXN_timestamp'  => $this->checkout->transaction->datetime(),
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
 				'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2677 2677
 				'payment_amount' => $this->checkout->amount_owing,
2678 2678
 				'return_url'     => $return_url,
2679
-				'cancel_url'     => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
2679
+				'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2680 2680
 				'notify_url'     => EE_Config::instance()->core->txn_page_url(
2681 2681
 					array(
2682 2682
 						'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -2685,7 +2685,7 @@  discard block
 block discarded – undo
2685 2685
 				)
2686 2686
 			);
2687 2687
 		}
2688
-		echo wp_json_encode( $txn_details );
2688
+		echo wp_json_encode($txn_details);
2689 2689
 		exit();
2690 2690
 	}
2691 2691
 
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
     public function __sleep()
2703 2703
     {
2704 2704
         // remove the reg form and the checkout
2705
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2705
+        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2706 2706
     }
2707 2707
 
2708 2708
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Resource_Manager.lib.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @return void
881 881
 	 */
882 882
 	public function deactivate_messenger( $messenger_name ) {
883
-        $this->_initialize_collections();
884
-        if ( $messenger_name instanceof EE_messenger ) {
883
+		$this->_initialize_collections();
884
+		if ( $messenger_name instanceof EE_messenger ) {
885 885
 			$messenger_name = $messenger_name->name;
886 886
 		}
887 887
 		unset( $this->_active_messengers[ $messenger_name ] );
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 	 * @param  string $message_type_name name of message type being deactivated
898 898
 	 */
899 899
 	public function deactivate_message_type( $message_type_name ) {
900
-        $this->_initialize_collections();
900
+		$this->_initialize_collections();
901 901
 		if ( $message_type_name instanceof EE_message_type ) {
902 902
 			$message_type_name = $message_type_name->name;
903 903
 		}
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 	 * @param string $messenger_name     Name of messenger the message type is being deactivated for.
928 928
 	 */
929 929
 	public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) {
930
-        $this->_initialize_collections();
930
+		$this->_initialize_collections();
931 931
 		if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
932 932
 			unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] );
933 933
 		}
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 * @return void
135 135
 	 */
136 136
 	protected function _initialize_collections() {
137
-		if ( $this->_initialized ) {
137
+		if ($this->_initialized) {
138 138
 			return;
139 139
 		}
140 140
 		$this->_initialized = true;
141 141
 		$this->_messenger_collection_loader->load_messengers_from_folder();
142 142
 		$this->_message_type_collection_loader->load_message_types_from_folder();
143
-		$this->get_has_activated_messengers_option( true );
143
+		$this->get_has_activated_messengers_option(true);
144 144
 		$this->_set_active_messengers_and_message_types();
145 145
 	}
146 146
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @param string $messenger_name
171 171
 	 * @return \EE_messenger
172 172
 	 */
173
-	public function get_messenger( $messenger_name ) {
174
-		return $this->messenger_collection()->get_by_info( $messenger_name );
173
+	public function get_messenger($messenger_name) {
174
+		return $this->messenger_collection()->get_by_info($messenger_name);
175 175
 	}
176 176
 
177 177
 
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 * @param string $messenger
183 183
 	 * @return EE_messenger | null
184 184
 	 */
185
-	public function get_active_messenger( $messenger ) {
185
+	public function get_active_messenger($messenger) {
186 186
 		$this->_initialize_collections();
187
-		return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null;
187
+		return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null;
188 188
 	}
189 189
 
190 190
 
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
 	 * @return \EE_messenger[]
194 194
 	 */
195 195
 	public function installed_messengers() {
196
-		if ( empty( $this->_installed_messengers ) ) {
196
+		if (empty($this->_installed_messengers)) {
197 197
 			$this->_installed_messengers = array();
198 198
 			$this->messenger_collection()->rewind();
199
-			while ( $this->messenger_collection()->valid() ) {
200
-				$this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current();
199
+			while ($this->messenger_collection()->valid()) {
200
+				$this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current();
201 201
 				$this->messenger_collection()->next();
202 202
 			}
203 203
 		}
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 	 * @return \EE_messenger
212 212
 	 * @throws \EE_Error
213 213
 	 */
214
-	public function valid_messenger( $messenger_name ) {
215
-		$messenger = $this->get_messenger( $messenger_name );
216
-		if ( $messenger instanceof EE_messenger ) {
214
+	public function valid_messenger($messenger_name) {
215
+		$messenger = $this->get_messenger($messenger_name);
216
+		if ($messenger instanceof EE_messenger) {
217 217
 			return $messenger;
218 218
 		}
219 219
 		throw new EE_Error(
220 220
 			sprintf(
221
-				__( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ),
221
+				__('The "%1$s" messenger is either invalid or not installed', 'event_espresso'),
222 222
 				$messenger_name
223 223
 			)
224 224
 		);
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	 * @param string $message_type_name
251 251
 	 * @return \EE_message_type
252 252
 	 */
253
-	public function get_message_type( $message_type_name ) {
254
-		return $this->message_type_collection()->get_by_info( $message_type_name );
253
+	public function get_message_type($message_type_name) {
254
+		return $this->message_type_collection()->get_by_info($message_type_name);
255 255
 	}
256 256
 
257 257
 
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 	 * @param string $message_type_name
264 264
 	 * @return \EE_message_type|null
265 265
 	 */
266
-	public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) {
267
-		return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name )
268
-			? $this->get_message_type( $message_type_name )
266
+	public function get_active_message_type_for_messenger($messenger_name, $message_type_name) {
267
+		return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name)
268
+			? $this->get_message_type($message_type_name)
269 269
 			: null;
270 270
 	}
271 271
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return bool
281 281
 	 */
282
-	public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) {
282
+	public function is_message_type_active_for_messenger($messenger_name, $message_type_name) {
283 283
 		$this->_initialize_collections();
284
-		return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] );
284
+		return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]);
285 285
 	}
286 286
 
287 287
 
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 	 * @param string $messenger_name  the name of the messenger to check if active.
293 293
 	 * @return bool
294 294
 	 */
295
-	public function is_messenger_active( $messenger_name ) {
295
+	public function is_messenger_active($messenger_name) {
296 296
 		$this->_initialize_collections();
297
-		return ! empty( $this->_active_message_types[ $messenger_name ] );
297
+		return ! empty($this->_active_message_types[$messenger_name]);
298 298
 	}
299 299
 
300 300
 
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 	 * @param string $message_type_name  The slug of the message type getting the settings for.
306 306
 	 * @return array
307 307
 	 */
308
-	public function get_message_type_settings_for_messenger( $messenger_name, $message_type_name ) {
308
+	public function get_message_type_settings_for_messenger($messenger_name, $message_type_name) {
309 309
 		$settings = array();
310
-		if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
311
-			$settings =  isset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] )
312
-				? $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings']
310
+		if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
311
+			$settings = isset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'])
312
+				? $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings']
313 313
 				: array();
314 314
 		}
315 315
 		return $settings;
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	 * @param string $messenger_name
325 325
 	 * @return bool
326 326
 	 */
327
-	public function messenger_has_active_message_types( $messenger_name ) {
327
+	public function messenger_has_active_message_types($messenger_name) {
328 328
 		$this->_initialize_collections();
329 329
 		return
330
-			! empty( $this->_active_message_types[ $messenger_name ] )
331
-			&& ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ] );
330
+			! empty($this->_active_message_types[$messenger_name])
331
+			&& ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types']);
332 332
 	}
333 333
 
334 334
 
@@ -341,15 +341,15 @@  discard block
 block discarded – undo
341 341
 	 * @param string $messenger_name The messenger being checked
342 342
 	 * @return EE_message_type[]|array    (empty array if no active_message_types)
343 343
 	 */
344
-	public function get_active_message_types_for_messenger( $messenger_name ) {
344
+	public function get_active_message_types_for_messenger($messenger_name) {
345 345
 		$message_types = array();
346
-		if ( ! $this->messenger_has_active_message_types( $messenger_name ) ) {
346
+		if ( ! $this->messenger_has_active_message_types($messenger_name)) {
347 347
 			return $message_types;
348 348
 		}
349 349
 		$installed_message_types = $this->installed_message_types();
350
-		foreach ( $installed_message_types as $message_type_name => $message_type ) {
351
-			if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
352
-				$message_types[ $message_type_name ] = $message_type;
350
+		foreach ($installed_message_types as $message_type_name => $message_type) {
351
+			if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
352
+				$message_types[$message_type_name] = $message_type;
353 353
 			}
354 354
 		}
355 355
 		return $message_types;
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 	public function list_of_active_message_types() {
368 368
 		$active_message_type_names = array();
369 369
 		$this->_initialize_collections();
370
-		foreach ( $this->_active_message_types as $messenger => $messenger_settings ) {
371
-			if ( ! isset( $messenger_settings['settings'][ $messenger . '-message_types' ] ) ) {
370
+		foreach ($this->_active_message_types as $messenger => $messenger_settings) {
371
+			if ( ! isset($messenger_settings['settings'][$messenger.'-message_types'])) {
372 372
 				continue;
373 373
 			}
374
-			foreach ( $messenger_settings['settings'][ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) {
375
-				if ( ! in_array( $message_type_name, $active_message_type_names ) ) {
374
+			foreach ($messenger_settings['settings'][$messenger.'-message_types'] as $message_type_name => $message_type_config) {
375
+				if ( ! in_array($message_type_name, $active_message_type_names)) {
376 376
 					$active_message_type_names[] = $message_type_name;
377 377
 				}
378 378
 			}
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
 		$active_message_types = array();
393 393
 		$installed_message_types = $this->installed_message_types();
394 394
 		$active_message_type_names = $this->list_of_active_message_types();
395
-		foreach ( $active_message_type_names as $active_message_type_name ) {
396
-			if ( isset( $installed_message_types[ $active_message_type_name ] ) ) {
397
-				$active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ];
395
+		foreach ($active_message_type_names as $active_message_type_name) {
396
+			if (isset($installed_message_types[$active_message_type_name])) {
397
+				$active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name];
398 398
 			}
399 399
 		}
400 400
 		return $active_message_types;
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 	 * @return \EE_message_type[]
407 407
 	 */
408 408
 	public function installed_message_types() {
409
-		if ( empty( $this->_installed_message_types ) ) {
409
+		if (empty($this->_installed_message_types)) {
410 410
 			$this->message_type_collection()->rewind();
411
-			while ( $this->message_type_collection()->valid() ) {
412
-				$this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current();
411
+			while ($this->message_type_collection()->valid()) {
412
+				$this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current();
413 413
 				$this->message_type_collection()->next();
414 414
 			}
415 415
 		}
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 	 * @return \EE_message_type
423 423
 	 * @throws \EE_Error
424 424
 	 */
425
-	public function valid_message_type( $message_type_name ) {
426
-		$message_type = $this->get_message_type( $message_type_name );
427
-		if ( $message_type instanceof EE_message_type ) {
425
+	public function valid_message_type($message_type_name) {
426
+		$message_type = $this->get_message_type($message_type_name);
427
+		if ($message_type instanceof EE_message_type) {
428 428
 			return $message_type;
429 429
 		}
430 430
 		throw new EE_Error(
431 431
 			sprintf(
432
-				__( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ),
432
+				__('The "%1$s" message type is either invalid or not installed', 'event_espresso'),
433 433
 				$message_type_name
434 434
 			)
435 435
 		);
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 	 * @return boolean
446 446
 	 * @throws \EE_Error
447 447
 	 */
448
-	public function valid_message_type_for_messenger( EE_messenger $messenger, $message_type_name ) {
448
+	public function valid_message_type_for_messenger(EE_messenger $messenger, $message_type_name) {
449 449
 		$valid_message_types = $messenger->get_valid_message_types();
450
-		if ( ! in_array( $message_type_name, $valid_message_types ) ) {
450
+		if ( ! in_array($message_type_name, $valid_message_types)) {
451 451
 			throw new EE_Error(
452 452
 				sprintf(
453 453
 					__(
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 	 *
475 475
 	 * @return array
476 476
 	 */
477
-	public function get_active_messengers_option( $reset = false) {
478
-		if ( $reset ) {
479
-			$this->_active_message_types = get_option( 'ee_active_messengers', array() );
477
+	public function get_active_messengers_option($reset = false) {
478
+		if ($reset) {
479
+			$this->_active_message_types = get_option('ee_active_messengers', array());
480 480
 		}
481 481
 		return $this->_active_message_types;
482 482
 	}
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 	 *                                 representing this data is used.
491 491
 	 * @return bool FALSE if not updated, TRUE if updated.
492 492
 	 */
493
-	public function update_active_messengers_option( $active_messenger_settings = array() ) {
494
-		$active_messenger_settings = empty( $active_messenger_settings ) ? $this->_active_message_types : $active_messenger_settings;
493
+	public function update_active_messengers_option($active_messenger_settings = array()) {
494
+		$active_messenger_settings = empty($active_messenger_settings) ? $this->_active_message_types : $active_messenger_settings;
495 495
 		//make sure _active_message_types is updated (this is the internal cache for the settings).
496 496
 		$this->_active_message_types = $active_messenger_settings;
497
-		return update_option( 'ee_active_messengers', $active_messenger_settings );
497
+		return update_option('ee_active_messengers', $active_messenger_settings);
498 498
 	}
499 499
 
500 500
 
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
 	 *
510 510
 	 * @return array
511 511
 	 */
512
-	public function get_has_activated_messengers_option( $reset = false ) {
513
-		if ( $reset || empty( $this->_has_activated_messengers_and_message_types ) ) {
514
-			$this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() );
512
+	public function get_has_activated_messengers_option($reset = false) {
513
+		if ($reset || empty($this->_has_activated_messengers_and_message_types)) {
514
+			$this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array());
515 515
 		}
516 516
 		return $this->_has_activated_messengers_and_message_types;
517 517
 	}
@@ -526,15 +526,15 @@  discard block
 block discarded – undo
526 526
 	 *
527 527
 	 * @return bool FALSE if not updated, TRUE if updated.
528 528
 	 */
529
-	public function update_has_activated_messengers_option( $has_activated_messengers = array() ) {
529
+	public function update_has_activated_messengers_option($has_activated_messengers = array()) {
530 530
 		//make sure the option has been retrieved from first so we don't overwrite it accidentally.
531
-		if ( empty( $has_activated_messengers ) && empty( $this->_has_activated_messengers_and_message_types ) ) {
531
+		if (empty($has_activated_messengers) && empty($this->_has_activated_messengers_and_message_types)) {
532 532
 			$this->get_has_activated_messengers_option();
533 533
 		}
534
-		$has_activated_messengers = empty( $has_activated_messengers )
534
+		$has_activated_messengers = empty($has_activated_messengers)
535 535
 			? $this->_has_activated_messengers_and_message_types
536 536
 			: $has_activated_messengers;
537
-		return update_option( 'ee_has_activated_messenger', $has_activated_messengers );
537
+		return update_option('ee_has_activated_messenger', $has_activated_messengers);
538 538
 	}
539 539
 
540 540
 
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 		//echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n";
557 557
 		// list of activated messengers as set via the admin
558 558
 		// note calling `get_active_messengers_options` also initializes the _active_message_types property.
559
-		$this->get_active_messengers_option( true );
560
-		$this->ensure_messengers_are_active( array(), false, true );
559
+		$this->get_active_messengers_option(true);
560
+		$this->ensure_messengers_are_active(array(), false, true);
561 561
 		$this->update_active_messengers_option();
562 562
 		$this->update_has_activated_messengers_option();
563 563
 	}
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	 * @param bool   $update_option  Whether to update the option in the db or not.
576 576
 	 * @return boolean true if either already active or successfully activated.
577 577
 	 */
578
-	public function ensure_messenger_is_active( $messenger_name, $update_option = true ) {
579
-		if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) {
578
+	public function ensure_messenger_is_active($messenger_name, $update_option = true) {
579
+		if ( ! isset($this->_active_messengers[$messenger_name])) {
580 580
 			try {
581
-				$this->activate_messenger( $messenger_name, array(), $update_option );
582
-			} catch( EE_Error $e ) {
581
+				$this->activate_messenger($messenger_name, array(), $update_option);
582
+			} catch (EE_Error $e) {
583 583
 				EE_Error::add_error(
584 584
 					$e->getMessage(),
585 585
 					__FILE__,
@@ -606,25 +606,25 @@  discard block
 block discarded – undo
606 606
 	 *                                and a messenger is indicated as active, but is NOT installed, then it will automatically be
607 607
 	 *                                deactivated.
608 608
 	 */
609
-	public function ensure_messengers_are_active( $messenger_names = array(), $update_option = true, $verify = false ) {
610
-		$messenger_names = empty( $messenger_names ) ? array_keys( $this->_active_message_types ) : $messenger_names;
609
+	public function ensure_messengers_are_active($messenger_names = array(), $update_option = true, $verify = false) {
610
+		$messenger_names = empty($messenger_names) ? array_keys($this->_active_message_types) : $messenger_names;
611 611
 
612 612
 		$not_installed = array();
613
-		foreach( $messenger_names as $messenger_name ) {
614
-			if ( $verify && ! $this->messenger_collection()->has_by_name( $messenger_name ) ) {
613
+		foreach ($messenger_names as $messenger_name) {
614
+			if ($verify && ! $this->messenger_collection()->has_by_name($messenger_name)) {
615 615
 				$not_installed[] = $messenger_name;
616
-				$this->deactivate_messenger( $messenger_name );
616
+				$this->deactivate_messenger($messenger_name);
617 617
 				continue;
618 618
 			}
619
-			$this->ensure_messenger_is_active( $messenger_name, $update_option );
619
+			$this->ensure_messenger_is_active($messenger_name, $update_option);
620 620
 		}
621 621
 
622
-		if ( ! empty( $not_installed_messenger ) ) {
622
+		if ( ! empty($not_installed_messenger)) {
623 623
 			EE_Error::add_error(
624 624
 				sprintf(
625
-					__( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ),
625
+					__('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'),
626 626
 					'<br />',
627
-					implode( ', ', $not_installed_messenger )
627
+					implode(', ', $not_installed_messenger)
628 628
 				),
629 629
 				__FILE__, __FUNCTION__, __LINE__
630 630
 			);
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
 	 * @return bool  Returns true if already is active or if was activated successfully.
644 644
 	 * @throws \EE_Error
645 645
 	 */
646
-	public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) {
646
+	public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) {
647 647
 		// grab the messenger to work with.
648
-		$messenger = $this->valid_messenger( $messenger_name );
649
-		if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) {
648
+		$messenger = $this->valid_messenger($messenger_name);
649
+		if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) {
650 650
 			//ensure messenger is active (that's an inherent coupling between active message types and the
651 651
 			//messenger they are being activated for.
652 652
 			try {
653
-				if ( ! $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
653
+				if ( ! $this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
654 654
 					//all is good so let's just get it active
655
-					$this->activate_messenger( $messenger_name, array( $message_type_name ), $update_option );
655
+					$this->activate_messenger($messenger_name, array($message_type_name), $update_option);
656 656
 				}
657
-			} catch( EE_Error $e ) {
657
+			} catch (EE_Error $e) {
658 658
 				EE_Error::add_error(
659 659
 					$e->getMessage(),
660 660
 					__FILE__,
@@ -678,14 +678,14 @@  discard block
 block discarded – undo
678 678
 	 * @param string $messenger_name      The name of the messenger that the message types are to be activated on.
679 679
 	 * @param bool   $update_option       Whether to persist the activation to the database or not (default true).
680 680
 	 */
681
-	public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) {
681
+	public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) {
682 682
 		$message_type_names = (array) $message_type_names;
683
-		foreach ( $message_type_names as $message_type_name ) {
683
+		foreach ($message_type_names as $message_type_name) {
684 684
 			// note, intentionally not updating option here because we're in a loop.
685 685
 			// We'll follow the instructions of the incoming $update_option argument after the loop.
686
-			$this->ensure_message_type_is_active( $message_type_name, $messenger_name, false );
686
+			$this->ensure_message_type_is_active($message_type_name, $messenger_name, false);
687 687
 		}
688
-		if ( $update_option ) {
688
+		if ($update_option) {
689 689
 			$this->update_active_messengers_option();
690 690
 			$this->update_has_activated_messengers_option();
691 691
 		}
@@ -712,24 +712,24 @@  discard block
 block discarded – undo
712 712
 	) {
713 713
 		$templates = array();
714 714
 		// grab the messenger to work with.
715
-		$messenger = $this->messenger_collection()->get_by_info( $messenger_name );
715
+		$messenger = $this->messenger_collection()->get_by_info($messenger_name);
716 716
 		// it's inactive. Activate it.
717
-		if ( $messenger instanceof EE_messenger ) {
718
-			$this->_active_messengers[ $messenger->name ] = $messenger;
717
+		if ($messenger instanceof EE_messenger) {
718
+			$this->_active_messengers[$messenger->name] = $messenger;
719 719
 			//activate incoming message types set to be activated with messenger.
720
-			$message_type_names = $this->_activate_message_types( $messenger, $message_type_names );
720
+			$message_type_names = $this->_activate_message_types($messenger, $message_type_names);
721 721
 			// setup any initial settings for the messenger if necessary.
722
-			$this->add_settings_for_messenger( $messenger->name );
723
-			if ( $update_active_messengers_option ) {
722
+			$this->add_settings_for_messenger($messenger->name);
723
+			if ($update_active_messengers_option) {
724 724
 				$this->update_active_messengers_option();
725 725
 				$this->update_has_activated_messengers_option();
726 726
 			}
727 727
 			//generate new templates if necessary and ensure all related templates that are already in the database are
728 728
 			//marked active.  Note, this will also deactivate a message type for a messenger if the template
729 729
 			//cannot be successfully created during its attempt (only happens for global template attempts).
730
-			if ( ! empty( $message_type_names ) ) {
731
-				$templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true );
732
-				EEH_MSG_Template::update_to_active( array( $messenger->name ), $message_type_names );
730
+			if ( ! empty($message_type_names)) {
731
+				$templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true);
732
+				EEH_MSG_Template::update_to_active(array($messenger->name), $message_type_names);
733 733
 			}
734 734
 		}
735 735
 		return $templates;
@@ -748,29 +748,29 @@  discard block
 block discarded – undo
748 748
 	 *
749 749
 	 * @return array
750 750
 	 */
751
-	protected function _activate_message_types( EE_messenger $messenger, $message_type_names = array() ) {
751
+	protected function _activate_message_types(EE_messenger $messenger, $message_type_names = array()) {
752 752
 		//If $message_type_names is empty, AND $this->_active_message_types is empty, then that means
753 753
 		//things have never been initialized (which should happen on EEH_Activation::generate_message_templates).
754 754
 		//So ONLY then do we need to actually grab defaults and cycle through them.  Otherwise we
755 755
 		//only override _active_message_types when an explicit array of $message_type_names has been provided.
756
-		$message_type_names = empty( $message_type_names ) && ! isset( $this->_active_message_types[ $messenger->name ] )
756
+		$message_type_names = empty($message_type_names) && ! isset($this->_active_message_types[$messenger->name])
757 757
 			? $messenger->get_default_message_types()
758 758
 			: (array) $message_type_names;
759 759
 
760 760
 		//now we ALWAYS need to make sure that the messenger is active for the message types we're activating!
761
-		if ( ! isset( $this->_active_message_types[ $messenger->name ] ) ) {
762
-			$this->_active_message_types[ $messenger->name ]['settings'] = array();
761
+		if ( ! isset($this->_active_message_types[$messenger->name])) {
762
+			$this->_active_message_types[$messenger->name]['settings'] = array();
763 763
 		}
764 764
 
765
-		if ( $message_type_names ) {
765
+		if ($message_type_names) {
766 766
 			// cycle thru message types
767
-			foreach ( $message_type_names as $message_type_name ) {
767
+			foreach ($message_type_names as $message_type_name) {
768 768
 				//only register the message type as active IF it isn't already active
769 769
 				//and if its actually installed.
770 770
 				if (
771
-					! $this->is_message_type_active_for_messenger( $messenger->name, $message_type_name )
771
+					! $this->is_message_type_active_for_messenger($messenger->name, $message_type_name)
772 772
 				) {
773
-					$this->add_settings_for_message_type( $messenger->name, $message_type_name );
773
+					$this->add_settings_for_message_type($messenger->name, $message_type_name);
774 774
 					$this->_set_messenger_has_activated_message_type(
775 775
 						$messenger,
776 776
 						$message_type_name
@@ -793,24 +793,24 @@  discard block
 block discarded – undo
793 793
 	 * @param  string       $message_type_name The name of the message type adding the settings for
794 794
 	 * @param  array        $new_settings     Any new settings being set for the message type and messenger
795 795
 	 */
796
-	public function add_settings_for_message_type( $messenger_name, $message_type_name, $new_settings = array() ) {
796
+	public function add_settings_for_message_type($messenger_name, $message_type_name, $new_settings = array()) {
797 797
 		// get installed message type from collection
798
-		$message_type = $this->message_type_collection()->get_by_info( $message_type_name );
799
-		$existing_settings = $this->get_message_type_settings_for_messenger( $messenger_name, $message_type_name );
798
+		$message_type = $this->message_type_collection()->get_by_info($message_type_name);
799
+		$existing_settings = $this->get_message_type_settings_for_messenger($messenger_name, $message_type_name);
800 800
 		//we need to setup any initial settings for message types
801
-		if ( $message_type instanceof EE_message_type ) {
801
+		if ($message_type instanceof EE_message_type) {
802 802
 			$default_settings = $message_type->get_admin_settings_fields();
803
-			foreach ( $default_settings as $field => $values ) {
804
-				if ( isset( $new_settings[ $field ] ) ) {
805
-					$existing_settings[ $field ] = $new_settings[ $field ];
803
+			foreach ($default_settings as $field => $values) {
804
+				if (isset($new_settings[$field])) {
805
+					$existing_settings[$field] = $new_settings[$field];
806 806
 					continue;
807 807
 				}
808
-				if ( ! isset( $existing_settings[ $field ] ) ) {
809
-					$existing_settings[ $field ] = $values['default'];
808
+				if ( ! isset($existing_settings[$field])) {
809
+					$existing_settings[$field] = $values['default'];
810 810
 				}
811 811
 			}
812 812
 		}
813
-		$this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] = $existing_settings;
813
+		$this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] = $existing_settings;
814 814
 	}
815 815
 
816 816
 
@@ -823,20 +823,20 @@  discard block
 block discarded – undo
823 823
 	 * @param \EE_messenger $messenger
824 824
 	 * @param string        $message_type_name
825 825
 	 */
826
-	protected function _set_messenger_has_activated_message_type( EE_messenger $messenger, $message_type_name ) {
826
+	protected function _set_messenger_has_activated_message_type(EE_messenger $messenger, $message_type_name) {
827 827
 
828 828
 		//if _has_activated_messengers_and_message_types is empty then lets ensure its initialized
829
-		if ( empty( $this->_has_activated_messengers_and_message_types ) ) {
829
+		if (empty($this->_has_activated_messengers_and_message_types)) {
830 830
 			$this->get_has_activated_messengers_option();
831 831
 		}
832 832
 
833 833
 		// make sure this messenger has a record in the has_activated array
834
-		if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) {
835
-			$this->_has_activated_messengers_and_message_types[ $messenger->name ] = array();
834
+		if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) {
835
+			$this->_has_activated_messengers_and_message_types[$messenger->name] = array();
836 836
 		}
837 837
 		// check if message type has already been added
838
-		if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) {
839
-			$this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name;
838
+		if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) {
839
+			$this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name;
840 840
 		}
841 841
 	}
842 842
 
@@ -851,20 +851,20 @@  discard block
 block discarded – undo
851 851
 	 * @param string        $messenger_name The name of the messenger the settings is being added for.
852 852
 	 * @param array         $new_settings   An array of settings to update the existing settings.
853 853
 	 */
854
-	public function add_settings_for_messenger( $messenger_name, $new_settings = array() ) {
855
-		$messenger = $this->get_messenger( $messenger_name );
856
-		if ( $messenger instanceof EE_messenger ) {
854
+	public function add_settings_for_messenger($messenger_name, $new_settings = array()) {
855
+		$messenger = $this->get_messenger($messenger_name);
856
+		if ($messenger instanceof EE_messenger) {
857 857
 			$msgr_settings = $messenger->get_admin_settings_fields();
858
-			if ( ! empty( $msgr_settings ) ) {
859
-				foreach ( $msgr_settings as $field => $value ) {
858
+			if ( ! empty($msgr_settings)) {
859
+				foreach ($msgr_settings as $field => $value) {
860 860
 					//is there a new setting for this?
861
-					if ( isset( $new_settings[ $field ] ) ) {
862
-						$this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $new_settings[ $field ];
861
+					if (isset($new_settings[$field])) {
862
+						$this->_active_message_types[$messenger->name]['settings'][$field] = $new_settings[$field];
863 863
 						continue;
864 864
 					}
865 865
 					//only set the default if it isn't already set.
866
-					if ( ! isset( $this->_active_message_types[ $messenger->name ]['settings'][ $field ] ) ) {
867
-						$this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $value;
866
+					if ( ! isset($this->_active_message_types[$messenger->name]['settings'][$field])) {
867
+						$this->_active_message_types[$messenger->name]['settings'][$field] = $value;
868 868
 					}
869 869
 				}
870 870
 			}
@@ -879,14 +879,14 @@  discard block
 block discarded – undo
879 879
 	 * @param  string|EE_messenger $messenger_name name of messenger
880 880
 	 * @return void
881 881
 	 */
882
-	public function deactivate_messenger( $messenger_name ) {
882
+	public function deactivate_messenger($messenger_name) {
883 883
         $this->_initialize_collections();
884
-        if ( $messenger_name instanceof EE_messenger ) {
884
+        if ($messenger_name instanceof EE_messenger) {
885 885
 			$messenger_name = $messenger_name->name;
886 886
 		}
887
-		unset( $this->_active_messengers[ $messenger_name ] );
888
-		unset( $this->_active_message_types[ $messenger_name ] );
889
-		$this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name );
887
+		unset($this->_active_messengers[$messenger_name]);
888
+		unset($this->_active_message_types[$messenger_name]);
889
+		$this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name);
890 890
 		$this->update_active_messengers_option();
891 891
 	}
892 892
 
@@ -896,22 +896,22 @@  discard block
 block discarded – undo
896 896
 	 *
897 897
 	 * @param  string $message_type_name name of message type being deactivated
898 898
 	 */
899
-	public function deactivate_message_type( $message_type_name ) {
899
+	public function deactivate_message_type($message_type_name) {
900 900
         $this->_initialize_collections();
901
-		if ( $message_type_name instanceof EE_message_type ) {
901
+		if ($message_type_name instanceof EE_message_type) {
902 902
 			$message_type_name = $message_type_name->name;
903 903
 		}
904
-		foreach ( $this->_active_message_types as $messenger_name => $settings ) {
904
+		foreach ($this->_active_message_types as $messenger_name => $settings) {
905 905
 			unset(
906
-				$this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]
906
+				$this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]
907 907
 			);
908 908
 
909 909
 			//we always record (even on deactivation) that a message type has been activated because there should at
910 910
 			//least be a record in the "has_activated" option that it WAS active at one point.
911
-			$messenger = $this->get_messenger( $messenger_name );
912
-			$this->_set_messenger_has_activated_message_type( $messenger, $message_type_name );
911
+			$messenger = $this->get_messenger($messenger_name);
912
+			$this->_set_messenger_has_activated_message_type($messenger, $message_type_name);
913 913
 		}
914
-		$this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name );
914
+		$this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name);
915 915
 		$this->update_active_messengers_option();
916 916
 		$this->update_has_activated_messengers_option();
917 917
 	}
@@ -926,12 +926,12 @@  discard block
 block discarded – undo
926 926
 	 * @param string $message_type_name  Name of message type being deactivated.
927 927
 	 * @param string $messenger_name     Name of messenger the message type is being deactivated for.
928 928
 	 */
929
-	public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) {
929
+	public function deactivate_message_type_for_messenger($message_type_name, $messenger_name) {
930 930
         $this->_initialize_collections();
931
-		if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
932
-			unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] );
931
+		if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
932
+			unset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]);
933 933
 		}
934
-		$this->_message_template_group_model->deactivate_message_template_groups_for( array( $messenger_name ), array( $message_type_name ) );
934
+		$this->_message_template_group_model->deactivate_message_template_groups_for(array($messenger_name), array($message_type_name));
935 935
 		$this->update_active_messengers_option();
936 936
 	}
937 937
 
@@ -948,12 +948,12 @@  discard block
 block discarded – undo
948 948
 	 *
949 949
 	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
950 950
 	 */
951
-	public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) {
951
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) {
952 952
 		//get the $messengers the message type says it can be used with.
953
-		foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) {
953
+		foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) {
954 954
 			if (
955 955
 				$messenger->name === $generating_messenger
956
-				&& $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name )
956
+				&& $this->is_message_type_active_for_messenger($messenger->name, $message_type->name)
957 957
 			) {
958 958
 				return true;
959 959
 			}
@@ -990,25 +990,25 @@  discard block
 block discarded – undo
990 990
 	 *                           or all contexts indexed by message type.
991 991
 	 * @return array
992 992
 	 */
993
-	public function get_all_contexts( $slugs_only = true ) {
993
+	public function get_all_contexts($slugs_only = true) {
994 994
 		$key = $slugs_only ? 'slugs' : 'all';
995 995
 		// check if contexts has been setup yet.
996
-		if ( empty( $this->_contexts[ $key ] ) ) {
996
+		if (empty($this->_contexts[$key])) {
997 997
 			// So let's get all active message type objects and loop through to get all unique contexts
998
-			foreach ( $this->get_active_message_type_objects() as $message_type ) {
999
-				if ( $message_type instanceof EE_message_type ) {
998
+			foreach ($this->get_active_message_type_objects() as $message_type) {
999
+				if ($message_type instanceof EE_message_type) {
1000 1000
 					$message_type_contexts = $message_type->get_contexts();
1001
-					if ( $slugs_only ) {
1002
-						foreach ( $message_type_contexts as $context => $context_details ) {
1003
-							$this->_contexts[ $key ][ $context ] = $context_details[ 'label' ];
1001
+					if ($slugs_only) {
1002
+						foreach ($message_type_contexts as $context => $context_details) {
1003
+							$this->_contexts[$key][$context] = $context_details['label'];
1004 1004
 						}
1005 1005
 					} else {
1006
-						$this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts;
1006
+						$this->_contexts[$key][$message_type->name] = $message_type_contexts;
1007 1007
 					}
1008 1008
 				}
1009 1009
 			}
1010 1010
 		}
1011
-		return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array();
1011
+		return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array();
1012 1012
 	}
1013 1013
 
1014 1014
 
@@ -1027,9 +1027,9 @@  discard block
 block discarded – undo
1027 1027
 		$installed_message_types = $this->installed_message_types();
1028 1028
 		$all_message_types_valid = true;
1029 1029
 		//loop through list of active message types and verify they are installed.
1030
-		foreach( $list_of_active_message_type_names as $message_type_name ) {
1031
-			if ( ! isset( $installed_message_types[$message_type_name] ) ) {
1032
-				$this->deactivate_message_type( $message_type_name );
1030
+		foreach ($list_of_active_message_type_names as $message_type_name) {
1031
+			if ( ! isset($installed_message_types[$message_type_name])) {
1032
+				$this->deactivate_message_type($message_type_name);
1033 1033
 				$all_message_types_valid = false;
1034 1034
 			}
1035 1035
 		}
@@ -1048,10 +1048,10 @@  discard block
 block discarded – undo
1048 1048
 	 * @param $messenger_name
1049 1049
 	 * @return bool
1050 1050
 	 */
1051
-	public function has_message_type_been_activated_for_messenger( $message_type_name, $messenger_name ) {
1051
+	public function has_message_type_been_activated_for_messenger($message_type_name, $messenger_name) {
1052 1052
 		$has_activated = $this->get_has_activated_messengers_option();
1053
-		return isset( $has_activated[ $messenger_name ] )
1054
-			&& in_array( $message_type_name, $has_activated[ $messenger_name ] );
1053
+		return isset($has_activated[$messenger_name])
1054
+			&& in_array($message_type_name, $has_activated[$messenger_name]);
1055 1055
 	}
1056 1056
 }
1057 1057
 // End of file EE_Message_Resource_Manager.lib.php
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepFormManager.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 
197 197
 	/**
198
-	 * @param $default_form_step
198
+	 * @param string $default_form_step
199 199
 	 * @throws InvalidDataTypeException
200 200
 	 */
201 201
 	protected function setDefaultFormStep( $default_form_step ) {
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 
505 505
 	/**
506 506
 	 * @param array $form_data
507
-	 * @return bool
507
+	 * @return boolean|null
508 508
 	 * @throws InvalidArgumentException
509 509
 	 * @throws InvalidDataTypeException
510 510
 	 */
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 use Exception;
17 17
 use InvalidArgumentException;
18 18
 
19
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
-	exit( 'No direct script access allowed' );
19
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 		$progress_step_style = 'number_bubbles',
116 116
 		EE_Request $request
117 117
 	) {
118
-		$this->setBaseUrl( $base_url );
119
-		$this->setDefaultFormStep( $default_form_step );
120
-		$this->setFormAction( $form_action );
121
-		$this->setFormConfig( $form_config );
122
-		$this->setProgressStepStyle( $progress_step_style );
118
+		$this->setBaseUrl($base_url);
119
+		$this->setDefaultFormStep($default_form_step);
120
+		$this->setFormAction($form_action);
121
+		$this->setFormConfig($form_config);
122
+		$this->setProgressStepStyle($progress_step_style);
123 123
 		$this->request = $request;
124 124
 	}
125 125
 
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
131 131
 	 */
132 132
 	public function baseUrl() {
133
-		if ( strpos( $this->base_url, $this->getCurrentStep()->slug() ) === false ) {
133
+		if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
134 134
 			add_query_arg(
135
-				array( $this->form_step_url_key => $this->getCurrentStep()->slug() ),
135
+				array($this->form_step_url_key => $this->getCurrentStep()->slug()),
136 136
 				$this->base_url
137 137
 			);
138 138
 		}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 * @throws InvalidDataTypeException
147 147
 	 * @throws InvalidArgumentException
148 148
 	 */
149
-	protected function setBaseUrl( $base_url ) {
150
-		if ( ! is_string( $base_url ) ) {
151
-			throw new InvalidDataTypeException( '$base_url', $base_url, 'string' );
149
+	protected function setBaseUrl($base_url) {
150
+		if ( ! is_string($base_url)) {
151
+			throw new InvalidDataTypeException('$base_url', $base_url, 'string');
152 152
 		}
153
-		if ( empty( $base_url ) ) {
153
+		if (empty($base_url)) {
154 154
 			throw new InvalidArgumentException(
155
-				__( 'The base URL can not be an empty string.', 'event_espresso' )
155
+				__('The base URL can not be an empty string.', 'event_espresso')
156 156
 			);
157 157
 		}
158 158
 		$this->base_url = $base_url;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @throws InvalidDataTypeException
166 166
 	 */
167 167
 	public function formStepUrlKey() {
168
-		if ( empty( $this->form_step_url_key ) ) {
168
+		if (empty($this->form_step_url_key)) {
169 169
 			$this->setFormStepUrlKey();
170 170
 		}
171 171
 		return $this->form_step_url_key;
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param string $form_step_url_key
178 178
 	 * @throws InvalidDataTypeException
179 179
 	 */
180
-	public function setFormStepUrlKey( $form_step_url_key = 'ee-form-step' ) {
181
-		if ( ! is_string( $form_step_url_key ) ) {
182
-			throw new InvalidDataTypeException( '$form_step_key', $form_step_url_key, 'string' );
180
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') {
181
+		if ( ! is_string($form_step_url_key)) {
182
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
183 183
 		}
184
-		$this->form_step_url_key = ! empty( $form_step_url_key ) ? $form_step_url_key : 'ee-form-step';
184
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
185 185
 	}
186 186
 
187 187
 
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * @param $default_form_step
200 200
 	 * @throws InvalidDataTypeException
201 201
 	 */
202
-	protected function setDefaultFormStep( $default_form_step ) {
203
-		if ( ! is_string( $default_form_step ) ) {
204
-			throw new InvalidDataTypeException( '$default_form_step', $default_form_step, 'string' );
202
+	protected function setDefaultFormStep($default_form_step) {
203
+		if ( ! is_string($default_form_step)) {
204
+			throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
205 205
 		}
206 206
 		$this->default_form_step = $default_form_step;
207 207
 	}
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @throws InvalidDataTypeException
215 215
 	 */
216 216
 	protected function setCurrentStepFromRequest() {
217
-		$current_step_slug = $this->request()->get( $this->formStepUrlKey(), $this->defaultFormStep() );
218
-		if ( ! $this->form_steps->setCurrent( $current_step_slug ) ) {
217
+		$current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
218
+		if ( ! $this->form_steps->setCurrent($current_step_slug)) {
219 219
 			throw new InvalidIdentifierException(
220 220
 				$current_step_slug,
221 221
 				$this->defaultFormStep(),
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
238 238
 	 */
239 239
 	public function getCurrentStep() {
240
-		if ( ! $this->form_steps->current() instanceof SequentialStepForm ) {
241
-			throw new InvalidFormHandlerException( $this->form_steps->current() );
240
+		if ( ! $this->form_steps->current() instanceof SequentialStepForm) {
241
+			throw new InvalidFormHandlerException($this->form_steps->current());
242 242
 		}
243 243
 		return $this->form_steps->current();
244 244
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
251 251
 	 */
252 252
 	public function formAction() {
253
-		if ( ! is_string( $this->form_action ) || empty( $this->form_action ) ) {
253
+		if ( ! is_string($this->form_action) || empty($this->form_action)) {
254 254
 			$this->form_action = $this->baseUrl();
255 255
 		}
256 256
 		return $this->form_action;
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	 * @param string $form_action
263 263
 	 * @throws InvalidDataTypeException
264 264
 	 */
265
-	public function setFormAction( $form_action ) {
266
-		if ( ! is_string( $form_action ) ) {
267
-			throw new InvalidDataTypeException( '$form_action', $form_action, 'string' );
265
+	public function setFormAction($form_action) {
266
+		if ( ! is_string($form_action)) {
267
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
268 268
 		}
269 269
 		$this->form_action = $form_action;
270 270
 	}
@@ -275,15 +275,15 @@  discard block
 block discarded – undo
275 275
 	 * @param array $form_action_args
276 276
 	 * @throws InvalidDataTypeException
277 277
 	 */
278
-	public function addFormActionArgs( $form_action_args = array() ) {
279
-		if ( ! is_array( $form_action_args ) ) {
280
-			throw new InvalidDataTypeException( '$form_action_args', $form_action_args, 'array' );
278
+	public function addFormActionArgs($form_action_args = array()) {
279
+		if ( ! is_array($form_action_args)) {
280
+			throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
281 281
 		}
282
-		$form_action_args = ! empty( $form_action_args )
282
+		$form_action_args = ! empty($form_action_args)
283 283
 			? $form_action_args
284
-			: array( $this->formStepUrlKey() => $this->form_steps->current()->slug() );
284
+			: array($this->formStepUrlKey() => $this->form_steps->current()->slug());
285 285
 		$this->getCurrentStep()->setFormAction(
286
-			add_query_arg( $form_action_args, $this->formAction() )
286
+			add_query_arg($form_action_args, $this->formAction())
287 287
 		);
288 288
 		$this->form_action = $this->getCurrentStep()->formAction();
289 289
 	}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	/**
303 303
 	 * @param string $form_config
304 304
 	 */
305
-	public function setFormConfig( $form_config ) {
305
+	public function setFormConfig($form_config) {
306 306
 		$this->form_config = $form_config;
307 307
 	}
308 308
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	/**
321 321
 	 * @param string $progress_step_style
322 322
 	 */
323
-	public function setProgressStepStyle( $progress_step_style ) {
323
+	public function setProgressStepStyle($progress_step_style) {
324 324
 		$this->progress_step_style = $progress_step_style;
325 325
 	}
326 326
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	protected function getProgressStepsCollection() {
342 342
 		static $collection = null;
343
-		if ( ! $collection instanceof ProgressStepCollection ) {
343
+		if ( ! $collection instanceof ProgressStepCollection) {
344 344
 			$collection = new ProgressStepCollection();
345 345
 		}
346 346
 		return $collection;
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 	 * @throws InvalidClassException
357 357
 	 * @throws InvalidInterfaceException
358 358
 	 */
359
-	protected function generateProgressSteps( Collection $progress_steps_collection ) {
359
+	protected function generateProgressSteps(Collection $progress_steps_collection) {
360 360
 		$current_step = $this->getCurrentStep();
361 361
 		/** @var SequentialStepForm $form_step */
362
-		foreach ( $this->form_steps as $form_step ) {
362
+		foreach ($this->form_steps as $form_step) {
363 363
 			// is this step active ?
364
-			if ( ! $form_step->initialize() ) {
364
+			if ( ! $form_step->initialize()) {
365 365
 				continue;
366 366
 			}
367 367
 			$progress_steps_collection->add(
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 			);
376 376
 		}
377 377
 		// set collection pointer back to current step
378
-		$this->form_steps->setCurrentUsingObject( $current_step );
378
+		$this->form_steps->setCurrentUsingObject($current_step);
379 379
 		return new ProgressStepManager(
380 380
 			$this->progressStepStyle(),
381 381
 			$this->defaultFormStep(),
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 	 * @throws InvalidInterfaceException
410 410
 	 * @throws InvalidArgumentException
411 411
 	 */
412
-	public function processForm( $form_data = array() ) {
412
+	public function processForm($form_data = array()) {
413 413
 		$this->buildCurrentStepFormForProcessing();
414
-		$this->processCurrentStepForm( $form_data );
414
+		$this->processCurrentStepForm($form_data);
415 415
 	}
416 416
 
417 417
 
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 	public function buildCurrentStepFormForDisplay() {
428 428
 		$form_step = $this->buildCurrentStepForm();
429 429
 		// no displayable content ? then skip straight to processing
430
-		if ( ! $form_step->displayable() ) {
430
+		if ( ! $form_step->displayable()) {
431 431
 			$this->addFormActionArgs();
432
-			$form_step->setFormAction( $this->formAction() );
433
-			wp_safe_redirect( $form_step->formAction() );
432
+			$form_step->setFormAction($this->formAction());
433
+			wp_safe_redirect($form_step->formAction());
434 434
 		}
435 435
 	}
436 436
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @throws InvalidArgumentException
446 446
 	 */
447 447
 	public function buildCurrentStepFormForProcessing() {
448
-		$this->buildCurrentStepForm( false );
448
+		$this->buildCurrentStepForm(false);
449 449
 	}
450 450
 
451 451
 
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 	 * @throws InvalidInterfaceException
461 461
 	 * @throws InvalidArgumentException
462 462
 	 */
463
-	private function buildCurrentStepForm( $for_display = true ) {
463
+	private function buildCurrentStepForm($for_display = true) {
464 464
 		$this->form_steps = $this->getFormStepsCollection();
465 465
 		$this->setCurrentStepFromRequest();
466 466
 		$form_step = $this->getCurrentStep();
467
-		if ( $form_step->submitBtnText() === __( 'Submit', 'event_espresso' ) ) {
468
-			$form_step->setSubmitBtnText( __( 'Next Step', 'event_espresso' ) );
467
+		if ($form_step->submitBtnText() === __('Submit', 'event_espresso')) {
468
+			$form_step->setSubmitBtnText(__('Next Step', 'event_espresso'));
469 469
 		}
470
-		if ( $for_display && $form_step->displayable() ) {
470
+		if ($for_display && $form_step->displayable()) {
471 471
 			$this->progress_step_manager = $this->generateProgressSteps(
472 472
 				$this->getProgressStepsCollection()
473 473
 			);
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 			$this->progress_step_manager->setPreviousStepsCompleted();
479 479
 			$this->progress_step_manager->enqueueStylesAndScripts();
480 480
 			$this->addFormActionArgs();
481
-			$form_step->setFormAction( $this->formAction() );
481
+			$form_step->setFormAction($this->formAction());
482 482
 
483 483
 		} else {
484
-			$form_step->setRedirectUrl( $this->baseUrl() );
484
+			$form_step->setRedirectUrl($this->baseUrl());
485 485
 			$form_step->addRedirectArgs(
486
-				array( $this->formStepUrlKey() => $this->form_steps->current()->slug() )
486
+				array($this->formStepUrlKey() => $this->form_steps->current()->slug())
487 487
 			);
488 488
 		}
489 489
 		$form_step->generate();
490
-		if ( $for_display ) {
490
+		if ($for_display) {
491 491
 			$form_step->enqueueStylesAndScripts();
492 492
 		}
493 493
 		return $form_step;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @param bool $return_as_string
500 500
 	 * @return string
501 501
 	 */
502
-	public function displayProgressSteps( $return_as_string = true ) {
502
+	public function displayProgressSteps($return_as_string = true) {
503 503
 		$progress_steps = apply_filters(
504 504
 			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
505 505
 			''
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
510 510
 			''
511 511
 		);
512
-		if ( $return_as_string ) {
512
+		if ($return_as_string) {
513 513
 			return $progress_steps;
514 514
 		}
515 515
 		echo $progress_steps;
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	 * @return string
524 524
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
525 525
 	 */
526
-	public function displayCurrentStepForm( $return_as_string = true ) {
527
-		if ( $return_as_string ) {
526
+	public function displayCurrentStepForm($return_as_string = true) {
527
+		if ($return_as_string) {
528 528
 			return $this->getCurrentStep()->display();
529 529
 		}
530 530
 		echo $this->getCurrentStep()->display();
@@ -539,32 +539,32 @@  discard block
 block discarded – undo
539 539
 	 * @throws InvalidArgumentException
540 540
 	 * @throws InvalidDataTypeException
541 541
 	 */
542
-	public function processCurrentStepForm( $form_data = array() ) {
542
+	public function processCurrentStepForm($form_data = array()) {
543 543
 		// grab instance of current step because after calling next() below,
544 544
 		// any calls to getCurrentStep() will return the "next" step because we advanced
545 545
 		$current_step = $this->getCurrentStep();
546 546
 		try {
547 547
 			// form processing should either throw exceptions or return true
548
-			$current_step->process( $form_data );
549
-		} catch ( Exception $e ) {
548
+			$current_step->process($form_data);
549
+		} catch (Exception $e) {
550 550
 			// something went wrong, so...
551 551
 			// if WP_DEBUG === true, display the Exception and stack trace right now
552
-			new ExceptionStackTraceDisplay( $e );
552
+			new ExceptionStackTraceDisplay($e);
553 553
 			// else convert the Exception to an EE_Error
554
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
554
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
555 555
 			// prevent redirect to next step or other if exception was thrown
556 556
 			if (
557 557
 				$current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
558 558
 				|| $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
559 559
 			) {
560
-				$current_step->setRedirectTo( SequentialStepForm::REDIRECT_TO_CURRENT_STEP );
560
+				$current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
561 561
 			}
562 562
 		}
563 563
 		// save notices to a transient so that when we redirect back
564 564
 		// to the display portion for this step
565 565
 		// those notices can be displayed
566
-		EE_Error::get_notices( false, true );
567
-		$this->redirectForm( $current_step );
566
+		EE_Error::get_notices(false, true);
567
+		$this->redirectForm($current_step);
568 568
 	}
569 569
 
570 570
 
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 	 *
575 575
 	 * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepFormInterface $current_step
576 576
 	 */
577
-	public function redirectForm( SequentialStepFormInterface $current_step ) {
577
+	public function redirectForm(SequentialStepFormInterface $current_step) {
578 578
 		$redirect_step = $current_step;
579
-		switch( $current_step->redirectTo() ) {
579
+		switch ($current_step->redirectTo()) {
580 580
 
581 581
 			case SequentialStepForm::REDIRECT_TO_OTHER :
582 582
 				// going somewhere else, so just check out now
583
-				wp_safe_redirect( $redirect_step->redirectUrl() );
583
+				wp_safe_redirect($redirect_step->redirectUrl());
584 584
 				exit();
585 585
 				break;
586 586
 
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
 			case SequentialStepForm::REDIRECT_TO_NEXT_STEP :
592 592
 				$this->form_steps->next();
593
-				if ( $this->form_steps->valid() ) {
593
+				if ($this->form_steps->valid()) {
594 594
 					$redirect_step = $this->form_steps->current();
595 595
 				}
596 596
 				break;
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
 				// $redirect_step is already set
601 601
 
602 602
 		}
603
-		$current_step->setRedirectUrl( $this->baseUrl() );
603
+		$current_step->setRedirectUrl($this->baseUrl());
604 604
 		$current_step->addRedirectArgs(
605 605
 			// use the slug for whatever step we are redirecting too
606
-			array( $this->formStepUrlKey() => $redirect_step->slug() )
606
+			array($this->formStepUrlKey() => $redirect_step->slug())
607 607
 		);
608
-		wp_safe_redirect( $current_step->redirectUrl() );
608
+		wp_safe_redirect($current_step->redirectUrl());
609 609
 		exit();
610 610
 	}
611 611
 
Please login to merge, or discard this patch.
core/services/container/CoffeeShop.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      * Adds instructions on how to brew objects
237 237
      *
238 238
      * @param RecipeInterface $recipe
239
-     * @return mixed
239
+     * @return boolean
240 240
      */
241 241
     public function addRecipe(RecipeInterface $recipe)
242 242
     {
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
     /**
313 313
      * Adds a service to one of the internal collections
314 314
      *
315
-     * @param        $identifier
315
+     * @param        string $identifier
316 316
      * @param array  $arguments
317 317
      * @param string $type
318 318
      * @return mixed
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         // array for storing class aliases
80 80
         $this->filters = array();
81 81
         // create collection for storing shared services
82
-        $this->carafe = new LooseCollection( '' );
82
+        $this->carafe = new LooseCollection('');
83 83
         // create collection for storing recipes that tell how to build services and entities
84 84
         $this->recipes = new Collection('EventEspresso\core\services\container\RecipeInterface');
85 85
         // create collection for storing closures for constructing new entities
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
             return;
303 303
         }
304 304
         $identifier = $this->processIdentifier($identifier);
305
-        foreach ((array)$aliases as $alias) {
305
+        foreach ((array) $aliases as $alias) {
306 306
             $this->filters[$this->processIdentifier($alias)] = $identifier;
307 307
         }
308 308
     }
Please login to merge, or discard this patch.
Indentation   +497 added lines, -497 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use OutOfBoundsException;
14 14
 
15 15
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
16
-    exit('No direct script access allowed');
16
+	exit('No direct script access allowed');
17 17
 }
18 18
 
19 19
 
@@ -32,502 +32,502 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * This was the best coffee related name I could think of to represent class name "aliases"
37
-     * So classes can be found via an alias identifier,
38
-     * that is revealed when it is run through... the filters... eh? get it?
39
-     *
40
-     * @var array $filters
41
-     */
42
-    private $filters = array();
43
-
44
-    /**
45
-     * These are the classes that will actually build the objects (to order of course)
46
-     *
47
-     * @var array $coffee_makers
48
-     */
49
-    private $coffee_makers = array();
50
-
51
-    /**
52
-     * where the instantiated "singleton" objects are stored
53
-     *
54
-     * @var CollectionInterface $carafe
55
-     */
56
-    private $carafe;
57
-
58
-    /**
59
-     * collection of Recipes that instruct us how to brew objects
60
-     *
61
-     * @var CollectionInterface $recipes
62
-     */
63
-    private $recipes;
64
-
65
-    /**
66
-     * collection of closures for brewing objects
67
-     *
68
-     * @var CollectionInterface $reservoir
69
-     */
70
-    private $reservoir;
71
-
72
-
73
-
74
-    /**
75
-     * CoffeeShop constructor
76
-     */
77
-    public function __construct()
78
-    {
79
-        // array for storing class aliases
80
-        $this->filters = array();
81
-        // create collection for storing shared services
82
-        $this->carafe = new LooseCollection( '' );
83
-        // create collection for storing recipes that tell how to build services and entities
84
-        $this->recipes = new Collection('EventEspresso\core\services\container\RecipeInterface');
85
-        // create collection for storing closures for constructing new entities
86
-        $this->reservoir = new Collection('Closure');
87
-        // create collection for storing the generators that build our services and entity closures
88
-        $this->coffee_makers = new Collection('EventEspresso\core\services\container\CoffeeMakerInterface');
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * Returns true if the container can return an entry for the given identifier.
95
-     * Returns false otherwise.
96
-     * `has($identifier)` returning true does not mean that `get($identifier)` will not throw an exception.
97
-     * It does however mean that `get($identifier)` will not throw a `ServiceNotFoundException`.
98
-     *
99
-     * @param string $identifier  Identifier of the entry to look for.
100
-     *                            Typically a Fully Qualified Class Name
101
-     * @return boolean
102
-     */
103
-    public function has($identifier)
104
-    {
105
-        $identifier = $this->filterIdentifier($identifier);
106
-        return $this->carafe->has($identifier);
107
-    }
108
-
109
-
110
-
111
-    /**
112
-     * finds a previously brewed (SHARED) service and returns it
113
-     *
114
-     * @param  string $identifier Identifier for the entity class to be constructed.
115
-     *                            Typically a Fully Qualified Class Name
116
-     * @return mixed
117
-     * @throws ServiceNotFoundException No service was found for this identifier.
118
-     */
119
-    public function get($identifier)
120
-    {
121
-        $identifier = $this->filterIdentifier($identifier);
122
-        if ($this->carafe->has($identifier)) {
123
-            return $this->carafe->get($identifier);
124
-        }
125
-        throw new ServiceNotFoundException($identifier);
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * returns an instance of the requested entity type using the supplied arguments.
132
-     * If a shared service is requested and an instance is already in the carafe, then it will be returned.
133
-     * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned
134
-     * If the request is for a new entity and a closure exists in the reservoir for creating it,
135
-     * then a new entity will be instantiated from the closure and returned.
136
-     * If a closure does not exist, then one will be built and added to the reservoir
137
-     * before instantiating the requested entity.
138
-     *
139
-     * @param  string $identifier Identifier for the entity class to be constructed.
140
-     *                            Typically a Fully Qualified Class Name
141
-     * @param array   $arguments  an array of arguments to be passed to the entity constructor
142
-     * @param string  $type
143
-     * @return mixed
144
-     * @throws ServiceNotFoundException No service was found for this identifier.
145
-     */
146
-    public function brew($identifier, $arguments = array(), $type = '')
147
-    {
148
-        // resolve any class aliases that may exist
149
-        $identifier = $this->filterIdentifier($identifier);
150
-        try {
151
-            // is a shared service being requested?
152
-            if (empty($type) || $type === CoffeeMaker::BREW_SHARED) {
153
-                // if a shared service was requested and an instance is in the carafe, then return it
154
-                return $this->get($identifier);
155
-            }
156
-        } catch (ServiceNotFoundException $e) {
157
-            // if not then we'll just catch the ServiceNotFoundException but not do anything just yet,
158
-            // and instead, attempt to build whatever was requested
159
-        }
160
-        $brewed = false;
161
-        // if the reservoir doesn't have a closure already for the requested identifier,
162
-        // then neither a shared service nor a closure for making entities has been built yet
163
-        if ( ! $this->reservoir->has($identifier)) {
164
-            // so let's brew something up and add it to the proper collection
165
-            $brewed = $this->makeCoffee($identifier, $arguments, $type);
166
-        }
167
-        // was the brewed item a callable factory function ?
168
-        if (is_callable($brewed)) {
169
-            // then instantiate a new entity from the cached closure
170
-            $entity = $brewed($arguments);
171
-        } else if ($brewed) {
172
-            // requested object was a shared entity, so attempt to get it from the carafe again
173
-            // because if it wasn't there before, then it should have just been brewed and added,
174
-            // but if it still isn't there, then this time
175
-            // the thrown ServiceNotFoundException will not be caught
176
-            $entity = $this->get($identifier);
177
-        } else {
178
-            // if identifier is for a non-shared entity,
179
-            // then either a cached closure already existed, or was just brewed
180
-            $closure = $this->reservoir->get($identifier);
181
-            $entity = $closure($arguments);
182
-        }
183
-        return $entity;
184
-    }
185
-
186
-
187
-
188
-    /**
189
-     * @param CoffeeMakerInterface $coffee_maker
190
-     * @param string               $type
191
-     * @return bool
192
-     */
193
-    public function addCoffeeMaker(CoffeeMakerInterface $coffee_maker, $type)
194
-    {
195
-        $type = CoffeeMaker::validateType($type);
196
-        return $this->coffee_makers->add($coffee_maker, $type);
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * @param string   $identifier
203
-     * @param callable $closure
204
-     * @return callable|null
205
-     */
206
-    public function addClosure($identifier, $closure)
207
-    {
208
-        if ( ! is_callable($closure)) {
209
-            throw new InvalidDataTypeException('$closure', $closure, 'Closure');
210
-        }
211
-        $identifier = $this->processIdentifier($identifier);
212
-        if ($this->reservoir->add($closure, $identifier)) {
213
-            return $closure;
214
-        }
215
-        return null;
216
-    }
217
-
218
-
219
-
220
-    /**
221
-     * @param string   $identifier
222
-     * @return boolean
223
-     */
224
-    public function removeClosure($identifier)
225
-    {
226
-        $identifier = $this->processIdentifier($identifier);
227
-        if ($this->reservoir->has($identifier)) {
228
-            $this->reservoir->remove($this->reservoir->get($identifier));
229
-            if ( ! $this->reservoir->has($identifier)) {
230
-                return true;
231
-            }
232
-        }
233
-        return false;
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * @param  string $identifier Identifier for the entity class that the service applies to
240
-     *                            Typically a Fully Qualified Class Name
241
-     * @param mixed  $service
242
-     * @return bool
243
-     */
244
-    public function addService($identifier, $service)
245
-    {
246
-        $identifier = $this->processIdentifier($identifier);
247
-        $service = $this->validateService($identifier, $service);
248
-        return $this->carafe->add($service, $identifier);
249
-    }
250
-
251
-
252
-
253
-    /**
254
-     * @param string $identifier
255
-     * @return boolean
256
-     */
257
-    public function removeService($identifier)
258
-    {
259
-        $identifier = $this->processIdentifier($identifier);
260
-        if ($this->carafe->has($identifier)) {
261
-            $this->carafe->remove($this->carafe->get($identifier));
262
-            if ( ! $this->carafe->has($identifier)) {
263
-                return true;
264
-            }
265
-        }
266
-        return false;
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * Adds instructions on how to brew objects
273
-     *
274
-     * @param RecipeInterface $recipe
275
-     * @return mixed
276
-     */
277
-    public function addRecipe(RecipeInterface $recipe)
278
-    {
279
-        $this->addAliases($recipe->identifier(), $recipe->filters());
280
-        $identifier = $this->processIdentifier($recipe->identifier());
281
-        return $this->recipes->add($recipe, $identifier);
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * @param string $identifier The Recipe's identifier
288
-     * @return boolean
289
-     */
290
-    public function removeRecipe($identifier)
291
-    {
292
-        $identifier = $this->processIdentifier($identifier);
293
-        if ($this->recipes->has($identifier)) {
294
-            $this->recipes->remove(
295
-                $this->recipes->get($identifier)
296
-            );
297
-            if ( ! $this->recipes->has($identifier)) {
298
-                return true;
299
-            }
300
-        }
301
-        return false;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * Get instructions on how to brew objects
308
-     *
309
-     * @param  string $identifier Identifier for the entity class that the recipe applies to
310
-     *                            Typically a Fully Qualified Class Name
311
-     * @param string $type
312
-     * @return RecipeInterface
313
-     */
314
-    public function getRecipe($identifier, $type = '')
315
-    {
316
-        $identifier = $this->processIdentifier($identifier);
317
-        if ($this->recipes->has($identifier)) {
318
-            return $this->recipes->get($identifier);
319
-        }
320
-        $default_recipes = $this->getDefaultRecipes();
321
-        $matches = array();
322
-        foreach ($default_recipes as $wildcard => $default_recipe) {
323
-            // is the wildcard recipe prefix in the identifier ?
324
-            if (strpos($identifier, $wildcard) !== false) {
325
-                // track matches and use the number of wildcard characters matched for the key
326
-                $matches[strlen($wildcard)] = $default_recipe;
327
-            }
328
-        }
329
-        if (count($matches) > 0) {
330
-            // sort our recipes by the number of wildcard characters matched
331
-            ksort($matches);
332
-            // then grab the last recipe form the list, since it had the most matching characters
333
-            $match = array_pop($matches);
334
-            // since we are using a default recipe, we need to set it's identifier and fqcn
335
-            return $this->copyDefaultRecipe($match, $identifier, $type);
336
-        }
337
-        if ($this->recipes->has(Recipe::DEFAULT_ID)) {
338
-            // since we are using a default recipe, we need to set it's identifier and fqcn
339
-            return $this->copyDefaultRecipe($this->recipes->get(Recipe::DEFAULT_ID), $identifier, $type);
340
-        }
341
-        throw new OutOfBoundsException(
342
-            sprintf(
343
-                __('Could not brew coffee because no recipes were found for class "%1$s".', 'event_espresso'),
344
-                $identifier
345
-            )
346
-        );
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * adds class name aliases to list of filters
353
-     *
354
-     * @param  string $identifier Identifier for the entity class that the alias applies to
355
-     *                            Typically a Fully Qualified Class Name
356
-     * @param  array  $aliases
357
-     * @return void
358
-     * @throws InvalidIdentifierException
359
-     */
360
-    public function addAliases($identifier, $aliases)
361
-    {
362
-        if (empty($aliases)) {
363
-            return;
364
-        }
365
-        $identifier = $this->processIdentifier($identifier);
366
-        foreach ((array)$aliases as $alias) {
367
-            $this->filters[$this->processIdentifier($alias)] = $identifier;
368
-        }
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Adds a service to one of the internal collections
375
-     *
376
-     * @param        $identifier
377
-     * @param array  $arguments
378
-     * @param string $type
379
-     * @return mixed
380
-     * @throws ServiceExistsException
381
-     */
382
-    private function makeCoffee($identifier, $arguments = array(), $type = '')
383
-    {
384
-        if ((empty($type) || $type === CoffeeMaker::BREW_SHARED) && $this->has($identifier)) {
385
-            throw new ServiceExistsException($identifier);
386
-        }
387
-        $identifier = $this->filterIdentifier($identifier);
388
-        $recipe = $this->getRecipe($identifier, $type);
389
-        $type = ! empty($type) ? $type : $recipe->type();
390
-        $coffee_maker = $this->getCoffeeMaker($type);
391
-        return $coffee_maker->brew($recipe, $arguments);
392
-    }
393
-
394
-
395
-
396
-    /**
397
-     * filters alias identifiers to find the real class name
398
-     *
399
-     * @param  string $identifier Identifier for the entity class that the filter applies to
400
-     *                            Typically a Fully Qualified Class Name
401
-     * @return string
402
-     * @throws InvalidIdentifierException
403
-     */
404
-    private function filterIdentifier($identifier)
405
-    {
406
-        $identifier = $this->processIdentifier($identifier);
407
-        return isset($this->filters[$identifier]) && ! empty($this->filters[$identifier])
408
-            ? $this->filters[$identifier]
409
-            : $identifier;
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * verifies and standardizes identifiers
416
-     *
417
-     * @param  string $identifier Identifier for the entity class
418
-     *                            Typically a Fully Qualified Class Name
419
-     * @return string
420
-     * @throws InvalidIdentifierException
421
-     */
422
-    private function processIdentifier($identifier)
423
-    {
424
-        if ( ! is_string($identifier)) {
425
-            throw new InvalidIdentifierException(
426
-                is_object($identifier) ? get_class($identifier) : gettype($identifier),
427
-                '\Fully\Qualified\ClassName'
428
-            );
429
-        }
430
-        return ltrim($identifier, '\\');
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * @param string $type
437
-     * @return CoffeeMakerInterface
438
-     * @throws InvalidDataTypeException
439
-     * @throws InvalidClassException
440
-     */
441
-    private function getCoffeeMaker($type)
442
-    {
443
-        if ( ! $this->coffee_makers->has($type)) {
444
-            throw new OutOfBoundsException(
445
-                __('The requested coffee maker is either missing or invalid.', 'event_espresso')
446
-            );
447
-        }
448
-        return $this->coffee_makers->get($type);
449
-    }
450
-
451
-
452
-
453
-    /**
454
-     * Retrieves all recipes that use a wildcard "*" in their identifier
455
-     * This allows recipes to be set up for handling
456
-     * legacy classes that do not support PSR-4 autoloading.
457
-     * for example:
458
-     * using "EEM_*" for a recipe identifier would target all legacy models like EEM_Attendee
459
-     *
460
-     * @return array
461
-     */
462
-    private function getDefaultRecipes()
463
-    {
464
-        $default_recipes = array();
465
-        $this->recipes->rewind();
466
-        while ($this->recipes->valid()) {
467
-            $identifier = $this->recipes->getInfo();
468
-            // does this recipe use a wildcard ? (but is NOT the global default)
469
-            if ($identifier !== Recipe::DEFAULT_ID && strpos($identifier, '*') !== false) {
470
-                // strip the wildcard and use identifier as key
471
-                $default_recipes[str_replace('*', '', $identifier)] = $this->recipes->current();
472
-            }
473
-            $this->recipes->next();
474
-        }
475
-        return $default_recipes;
476
-    }
477
-
478
-
479
-
480
-    /**
481
-     * clones a default recipe and then copies details
482
-     * from the incoming request to it so that it can be used
483
-     *
484
-     * @param RecipeInterface $default_recipe
485
-     * @param string          $identifier
486
-     * @param string          $type
487
-     * @return RecipeInterface
488
-     */
489
-    private function copyDefaultRecipe(RecipeInterface $default_recipe, $identifier, $type = '')
490
-    {
491
-        $recipe = clone $default_recipe;
492
-        if ( ! empty($type)) {
493
-            $recipe->setType($type);
494
-        }
495
-        // is this the base default recipe ?
496
-        if ($default_recipe->identifier() === Recipe::DEFAULT_ID) {
497
-            $recipe->setIdentifier($identifier);
498
-            $recipe->setFqcn($identifier);
499
-            return $recipe;
500
-        }
501
-        $recipe->setIdentifier($identifier);
502
-        foreach ($default_recipe->paths() as $path) {
503
-            $path = str_replace('*', $identifier, $path);
504
-            if (is_readable($path)) {
505
-                $recipe->setPaths($path);
506
-            }
507
-        }
508
-        $recipe->setFqcn($identifier);
509
-        return $recipe;
510
-    }
511
-
512
-
513
-
514
-    /**
515
-     * @param  string $identifier Identifier for the entity class that the service applies to
516
-     *                            Typically a Fully Qualified Class Name
517
-     * @param mixed  $service
518
-     * @return object
519
-     * @throws InvalidServiceException
520
-     */
521
-    private function validateService($identifier, $service)
522
-    {
523
-        if ( ! is_object($service)) {
524
-            throw new InvalidServiceException(
525
-                $identifier,
526
-                $service
527
-            );
528
-        }
529
-        return $service;
530
-    }
35
+	/**
36
+	 * This was the best coffee related name I could think of to represent class name "aliases"
37
+	 * So classes can be found via an alias identifier,
38
+	 * that is revealed when it is run through... the filters... eh? get it?
39
+	 *
40
+	 * @var array $filters
41
+	 */
42
+	private $filters = array();
43
+
44
+	/**
45
+	 * These are the classes that will actually build the objects (to order of course)
46
+	 *
47
+	 * @var array $coffee_makers
48
+	 */
49
+	private $coffee_makers = array();
50
+
51
+	/**
52
+	 * where the instantiated "singleton" objects are stored
53
+	 *
54
+	 * @var CollectionInterface $carafe
55
+	 */
56
+	private $carafe;
57
+
58
+	/**
59
+	 * collection of Recipes that instruct us how to brew objects
60
+	 *
61
+	 * @var CollectionInterface $recipes
62
+	 */
63
+	private $recipes;
64
+
65
+	/**
66
+	 * collection of closures for brewing objects
67
+	 *
68
+	 * @var CollectionInterface $reservoir
69
+	 */
70
+	private $reservoir;
71
+
72
+
73
+
74
+	/**
75
+	 * CoffeeShop constructor
76
+	 */
77
+	public function __construct()
78
+	{
79
+		// array for storing class aliases
80
+		$this->filters = array();
81
+		// create collection for storing shared services
82
+		$this->carafe = new LooseCollection( '' );
83
+		// create collection for storing recipes that tell how to build services and entities
84
+		$this->recipes = new Collection('EventEspresso\core\services\container\RecipeInterface');
85
+		// create collection for storing closures for constructing new entities
86
+		$this->reservoir = new Collection('Closure');
87
+		// create collection for storing the generators that build our services and entity closures
88
+		$this->coffee_makers = new Collection('EventEspresso\core\services\container\CoffeeMakerInterface');
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * Returns true if the container can return an entry for the given identifier.
95
+	 * Returns false otherwise.
96
+	 * `has($identifier)` returning true does not mean that `get($identifier)` will not throw an exception.
97
+	 * It does however mean that `get($identifier)` will not throw a `ServiceNotFoundException`.
98
+	 *
99
+	 * @param string $identifier  Identifier of the entry to look for.
100
+	 *                            Typically a Fully Qualified Class Name
101
+	 * @return boolean
102
+	 */
103
+	public function has($identifier)
104
+	{
105
+		$identifier = $this->filterIdentifier($identifier);
106
+		return $this->carafe->has($identifier);
107
+	}
108
+
109
+
110
+
111
+	/**
112
+	 * finds a previously brewed (SHARED) service and returns it
113
+	 *
114
+	 * @param  string $identifier Identifier for the entity class to be constructed.
115
+	 *                            Typically a Fully Qualified Class Name
116
+	 * @return mixed
117
+	 * @throws ServiceNotFoundException No service was found for this identifier.
118
+	 */
119
+	public function get($identifier)
120
+	{
121
+		$identifier = $this->filterIdentifier($identifier);
122
+		if ($this->carafe->has($identifier)) {
123
+			return $this->carafe->get($identifier);
124
+		}
125
+		throw new ServiceNotFoundException($identifier);
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * returns an instance of the requested entity type using the supplied arguments.
132
+	 * If a shared service is requested and an instance is already in the carafe, then it will be returned.
133
+	 * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned
134
+	 * If the request is for a new entity and a closure exists in the reservoir for creating it,
135
+	 * then a new entity will be instantiated from the closure and returned.
136
+	 * If a closure does not exist, then one will be built and added to the reservoir
137
+	 * before instantiating the requested entity.
138
+	 *
139
+	 * @param  string $identifier Identifier for the entity class to be constructed.
140
+	 *                            Typically a Fully Qualified Class Name
141
+	 * @param array   $arguments  an array of arguments to be passed to the entity constructor
142
+	 * @param string  $type
143
+	 * @return mixed
144
+	 * @throws ServiceNotFoundException No service was found for this identifier.
145
+	 */
146
+	public function brew($identifier, $arguments = array(), $type = '')
147
+	{
148
+		// resolve any class aliases that may exist
149
+		$identifier = $this->filterIdentifier($identifier);
150
+		try {
151
+			// is a shared service being requested?
152
+			if (empty($type) || $type === CoffeeMaker::BREW_SHARED) {
153
+				// if a shared service was requested and an instance is in the carafe, then return it
154
+				return $this->get($identifier);
155
+			}
156
+		} catch (ServiceNotFoundException $e) {
157
+			// if not then we'll just catch the ServiceNotFoundException but not do anything just yet,
158
+			// and instead, attempt to build whatever was requested
159
+		}
160
+		$brewed = false;
161
+		// if the reservoir doesn't have a closure already for the requested identifier,
162
+		// then neither a shared service nor a closure for making entities has been built yet
163
+		if ( ! $this->reservoir->has($identifier)) {
164
+			// so let's brew something up and add it to the proper collection
165
+			$brewed = $this->makeCoffee($identifier, $arguments, $type);
166
+		}
167
+		// was the brewed item a callable factory function ?
168
+		if (is_callable($brewed)) {
169
+			// then instantiate a new entity from the cached closure
170
+			$entity = $brewed($arguments);
171
+		} else if ($brewed) {
172
+			// requested object was a shared entity, so attempt to get it from the carafe again
173
+			// because if it wasn't there before, then it should have just been brewed and added,
174
+			// but if it still isn't there, then this time
175
+			// the thrown ServiceNotFoundException will not be caught
176
+			$entity = $this->get($identifier);
177
+		} else {
178
+			// if identifier is for a non-shared entity,
179
+			// then either a cached closure already existed, or was just brewed
180
+			$closure = $this->reservoir->get($identifier);
181
+			$entity = $closure($arguments);
182
+		}
183
+		return $entity;
184
+	}
185
+
186
+
187
+
188
+	/**
189
+	 * @param CoffeeMakerInterface $coffee_maker
190
+	 * @param string               $type
191
+	 * @return bool
192
+	 */
193
+	public function addCoffeeMaker(CoffeeMakerInterface $coffee_maker, $type)
194
+	{
195
+		$type = CoffeeMaker::validateType($type);
196
+		return $this->coffee_makers->add($coffee_maker, $type);
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * @param string   $identifier
203
+	 * @param callable $closure
204
+	 * @return callable|null
205
+	 */
206
+	public function addClosure($identifier, $closure)
207
+	{
208
+		if ( ! is_callable($closure)) {
209
+			throw new InvalidDataTypeException('$closure', $closure, 'Closure');
210
+		}
211
+		$identifier = $this->processIdentifier($identifier);
212
+		if ($this->reservoir->add($closure, $identifier)) {
213
+			return $closure;
214
+		}
215
+		return null;
216
+	}
217
+
218
+
219
+
220
+	/**
221
+	 * @param string   $identifier
222
+	 * @return boolean
223
+	 */
224
+	public function removeClosure($identifier)
225
+	{
226
+		$identifier = $this->processIdentifier($identifier);
227
+		if ($this->reservoir->has($identifier)) {
228
+			$this->reservoir->remove($this->reservoir->get($identifier));
229
+			if ( ! $this->reservoir->has($identifier)) {
230
+				return true;
231
+			}
232
+		}
233
+		return false;
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * @param  string $identifier Identifier for the entity class that the service applies to
240
+	 *                            Typically a Fully Qualified Class Name
241
+	 * @param mixed  $service
242
+	 * @return bool
243
+	 */
244
+	public function addService($identifier, $service)
245
+	{
246
+		$identifier = $this->processIdentifier($identifier);
247
+		$service = $this->validateService($identifier, $service);
248
+		return $this->carafe->add($service, $identifier);
249
+	}
250
+
251
+
252
+
253
+	/**
254
+	 * @param string $identifier
255
+	 * @return boolean
256
+	 */
257
+	public function removeService($identifier)
258
+	{
259
+		$identifier = $this->processIdentifier($identifier);
260
+		if ($this->carafe->has($identifier)) {
261
+			$this->carafe->remove($this->carafe->get($identifier));
262
+			if ( ! $this->carafe->has($identifier)) {
263
+				return true;
264
+			}
265
+		}
266
+		return false;
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * Adds instructions on how to brew objects
273
+	 *
274
+	 * @param RecipeInterface $recipe
275
+	 * @return mixed
276
+	 */
277
+	public function addRecipe(RecipeInterface $recipe)
278
+	{
279
+		$this->addAliases($recipe->identifier(), $recipe->filters());
280
+		$identifier = $this->processIdentifier($recipe->identifier());
281
+		return $this->recipes->add($recipe, $identifier);
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * @param string $identifier The Recipe's identifier
288
+	 * @return boolean
289
+	 */
290
+	public function removeRecipe($identifier)
291
+	{
292
+		$identifier = $this->processIdentifier($identifier);
293
+		if ($this->recipes->has($identifier)) {
294
+			$this->recipes->remove(
295
+				$this->recipes->get($identifier)
296
+			);
297
+			if ( ! $this->recipes->has($identifier)) {
298
+				return true;
299
+			}
300
+		}
301
+		return false;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * Get instructions on how to brew objects
308
+	 *
309
+	 * @param  string $identifier Identifier for the entity class that the recipe applies to
310
+	 *                            Typically a Fully Qualified Class Name
311
+	 * @param string $type
312
+	 * @return RecipeInterface
313
+	 */
314
+	public function getRecipe($identifier, $type = '')
315
+	{
316
+		$identifier = $this->processIdentifier($identifier);
317
+		if ($this->recipes->has($identifier)) {
318
+			return $this->recipes->get($identifier);
319
+		}
320
+		$default_recipes = $this->getDefaultRecipes();
321
+		$matches = array();
322
+		foreach ($default_recipes as $wildcard => $default_recipe) {
323
+			// is the wildcard recipe prefix in the identifier ?
324
+			if (strpos($identifier, $wildcard) !== false) {
325
+				// track matches and use the number of wildcard characters matched for the key
326
+				$matches[strlen($wildcard)] = $default_recipe;
327
+			}
328
+		}
329
+		if (count($matches) > 0) {
330
+			// sort our recipes by the number of wildcard characters matched
331
+			ksort($matches);
332
+			// then grab the last recipe form the list, since it had the most matching characters
333
+			$match = array_pop($matches);
334
+			// since we are using a default recipe, we need to set it's identifier and fqcn
335
+			return $this->copyDefaultRecipe($match, $identifier, $type);
336
+		}
337
+		if ($this->recipes->has(Recipe::DEFAULT_ID)) {
338
+			// since we are using a default recipe, we need to set it's identifier and fqcn
339
+			return $this->copyDefaultRecipe($this->recipes->get(Recipe::DEFAULT_ID), $identifier, $type);
340
+		}
341
+		throw new OutOfBoundsException(
342
+			sprintf(
343
+				__('Could not brew coffee because no recipes were found for class "%1$s".', 'event_espresso'),
344
+				$identifier
345
+			)
346
+		);
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * adds class name aliases to list of filters
353
+	 *
354
+	 * @param  string $identifier Identifier for the entity class that the alias applies to
355
+	 *                            Typically a Fully Qualified Class Name
356
+	 * @param  array  $aliases
357
+	 * @return void
358
+	 * @throws InvalidIdentifierException
359
+	 */
360
+	public function addAliases($identifier, $aliases)
361
+	{
362
+		if (empty($aliases)) {
363
+			return;
364
+		}
365
+		$identifier = $this->processIdentifier($identifier);
366
+		foreach ((array)$aliases as $alias) {
367
+			$this->filters[$this->processIdentifier($alias)] = $identifier;
368
+		}
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Adds a service to one of the internal collections
375
+	 *
376
+	 * @param        $identifier
377
+	 * @param array  $arguments
378
+	 * @param string $type
379
+	 * @return mixed
380
+	 * @throws ServiceExistsException
381
+	 */
382
+	private function makeCoffee($identifier, $arguments = array(), $type = '')
383
+	{
384
+		if ((empty($type) || $type === CoffeeMaker::BREW_SHARED) && $this->has($identifier)) {
385
+			throw new ServiceExistsException($identifier);
386
+		}
387
+		$identifier = $this->filterIdentifier($identifier);
388
+		$recipe = $this->getRecipe($identifier, $type);
389
+		$type = ! empty($type) ? $type : $recipe->type();
390
+		$coffee_maker = $this->getCoffeeMaker($type);
391
+		return $coffee_maker->brew($recipe, $arguments);
392
+	}
393
+
394
+
395
+
396
+	/**
397
+	 * filters alias identifiers to find the real class name
398
+	 *
399
+	 * @param  string $identifier Identifier for the entity class that the filter applies to
400
+	 *                            Typically a Fully Qualified Class Name
401
+	 * @return string
402
+	 * @throws InvalidIdentifierException
403
+	 */
404
+	private function filterIdentifier($identifier)
405
+	{
406
+		$identifier = $this->processIdentifier($identifier);
407
+		return isset($this->filters[$identifier]) && ! empty($this->filters[$identifier])
408
+			? $this->filters[$identifier]
409
+			: $identifier;
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * verifies and standardizes identifiers
416
+	 *
417
+	 * @param  string $identifier Identifier for the entity class
418
+	 *                            Typically a Fully Qualified Class Name
419
+	 * @return string
420
+	 * @throws InvalidIdentifierException
421
+	 */
422
+	private function processIdentifier($identifier)
423
+	{
424
+		if ( ! is_string($identifier)) {
425
+			throw new InvalidIdentifierException(
426
+				is_object($identifier) ? get_class($identifier) : gettype($identifier),
427
+				'\Fully\Qualified\ClassName'
428
+			);
429
+		}
430
+		return ltrim($identifier, '\\');
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * @param string $type
437
+	 * @return CoffeeMakerInterface
438
+	 * @throws InvalidDataTypeException
439
+	 * @throws InvalidClassException
440
+	 */
441
+	private function getCoffeeMaker($type)
442
+	{
443
+		if ( ! $this->coffee_makers->has($type)) {
444
+			throw new OutOfBoundsException(
445
+				__('The requested coffee maker is either missing or invalid.', 'event_espresso')
446
+			);
447
+		}
448
+		return $this->coffee_makers->get($type);
449
+	}
450
+
451
+
452
+
453
+	/**
454
+	 * Retrieves all recipes that use a wildcard "*" in their identifier
455
+	 * This allows recipes to be set up for handling
456
+	 * legacy classes that do not support PSR-4 autoloading.
457
+	 * for example:
458
+	 * using "EEM_*" for a recipe identifier would target all legacy models like EEM_Attendee
459
+	 *
460
+	 * @return array
461
+	 */
462
+	private function getDefaultRecipes()
463
+	{
464
+		$default_recipes = array();
465
+		$this->recipes->rewind();
466
+		while ($this->recipes->valid()) {
467
+			$identifier = $this->recipes->getInfo();
468
+			// does this recipe use a wildcard ? (but is NOT the global default)
469
+			if ($identifier !== Recipe::DEFAULT_ID && strpos($identifier, '*') !== false) {
470
+				// strip the wildcard and use identifier as key
471
+				$default_recipes[str_replace('*', '', $identifier)] = $this->recipes->current();
472
+			}
473
+			$this->recipes->next();
474
+		}
475
+		return $default_recipes;
476
+	}
477
+
478
+
479
+
480
+	/**
481
+	 * clones a default recipe and then copies details
482
+	 * from the incoming request to it so that it can be used
483
+	 *
484
+	 * @param RecipeInterface $default_recipe
485
+	 * @param string          $identifier
486
+	 * @param string          $type
487
+	 * @return RecipeInterface
488
+	 */
489
+	private function copyDefaultRecipe(RecipeInterface $default_recipe, $identifier, $type = '')
490
+	{
491
+		$recipe = clone $default_recipe;
492
+		if ( ! empty($type)) {
493
+			$recipe->setType($type);
494
+		}
495
+		// is this the base default recipe ?
496
+		if ($default_recipe->identifier() === Recipe::DEFAULT_ID) {
497
+			$recipe->setIdentifier($identifier);
498
+			$recipe->setFqcn($identifier);
499
+			return $recipe;
500
+		}
501
+		$recipe->setIdentifier($identifier);
502
+		foreach ($default_recipe->paths() as $path) {
503
+			$path = str_replace('*', $identifier, $path);
504
+			if (is_readable($path)) {
505
+				$recipe->setPaths($path);
506
+			}
507
+		}
508
+		$recipe->setFqcn($identifier);
509
+		return $recipe;
510
+	}
511
+
512
+
513
+
514
+	/**
515
+	 * @param  string $identifier Identifier for the entity class that the service applies to
516
+	 *                            Typically a Fully Qualified Class Name
517
+	 * @param mixed  $service
518
+	 * @return object
519
+	 * @throws InvalidServiceException
520
+	 */
521
+	private function validateService($identifier, $service)
522
+	{
523
+		if ( ! is_object($service)) {
524
+			throw new InvalidServiceException(
525
+				$identifier,
526
+				$service
527
+			);
528
+		}
529
+		return $service;
530
+	}
531 531
 
532 532
 }
533 533
 // End of file CoffeeShop.php
Please login to merge, or discard this patch.
core/services/container/exceptions/ServiceNotFoundException.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\services\container\exceptions;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -18,28 +18,28 @@  discard block
 block discarded – undo
18 18
 class ServiceNotFoundException extends \RuntimeException
19 19
 {
20 20
 
21
-    /**
22
-     * ServiceNotFoundException constructor
23
-     *
24
-     * @param string     $service_name the name of the requested service
25
-     * @param string     $message
26
-     * @param int        $code
27
-     * @param \Exception $previous
28
-     */
29
-    public function __construct(
30
-        $service_name,
31
-        $message = '',
32
-        $code = 0,
33
-        \Exception $previous = null
34
-    ) {
35
-        if (empty($message)) {
36
-            $message = sprintf(
37
-                __('The requested service "%1$s" could not found be found in the CoffeeShop.', 'event_espresso'),
38
-                $service_name
39
-            );
40
-        }
41
-        parent::__construct($message, $code, $previous);
42
-    }
21
+	/**
22
+	 * ServiceNotFoundException constructor
23
+	 *
24
+	 * @param string     $service_name the name of the requested service
25
+	 * @param string     $message
26
+	 * @param int        $code
27
+	 * @param \Exception $previous
28
+	 */
29
+	public function __construct(
30
+		$service_name,
31
+		$message = '',
32
+		$code = 0,
33
+		\Exception $previous = null
34
+	) {
35
+		if (empty($message)) {
36
+			$message = sprintf(
37
+				__('The requested service "%1$s" could not found be found in the CoffeeShop.', 'event_espresso'),
38
+				$service_name
39
+			);
40
+		}
41
+		parent::__construct($message, $code, $previous);
42
+	}
43 43
 }
44 44
 // End of file ServiceNotFoundException.php
45 45
 // Location: /ServiceNotFoundException.php
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/container/exceptions/ServiceExistsException.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\services\container\exceptions;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * ServiceExistsException constructor
24
-     *
25
-     * @param string     $service_name the name of the requested service
26
-     * @param string     $message
27
-     * @param int        $code
28
-     * @param \Exception $previous
29
-     */
30
-    public function __construct(
31
-        $service_name,
32
-        $message = '',
33
-        $code = 0,
34
-        \Exception $previous = null
35
-    ) {
36
-        if (empty($message)) {
37
-            $message = sprintf(
38
-                __('The "%1$s" service already exists in the CoffeeShop and can not be added again.', 'event_espresso'),
39
-                $service_name
40
-            );
41
-        }
42
-        parent::__construct($message, $code, $previous);
43
-    }
22
+	/**
23
+	 * ServiceExistsException constructor
24
+	 *
25
+	 * @param string     $service_name the name of the requested service
26
+	 * @param string     $message
27
+	 * @param int        $code
28
+	 * @param \Exception $previous
29
+	 */
30
+	public function __construct(
31
+		$service_name,
32
+		$message = '',
33
+		$code = 0,
34
+		\Exception $previous = null
35
+	) {
36
+		if (empty($message)) {
37
+			$message = sprintf(
38
+				__('The "%1$s" service already exists in the CoffeeShop and can not be added again.', 'event_espresso'),
39
+				$service_name
40
+			);
41
+		}
42
+		parent::__construct($message, $code, $previous);
43
+	}
44 44
 
45 45
 
46 46
 }
Please login to merge, or discard this patch.