Completed
Branch FET-7999-purchasing-agent (117637)
by
unknown
127:29 queued 117:09
created
strategies/validation/EE_Simple_HTML_Validation_Strategy.strategy.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@  discard block
 block discarded – undo
10 10
  * @since 				4.6
11 11
  *
12 12
  */
13
-class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{
13
+class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base {
14 14
 
15 15
 	/**
16 16
 	 * @param null $validation_error_message
17 17
 	 */
18
-	public function __construct( $validation_error_message = NULL ) {
19
-		if( ! $validation_error_message ){
18
+	public function __construct($validation_error_message = NULL) {
19
+		if ( ! $validation_error_message) {
20 20
 			$allowedtags = $this->_get_allowed_tags();
21
-			$validation_error_message = sprintf( __( "Only simple HTML tags are allowed. Eg, %s", "event_espresso" ), implode( ",", array_keys( $allowedtags ) ) );
21
+			$validation_error_message = sprintf(__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags)));
22 22
 		}
23
-		parent::__construct( $validation_error_message );
23
+		parent::__construct($validation_error_message);
24 24
 	}
25 25
 
26 26
 
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	protected function _get_allowed_tags() {
32 32
 		global $allowedtags;
33
-		$allowedtags[ 'ol' ] = array();
34
-		$allowedtags[ 'ul' ] = array();
35
-		$allowedtags[ 'li' ] = array();
36
-		$allowedtags[ 'br' ] = array();
37
-		$allowedtags[ 'p' ] = array();
33
+		$allowedtags['ol'] = array();
34
+		$allowedtags['ul'] = array();
35
+		$allowedtags['li'] = array();
36
+		$allowedtags['br'] = array();
37
+		$allowedtags['p'] = array();
38 38
 		return $allowedtags;
39 39
 	}
40 40
 
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function validate($normalized_value) {
48 48
 		$allowedtags = $this->_get_allowed_tags();
49
-		parent::validate( $normalized_value );
50
-		$normalized_value_sans_tags =  wp_kses( "$normalized_value",$allowedtags );
51
-		if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) {
52
-			throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' );
49
+		parent::validate($normalized_value);
50
+		$normalized_value_sans_tags = wp_kses("$normalized_value", $allowedtags);
51
+		if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) {
52
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags');
53 53
 		}
54 54
 	}
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
strategies/validation/EE_Validation_Strategy_Base.strategy.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since 				4.6
9 9
  *
10 10
  */
11
-abstract class EE_Validation_Strategy_Base extends EE_Form_Input_Strategy_Base{
11
+abstract class EE_Validation_Strategy_Base extends EE_Form_Input_Strategy_Base {
12 12
 
13 13
 
14 14
 	protected $_validation_error_message = '';
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * @param null $validation_error_message
20 20
 	 */
21
-	public function __construct( $validation_error_message = NULL ) {
22
-		$this->_validation_error_message = $validation_error_message === NULL ? __( 'Input invalid', 'event_espresso' ) : $validation_error_message ;
21
+	public function __construct($validation_error_message = NULL) {
22
+		$this->_validation_error_message = $validation_error_message === NULL ? __('Input invalid', 'event_espresso') : $validation_error_message;
23 23
 		parent::__construct();
24 24
 	}
25 25
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
35 35
 	 * this validation strategy is the 'required' validation strategy, most should be OK with a null, empty string, etc)
36 36
 	 */
37
-	function validate($normalized_value){
37
+	function validate($normalized_value) {
38 38
 		//by default, the validation strategy does no validation. this should be implemented
39 39
 	}
40 40
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return array
60 60
 	 */
61
-	function get_jquery_validation_rule_array(){
61
+	function get_jquery_validation_rule_array() {
62 62
 		return array();
63 63
 	}
64 64
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * the input is invalid. Used for both frontend and backend validation.
68 68
 	 * @return string
69 69
 	 */
70
-	function get_validation_error_message(){
70
+	function get_validation_error_message() {
71 71
 		return $this->_validation_error_message;
72 72
 	}
73 73
 }
74 74
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/line_item_display/EE_Line_Item_Display.class.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_Line_Item_Display
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author				Brent Christensen
11
- * @since		 	   $VID:$
12
- *
13
- */
3
+  *
4
+  * Class EE_Line_Item_Display
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author				Brent Christensen
11
+  * @since		 	   $VID:$
12
+  *
13
+  */
14 14
 class EE_Line_Item_Display {
15 15
 
16 16
 	private $strategy = NULL;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 * @param string $context - where/how the line items are being displayed
22 22
 	 * @param string $other_line_item_display_strategy
23 23
 	 */
24
-	public function __construct( $context = '', $other_line_item_display_strategy = '' ) {
25
-		$context = strtolower( $context );
26
-		switch ( $context ) {
24
+	public function __construct($context = '', $other_line_item_display_strategy = '') {
25
+		$context = strtolower($context);
26
+		switch ($context) {
27 27
 			case 'invoice' :
28 28
 				$this->strategy = new EE_Invoice_Line_Item_Display_Strategy();
29 29
 				break;
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 				break;
36 36
 			default :
37 37
 				if (
38
-					! empty( $other_line_item_display_strategy ) &&
39
-					class_exists( $other_line_item_display_strategy )
38
+					! empty($other_line_item_display_strategy) &&
39
+					class_exists($other_line_item_display_strategy)
40 40
 				) {
41 41
 					$this->strategy = new  $other_line_item_display_strategy();
42 42
 				} else {
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @param array        $options
51 51
 	 * @return mixed
52 52
 	 */
53
-	public function display_line_item( EE_Line_Item $line_item, $options = array() ) {
54
-		return $this->strategy->display_line_item( $line_item, $options );
53
+	public function display_line_item(EE_Line_Item $line_item, $options = array()) {
54
+		return $this->strategy->display_line_item($line_item, $options);
55 55
 	}
56 56
 
57 57
 
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Billable_Line_Item_Filter.class.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Billable_Line_Item_Filter
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	 * EE_Billable_Line_Item_Filter constructor.
26 26
 	 * @param EE_Registration[] $registrations
27 27
 	 */
28
-	public function __construct( $registrations ) {
29
-		parent::__construct( $this->_remove_unbillable_registrations( $registrations ) );
28
+	public function __construct($registrations) {
29
+		parent::__construct($this->_remove_unbillable_registrations($registrations));
30 30
 	}
31 31
 
32 32
 
@@ -39,25 +39,24 @@  discard block
 block discarded – undo
39 39
 	 * @param EE_Registration[] $registrations
40 40
 	 * @return mixed
41 41
 	 */
42
-	protected function _remove_unbillable_registrations( $registrations = array() ) {
43
-		if ( ! empty( $registrations ) ) {
42
+	protected function _remove_unbillable_registrations($registrations = array()) {
43
+		if ( ! empty($registrations)) {
44 44
 			// these reg statuses require payment (if event is not free)
45 45
 			$requires_payment = EEM_Registration::reg_statuses_that_allow_payment();
46
-			foreach ( $registrations as $key => $registration ) {
47
-				if ( ! $registration instanceof EE_Registration ) {
46
+			foreach ($registrations as $key => $registration) {
47
+				if ( ! $registration instanceof EE_Registration) {
48 48
 					continue;
49 49
 				}
50 50
 				// are we billing for this registration at this moment ?
51
-				if ( !
52
-					$registration->owes_monies_and_can_pay( $requires_payment ) &&
51
+				if ( ! $registration->owes_monies_and_can_pay($requires_payment) &&
53 52
 					! (
54 53
 						// free registration with valid reg status
55 54
 						$registration->final_price() == 0 &&
56
-						in_array( $registration->status_ID(), $requires_payment )
55
+						in_array($registration->status_ID(), $requires_payment)
57 56
 					)
58 57
 				) {
59 58
 					// not billable. remove it
60
-					unset( $registrations[ $key ] );
59
+					unset($registrations[$key]);
61 60
 				}
62 61
 			}
63 62
 		}
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Line_Item_Filter_Collection.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Line_Item_Filter_Collection
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Line_Item_Filter_Processor.class.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Line_Item_Filter_Processor
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 	 * @param \EEI_Line_Item                  $grand_total_line_item
56 56
 	 * @throws \EE_Error
57 57
 	 */
58
-	public function __construct( EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item ) {
58
+	public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item) {
59 59
 		$this->line_item_filters = $line_item_filters;
60
-		if ( $grand_total_line_item->type() !== EEM_Line_Item::type_total ) {
61
-			throw new EE_Error( __( 'A Line Item of the type total is required', 'event_espresso' ) );
60
+		if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) {
61
+			throw new EE_Error(__('A Line Item of the type total is required', 'event_espresso'));
62 62
 		}
63
-		$this->grand_total_line_item = $this->clone_and_reset_line_item_tree( $grand_total_line_item );
63
+		$this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item);
64 64
 	}
65 65
 
66 66
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	 * @param \EEI_Line_Item $line_item
72 72
 	 * @return \EEI_Line_Item
73 73
 	 */
74
-	protected function clone_and_reset_line_item_tree( EEI_Line_Item $line_item ) {
75
-		$cloned_line_item = $this->clone_and_reset_line_item( $line_item );
76
-		foreach ( $line_item->children() as $child_line_item ) {
77
-			$cloned_line_item->add_child_line_item( $this->clone_and_reset_line_item_tree( $child_line_item ) );
74
+	protected function clone_and_reset_line_item_tree(EEI_Line_Item $line_item) {
75
+		$cloned_line_item = $this->clone_and_reset_line_item($line_item);
76
+		foreach ($line_item->children() as $child_line_item) {
77
+			$cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item));
78 78
 		}
79 79
 		return $cloned_line_item;
80 80
 	}
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 	 * @param \EEI_Line_Item $line_item
92 92
 	 * @return \EEI_Line_Item
93 93
 	 */
94
-	protected function clone_and_reset_line_item( EEI_Line_Item $line_item ) {
94
+	protected function clone_and_reset_line_item(EEI_Line_Item $line_item) {
95 95
 		// we don't actually want to work with the original line item, so clone it
96 96
 		$cloned_line_item = clone $line_item;
97
-		$cloned_line_item->set( 'LIN_ID', null );
98
-		$cloned_line_item->set( 'LIN_parent', null );
97
+		$cloned_line_item->set('LIN_ID', null);
98
+		$cloned_line_item->set('LIN_parent', null);
99 99
 		$cloned_line_item->clear_related_line_item_cache();
100
-		foreach( array_keys( EEM_Line_Item::instance()->relation_settings() ) as $relation_name) {
101
-			$cloned_line_item->clear_cache( $relation_name, null, true );
100
+		foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) {
101
+			$cloned_line_item->clear_cache($relation_name, null, true);
102 102
 		}
103
-		$cloned_line_item->set_allow_persist( false );
103
+		$cloned_line_item->set_allow_persist(false);
104 104
 		return $cloned_line_item;
105 105
 	}
106 106
 
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function process() {
115 115
 		$this->line_item_filters->rewind();
116
-		while ( $this->line_item_filters->valid() ) {
117
-			$this->grand_total_line_item = $this->line_item_filters->current()->process( $this->grand_total_line_item );
116
+		while ($this->line_item_filters->valid()) {
117
+			$this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item);
118 118
 			$this->line_item_filters->next();
119 119
 		}
120 120
 		$this->grand_total_line_item->recalculate_total_including_taxes();
Please login to merge, or discard this patch.
core/libraries/line_item_filters/EE_Non_Zero_Line_Item_Filter.class.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Non_Zero_Line_Item_Filter
@@ -31,36 +31,36 @@  discard block
 block discarded – undo
31 31
 	 * @param EEI_Line_Item $line_item
32 32
 	 * @return \EEI_Line_Item
33 33
 	 */
34
-	public function process( EEI_Line_Item $line_item ) {
35
-		$non_zero_line_item = $this->_filter_zero_line_item( $line_item );
36
-		if ( ! $non_zero_line_item instanceof EEI_Line_Item ) {
34
+	public function process(EEI_Line_Item $line_item) {
35
+		$non_zero_line_item = $this->_filter_zero_line_item($line_item);
36
+		if ( ! $non_zero_line_item instanceof EEI_Line_Item) {
37 37
 			return null;
38 38
 		}
39 39
 		//if this is an event subtotal, we want to only include it if it
40 40
 		//has a non-zero total and at least one ticket line item child
41
-		if( $line_item->children() ) {
41
+		if ($line_item->children()) {
42 42
 			$ticket_or_subtotals_with_tkt_children_count = 0;
43
-			foreach ( $line_item->children() as $child_line_item ) {
43
+			foreach ($line_item->children() as $child_line_item) {
44 44
 				$code = $child_line_item->code();
45
-				$child_line_item = $this->process( $child_line_item );
46
-				if( ! $child_line_item instanceof EEI_Line_Item ) {
47
-					$line_item->delete_child_line_item( $code );
45
+				$child_line_item = $this->process($child_line_item);
46
+				if ( ! $child_line_item instanceof EEI_Line_Item) {
47
+					$line_item->delete_child_line_item($code);
48 48
 					continue;
49 49
 				}
50 50
 				if (
51
-					( $child_line_item instanceof EEI_Line_Item &&
51
+					($child_line_item instanceof EEI_Line_Item &&
52 52
 					$child_line_item->type() === EEM_Line_Item::type_line_item &&
53
-					$child_line_item->OBJ_type() === 'Ticket' ) ||
54
-					( $child_line_item instanceof EEI_Line_Item &&
55
-					 $child_line_item->type() === EEM_Line_Item::type_sub_total )
53
+					$child_line_item->OBJ_type() === 'Ticket') ||
54
+					($child_line_item instanceof EEI_Line_Item &&
55
+					 $child_line_item->type() === EEM_Line_Item::type_sub_total)
56 56
 				) {
57 57
 					$ticket_or_subtotals_with_tkt_children_count++;
58 58
 				}
59 59
 			}
60 60
 			// if this is an event subtotal with NO ticket children
61 61
 			// we basically want to ignore it
62
-			return $this->_filter_zero_subtotal_line_item( $non_zero_line_item, $ticket_or_subtotals_with_tkt_children_count );
63
-		}else{
62
+			return $this->_filter_zero_subtotal_line_item($non_zero_line_item, $ticket_or_subtotals_with_tkt_children_count);
63
+		} else {
64 64
 			return $non_zero_line_item;
65 65
 		}
66 66
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param EEI_Line_Item $line_item
74 74
 	 * @return EEI_Line_Item
75 75
 	 */
76
-	protected function _filter_zero_line_item( EEI_Line_Item $line_item ) {
76
+	protected function _filter_zero_line_item(EEI_Line_Item $line_item) {
77 77
 		if (
78 78
 			$line_item->type() === EEM_Line_Item::type_line_item &&
79 79
 			$line_item->OBJ_type() === 'Ticket' &&
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param int           $ticket_children
94 94
 	 * @return \EEI_Line_Item
95 95
 	 */
96
-	protected function _filter_zero_subtotal_line_item( EEI_Line_Item $line_item, $ticket_children = 0 ) {
96
+	protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0) {
97 97
 		if (
98 98
 			$line_item->type() === EEM_Line_Item::type_sub_total &&
99 99
 			$ticket_children === 0
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 			// if this is an event subtotal with NO ticket children
61 61
 			// we basically want to ignore it
62 62
 			return $this->_filter_zero_subtotal_line_item( $non_zero_line_item, $ticket_or_subtotals_with_tkt_children_count );
63
-		}else{
63
+		} else{
64 64
 			return $non_zero_line_item;
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
line_item_filters/EE_Single_Registration_Line_Item_Filter.class.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Single_Registration_Line_Item_Filter
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param EE_Registration $registration
23 23
 	 */
24
-	public function __construct( $registration ) {
25
-		parent::__construct( array( $registration ) );
24
+	public function __construct($registration) {
25
+		parent::__construct(array($registration));
26 26
 	}
27 27
 }
28 28
 // End of file EE_Single_Registration_Line_Item_Filter.class.php
Please login to merge, or discard this patch.
line_item_filters/EE_Specific_Registrations_Line_Item_Filter.class.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Specific_Registrations_Line_Item_Filter extends EE_Line_Item_Filter_Base {
20 20
 /**
21
-	 * array of line item codes and their corresponding quantities for
22
-	 * registrations that owe money and can pay at this moment
23
-	 * @type array $_counts_per_line_item_code
24
-	 */
21
+ * array of line item codes and their corresponding quantities for
22
+ * registrations that owe money and can pay at this moment
23
+ * @type array $_counts_per_line_item_code
24
+ */
25 25
 	protected $_counts_per_line_item_code = array();
26 26
 
27 27
 	/**
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 * EE_Billable_Line_Item_Filter constructor.
37 37
 	 * @param EE_Registration[] $registrations
38 38
 	 */
39
-	public function __construct( $registrations ) {
39
+	public function __construct($registrations) {
40 40
 		$this->_registrations = $registrations;
41
-		$this->_calculate_counts_per_line_item_code( $registrations );
41
+		$this->_calculate_counts_per_line_item_code($registrations);
42 42
 	}
43 43
 
44 44
 	/**
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	 * @param EE_Registration[] $registrations
47 47
 	 * @return void
48 48
 	 */
49
-	protected function _calculate_counts_per_line_item_code( $registrations ) {
50
-		foreach( $registrations as $registration ) {
51
-			$line_item_code = EEM_Line_Item::instance()->get_var( EEM_Line_Item::instance()->line_item_for_registration_query_params( $registration, array( 'limit' => 1 ) ), 'LIN_code' );
52
-			if( $line_item_code ) {
53
-				if( ! isset( $this->_counts_per_line_item_code[ $line_item_code ] ) ) {
54
-					$this->_counts_per_line_item_code[ $line_item_code ] = 1;
55
-				}else{
56
-					$this->_counts_per_line_item_code[ $line_item_code ]++;
49
+	protected function _calculate_counts_per_line_item_code($registrations) {
50
+		foreach ($registrations as $registration) {
51
+			$line_item_code = EEM_Line_Item::instance()->get_var(EEM_Line_Item::instance()->line_item_for_registration_query_params($registration, array('limit' => 1)), 'LIN_code');
52
+			if ($line_item_code) {
53
+				if ( ! isset($this->_counts_per_line_item_code[$line_item_code])) {
54
+					$this->_counts_per_line_item_code[$line_item_code] = 1;
55
+				} else {
56
+					$this->_counts_per_line_item_code[$line_item_code]++;
57 57
 				}
58 58
 			}
59 59
 		}
@@ -67,57 +67,57 @@  discard block
 block discarded – undo
67 67
 	 * @param EEI_Line_Item      $line_item
68 68
 	 * @return \EEI_Line_Item
69 69
 	 */
70
-	public function process( EEI_Line_Item $line_item ) {
71
-		$this->_filter_billable_line_item( $line_item );
72
-		if( ! $line_item->children() ) {
70
+	public function process(EEI_Line_Item $line_item) {
71
+		$this->_filter_billable_line_item($line_item);
72
+		if ( ! $line_item->children()) {
73 73
 			return $line_item;
74 74
 		}
75 75
 		//the original running total (taking ALL tickets into account)
76 76
 		$running_total_of_children = 0;
77 77
 		//the new running total (only taking the specified ticket quantities into account)
78 78
 		$runnign_total_of_children_under_consideration = 0;
79
-		foreach ( $line_item->children() as $child_line_item ) {
80
-			if( $child_line_item->is_percent() ) {
79
+		foreach ($line_item->children() as $child_line_item) {
80
+			if ($child_line_item->is_percent()) {
81 81
 				$original_li_total = $running_total_of_children * $child_line_item->percent() / 100;
82
-			}else{
82
+			} else {
83 83
 				$original_li_total = $child_line_item->unit_price() * $child_line_item->quantity();
84 84
 			}
85 85
 
86
-			$this->process( $child_line_item );
86
+			$this->process($child_line_item);
87 87
 			/*
88 88
 			 * If this line item is a normal line item that isn't for a ticket
89 89
 			 * we want to modify its total (and unit price if not a percentage line item)
90 90
 			 * so it reflects only that portion of the surcharge/discount shared by these
91 91
 			 * registrations
92 92
 			 */
93
-			if( $child_line_item->type() === EEM_Line_Item::type_line_item &&
94
-					$child_line_item->OBJ_type() !== 'Ticket' ) {
95
-				if( $running_total_of_children ) {
93
+			if ($child_line_item->type() === EEM_Line_Item::type_line_item &&
94
+					$child_line_item->OBJ_type() !== 'Ticket') {
95
+				if ($running_total_of_children) {
96 96
 					$percent_of_running_total = $original_li_total / $running_total_of_children;
97 97
 				} else {
98 98
 					$percent_of_running_total = 0;
99 99
 				}
100 100
 
101
-				$child_line_item->set_total( $runnign_total_of_children_under_consideration * $percent_of_running_total );
102
-				if( ! $child_line_item->is_percent() ) {
103
-					$child_line_item->set_unit_price( $child_line_item->total() / $child_line_item->quantity() );
101
+				$child_line_item->set_total($runnign_total_of_children_under_consideration * $percent_of_running_total);
102
+				if ( ! $child_line_item->is_percent()) {
103
+					$child_line_item->set_unit_price($child_line_item->total() / $child_line_item->quantity());
104 104
 				}
105
-			}elseif( $line_item->type() === EEM_Line_Item::type_line_item &&
106
-					$line_item->OBJ_type() === 'Ticket' ) {
105
+			}elseif ($line_item->type() === EEM_Line_Item::type_line_item &&
106
+					$line_item->OBJ_type() === 'Ticket') {
107 107
 				//make sure this item's quantity matches its parent
108
-				if( ! $child_line_item->is_percent() ) {
109
-					$child_line_item->set_quantity( $line_item->quantity() );
110
-					$child_line_item->set_total( $child_line_item->unit_price() * $child_line_item->quantity() );
108
+				if ( ! $child_line_item->is_percent()) {
109
+					$child_line_item->set_quantity($line_item->quantity());
110
+					$child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity());
111 111
 				}
112 112
 			}
113 113
 			$running_total_of_children += $original_li_total;
114 114
 			$runnign_total_of_children_under_consideration += $child_line_item->total();
115 115
 		}
116
-		$line_item->set_total( $runnign_total_of_children_under_consideration );
117
-		if( $line_item->quantity() ) {
118
-			$line_item->set_unit_price( $runnign_total_of_children_under_consideration / $line_item->quantity() );
116
+		$line_item->set_total($runnign_total_of_children_under_consideration);
117
+		if ($line_item->quantity()) {
118
+			$line_item->set_unit_price($runnign_total_of_children_under_consideration / $line_item->quantity());
119 119
 		} else {
120
-			$line_item->set_unit_price( 0 );
120
+			$line_item->set_unit_price(0);
121 121
 		}
122 122
 		return $line_item;
123 123
 	}
@@ -130,18 +130,18 @@  discard block
 block discarded – undo
130 130
 	 * @param EEI_Line_Item $line_item
131 131
 	 * @return EEI_Line_Item
132 132
 	 */
133
-	protected function _filter_billable_line_item( EEI_Line_Item $line_item ) {
133
+	protected function _filter_billable_line_item(EEI_Line_Item $line_item) {
134 134
 		// is this a ticket ?
135
-		if ( $line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket' ) {
135
+		if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket') {
136 136
 			// if this ticket is billable at this moment, then we should have a positive quantity
137
-			if ( isset( $this->_counts_per_line_item_code[ $line_item->code() ] )) {
137
+			if (isset($this->_counts_per_line_item_code[$line_item->code()])) {
138 138
 				// set quantity based on number of billable registrations for this ticket
139
-				$quantity = $this->_counts_per_line_item_code[ $line_item->code() ];
139
+				$quantity = $this->_counts_per_line_item_code[$line_item->code()];
140 140
 			} else {
141 141
 				$quantity = 0;
142 142
 			}
143
-			$line_item->set_quantity( $quantity );
144
-			$line_item->set_total( $line_item->unit_price() * $line_item->quantity() );
143
+			$line_item->set_quantity($quantity);
144
+			$line_item->set_total($line_item->unit_price() * $line_item->quantity());
145 145
 		}
146 146
 		return $line_item;
147 147
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			if( $line_item_code ) {
53 53
 				if( ! isset( $this->_counts_per_line_item_code[ $line_item_code ] ) ) {
54 54
 					$this->_counts_per_line_item_code[ $line_item_code ] = 1;
55
-				}else{
55
+				} else{
56 56
 					$this->_counts_per_line_item_code[ $line_item_code ]++;
57 57
 				}
58 58
 			}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		foreach ( $line_item->children() as $child_line_item ) {
80 80
 			if( $child_line_item->is_percent() ) {
81 81
 				$original_li_total = $running_total_of_children * $child_line_item->percent() / 100;
82
-			}else{
82
+			} else{
83 83
 				$original_li_total = $child_line_item->unit_price() * $child_line_item->quantity();
84 84
 			}
85 85
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 				if( ! $child_line_item->is_percent() ) {
103 103
 					$child_line_item->set_unit_price( $child_line_item->total() / $child_line_item->quantity() );
104 104
 				}
105
-			}elseif( $line_item->type() === EEM_Line_Item::type_line_item &&
105
+			} elseif( $line_item->type() === EEM_Line_Item::type_line_item &&
106 106
 					$line_item->OBJ_type() === 'Ticket' ) {
107 107
 				//make sure this item's quantity matches its parent
108 108
 				if( ! $child_line_item->is_percent() ) {
Please login to merge, or discard this patch.