Completed
Branch BUG-8511-spco-revisit-oversell... (0aad32)
by
unknown
34:42 queued 17:09
created
core/db_models/EEM_Event.model.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once( EE_MODELS . 'EEM_CPT_Base.model.php');
2
+require_once(EE_MODELS.'EEM_CPT_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * EEM_Event Model
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author				Michael Nelson, Brent Christensen
12 12
  *
13 13
  */
14
-class EEM_Event  extends EEM_CPT_Base{
14
+class EEM_Event  extends EEM_CPT_Base {
15 15
 
16 16
 	/**
17 17
 	 * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the event
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * @param string $timezone
52 52
 	 * @return EEM_Event
53 53
 	 */
54
-	public static function instance( $timezone = NULL ){
54
+	public static function instance($timezone = NULL) {
55 55
 
56 56
 		// check if instance of EEM_Event already exists
57
-		if ( ! self::$_instance instanceof EEM_Event ) {
57
+		if ( ! self::$_instance instanceof EEM_Event) {
58 58
 			// instantiate Espresso_model
59
-			self::$_instance = new self( $timezone );
59
+			self::$_instance = new self($timezone);
60 60
 		}
61 61
 		//we might have a timezone set, let set_timezone decide what to do with it
62
-		self::$_instance->set_timezone( $timezone );
62
+		self::$_instance->set_timezone($timezone);
63 63
 		// EEM_Event object
64 64
 		return self::$_instance;
65 65
 	}
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 	 * @param string $timezone
71 71
 	 * @return EEM_Event
72 72
 	 */
73
-	protected function __construct($timezone = null){
73
+	protected function __construct($timezone = null) {
74 74
 
75
-		EE_Registry::instance()->load_model( 'Registration' );
75
+		EE_Registry::instance()->load_model('Registration');
76 76
 
77
-		$this->singular_item = __('Event','event_espresso');
78
-		$this->plural_item = __('Events','event_espresso');
77
+		$this->singular_item = __('Event', 'event_espresso');
78
+		$this->plural_item = __('Events', 'event_espresso');
79 79
 
80 80
 		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
81 81
 		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
@@ -89,57 +89,57 @@  discard block
 block discarded – undo
89 89
 			array(
90 90
 				EEM_Event::cancelled => array(
91 91
 					'label' => __('Cancelled', 'event_espresso'),
92
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE )
92
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE)
93 93
 				),
94 94
 				EEM_Event::postponed => array(
95 95
 					'label' => __('Postponed', 'event_espresso'),
96
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE )
96
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE)
97 97
 				),
98 98
 				EEM_Event::sold_out => array(
99 99
 					'label' => __('Sold Out', 'event_espresso'),
100
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE )
100
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE)
101 101
 				)
102 102
 			)
103 103
 		);
104 104
 
105
-		self::$_default_reg_status = empty( self::$_default_reg_status ) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
105
+		self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status;
106 106
 
107 107
 		$this->_tables = array(
108
-			'Event_CPT'=>new EE_Primary_Table( 'posts','ID' ),
109
-			'Event_Meta'=> new EE_Secondary_Table( 'esp_event_meta', 'EVTM_ID', 'EVT_ID' )
108
+			'Event_CPT'=>new EE_Primary_Table('posts', 'ID'),
109
+			'Event_Meta'=> new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID')
110 110
 		);
111 111
 
112 112
 		$this->_fields = array(
113 113
 			'Event_CPT'=>array(
114
-				'EVT_ID'=>new EE_Primary_Key_Int_Field( 'ID', __( 'Post ID for Event','event_espresso' )),
115
-				'EVT_name'=>new EE_Plain_Text_Field( 'post_title', __( 'Event Name','event_espresso' ), FALSE, '' ),
116
-				'EVT_desc'=>new EE_Post_Content_Field( 'post_content', __( 'Event Description', 'event_espresso' ), FALSE, '' ),
117
-				'EVT_slug'=>new EE_Slug_Field( 'post_name', __( 'Event Slug', 'event_espresso' ), FALSE, '' ),
118
-				'EVT_created'=>new EE_Datetime_Field( 'post_date', __( 'Date/Time Event Created', 'event_espresso' ), FALSE, time()),
119
-				'EVT_short_desc'=>new EE_Simple_HTML_Field( 'post_excerpt', __( 'Event Short Description', 'event_espresso' ), FALSE,'' ),
120
-				'EVT_modified'=>new EE_Datetime_Field( 'post_modified', __( 'Date/Time Event Modified', 'event_espresso' ), FALSE, time()),
121
-				'EVT_wp_user'=>new EE_WP_User_Field( 'post_author', __( 'Event Creator ID', 'event_espresso'), FALSE),
122
-				'parent'=>new EE_Integer_Field( 'post_parent', __( 'Event Parent ID', 'event_espresso' ), FALSE, 0 ),
123
-				'EVT_order'=>new EE_Integer_Field( 'menu_order', __( 'Event Menu Order', 'event_espresso' ), FALSE, 1 ),
124
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'),// EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
-				'status' => new EE_WP_Post_Status_Field( 'post_status', __( 'Event Status', 'event_espresso' ), FALSE, 'draft', $this->_custom_stati )
114
+				'EVT_ID'=>new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')),
115
+				'EVT_name'=>new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''),
116
+				'EVT_desc'=>new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''),
117
+				'EVT_slug'=>new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''),
118
+				'EVT_created'=>new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, time()),
119
+				'EVT_short_desc'=>new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''),
120
+				'EVT_modified'=>new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), FALSE, time()),
121
+				'EVT_wp_user'=>new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), FALSE),
122
+				'parent'=>new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), FALSE, 0),
123
+				'EVT_order'=>new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1),
124
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'), // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
125
+				'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati)
126 126
 			),
127 127
 			'Event_Meta'=>array(
128
-				'EVTM_ID'=> new EE_DB_Only_Float_Field( 'EVTM_ID', __( 'Event Meta Row ID','event_espresso' ), FALSE ),
129
-				'EVT_ID_fk'=>new EE_DB_Only_Int_Field( 'EVT_ID', __( 'Foreign key to Event ID from Event Meta table', 'event_espresso' ), FALSE ),
130
-				'EVT_display_desc'=>new EE_Boolean_Field( 'EVT_display_desc', __( 'Display Description Flag', 'event_espresso' ), FALSE, 1 ),
131
-				'EVT_display_ticket_selector'=>new EE_Boolean_Field( 'EVT_display_ticket_selector', __( 'Display Ticket Selector Flag', 'event_espresso' ), FALSE, 1 ),
132
-				'EVT_visible_on'=>new EE_Datetime_Field( 'EVT_visible_on', __( 'Event Visible Date', 'event_espresso' ), TRUE, time()),
133
-				'EVT_additional_limit'=>new EE_Integer_Field( 'EVT_additional_limit', __( 'Limit of Additional Registrations on Same Transaction', 'event_espresso' ), TRUE, 10 ),
128
+				'EVTM_ID'=> new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE),
129
+				'EVT_ID_fk'=>new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE),
130
+				'EVT_display_desc'=>new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1),
131
+				'EVT_display_ticket_selector'=>new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1),
132
+				'EVT_visible_on'=>new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, time()),
133
+				'EVT_additional_limit'=>new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10),
134 134
 				'EVT_default_registration_status'=>new EE_Enum_Text_Field(
135
-					'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
135
+					'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array()
136 136
 				),
137
-				'EVT_member_only'=>new EE_Boolean_Field( 'EVT_member_only', __( 'Member-Only Event Flag', 'event_espresso' ), FALSE, FALSE ),
138
-				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __( 'Event Phone Number', 'event_espresso' ), FALSE ),
139
-				'EVT_allow_overflow'=>new EE_Boolean_Field(  'EVT_allow_overflow', __( 'Allow Overflow on Event', 'event_espresso' ), FALSE, FALSE ),
140
-				'EVT_timezone_string'=>new EE_Plain_Text_Field( 'EVT_timezone_string', __( 'Timezone (name) for Event times', 'event_espresso' ), FALSE ),
141
-				'EVT_external_URL'=>new EE_Plain_Text_Field( 'EVT_external_URL', __( 'URL of Event Page if hosted elsewhere', 'event_espresso' ), TRUE ),
142
-				'EVT_donations'=>new EE_Boolean_Field( 'EVT_donations', __( 'Accept Donations?', 'event_espresso' ), FALSE, FALSE )
137
+				'EVT_member_only'=>new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE),
138
+				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE),
139
+				'EVT_allow_overflow'=>new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE),
140
+				'EVT_timezone_string'=>new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE),
141
+				'EVT_external_URL'=>new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE),
142
+				'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE)
143 143
 
144 144
 			));
145 145
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			'WP_User' => new EE_Belongs_To_Relation(),
155 155
 		);
156 156
 		//this model is generally available for reading
157
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
158
-		parent::__construct( $timezone );
157
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
158
+		parent::__construct($timezone);
159 159
 	}
160 160
 
161 161
 
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	/**
164 164
 	 * @param string $default_reg_status
165 165
 	 */
166
-	public static function set_default_reg_status( $default_reg_status ) {
166
+	public static function set_default_reg_status($default_reg_status) {
167 167
 		self::$_default_reg_status = $default_reg_status;
168 168
 		//if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default.
169
-		if ( self::$_instance instanceof EEM_Event ) {
169
+		if (self::$_instance instanceof EEM_Event) {
170 170
 			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field(
171
-				'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), false, $default_reg_status, EEM_Registration::reg_status_array()
171
+				'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), false, $default_reg_status, EEM_Registration::reg_status_array()
172 172
 			);
173
-			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize( 'Event_Meta', 'EVT_default_registration_status', 'EEM_Event' );
173
+			self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', 'EVT_default_registration_status', 'EEM_Event');
174 174
 		}
175 175
 	}
176 176
 
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	*		@return 		array
184 184
 	*/
185 185
 	public function get_all_question_groups() {
186
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
187
-			array( 'QSG_deleted' => FALSE ),
188
-			'order_by' => array( 'QSG_order' => 'ASC' )
186
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
187
+			array('QSG_deleted' => FALSE),
188
+			'order_by' => array('QSG_order' => 'ASC')
189 189
 		));
190 190
 	}
191 191
 
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	* 		@param		int $EVT_ID
202 202
 	*		@return 		array
203 203
 	*/
204
-	public function get_all_event_question_groups( $EVT_ID = 0 ) {
205
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
206
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
204
+	public function get_all_event_question_groups($EVT_ID = 0) {
205
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
206
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
207 207
 			return FALSE;
208 208
 		}
209
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
210
-			array( 'EVT_ID' => $EVT_ID )
209
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
210
+			array('EVT_ID' => $EVT_ID)
211 211
 		));
212 212
 	}
213 213
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	* 		@param		boolean	$for_primary_attendee
224 224
 	*		@return 		array
225 225
 	*/
226
-	public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) {
227
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
228
-			EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
226
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = TRUE) {
227
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
228
+			EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
229 229
 			return FALSE;
230 230
 		}
231
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
232
-			array( 'EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee )
231
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
232
+			array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee)
233 233
 		));
234 234
 	}
235 235
 
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	* 		@param		EE_Registration 	$registration
247 247
 	*		@return 		array
248 248
 	*/
249
-	public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) {
249
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) {
250 250
 
251
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
252
-			EE_Error::add_error( __( 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
251
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
252
+			EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
253 253
 			return FALSE;
254 254
 		}
255 255
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			'QSG_deleted' => FALSE
260 260
 		);
261 261
 
262
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
262
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
263 263
 			$where_params,
264 264
 			'order_by' => array('QSG_order' => 'ASC')
265 265
 		));
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	* 		@param		string		$QSG_IDs  csv list of $QSG IDs
280 280
 	*		@return 		array
281 281
 	*/
282
-	public function get_questions_in_groups( $QSG_IDs = '' ) {
282
+	public function get_questions_in_groups($QSG_IDs = '') {
283 283
 
284
-		if ( empty( $QSG_IDs )) {
285
-			EE_Error::add_error( __( 'An error occurred. No Question Group IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
284
+		if (empty($QSG_IDs)) {
285
+			EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
286 286
 			return FALSE;
287 287
 		}
288 288
 
289
-		return EE_Registry::instance()->load_model( 'Question' )->get_all( array(
289
+		return EE_Registry::instance()->load_model('Question')->get_all(array(
290 290
 			array(
291
-				'Question_Group.QSG_ID' => array( 'IN', $QSG_IDs ),
291
+				'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
292 292
 				'QST_deleted' => FALSE,
293 293
 				'QST_admin_only' => is_admin()
294 294
 			),
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 	* 		@param		string		$QST_IDs  csv list of $QST IDs
311 311
 	*		@return 		array
312 312
 	*/
313
-	public function get_options_for_question( $QST_IDs ) {
313
+	public function get_options_for_question($QST_IDs) {
314 314
 
315
-		if ( empty( $QST_IDs )) {
316
-			EE_Error::add_error( __( 'An error occurred. No Question IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
315
+		if (empty($QST_IDs)) {
316
+			EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
317 317
 			return FALSE;
318 318
 		}
319 319
 
320
-		return EE_Registry::instance()->load_model( 'Question_Option' )->get_all( array(
320
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(array(
321 321
 			array(
322
-				'Question.QST_ID' => array( 'IN', $QST_IDs ),
322
+				'Question.QST_ID' => array('IN', $QST_IDs),
323 323
 				'QSO_deleted' => FALSE
324 324
 			),
325 325
 			'order_by' => 'QSO_ID'
@@ -339,46 +339,46 @@  discard block
 block discarded – undo
339 339
 	 * @throws EE_Error
340 340
 	 * @return 	array
341 341
 	 */
342
-	public function assemble_array_of_groups_questions_and_options( EE_Registration $registration, $EVT_ID = 0 ) {
342
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) {
343 343
 
344
-		if ( empty( $EVT_ID ) ) {
345
-			throw new EE_Error( __( 'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso' ) );
344
+		if (empty($EVT_ID)) {
345
+			throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso'));
346 346
 		}
347 347
 
348 348
 		$questions = array();
349 349
 
350 350
 		// get all question groups for event
351
-		$qgs = $this->get_question_groups_for_event( $EVT_ID, $registration );
352
-		if ( !empty( $qgs ) ) {
353
-			foreach ( $qgs as $qg ) {
351
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
352
+		if ( ! empty($qgs)) {
353
+			foreach ($qgs as $qg) {
354 354
 			 	$qsts = $qg->questions();
355
-			 	$questions[ $qg->ID() ] = $qg->model_field_array();
356
-			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
357
-			 	foreach ( $qsts as $qst ) {
358
-			 		if ( $qst->is_system_question() )
355
+			 	$questions[$qg->ID()] = $qg->model_field_array();
356
+			 	$questions[$qg->ID()]['QSG_questions'] = array();
357
+			 	foreach ($qsts as $qst) {
358
+			 		if ($qst->is_system_question())
359 359
 			 			continue;
360
-			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
360
+			 		$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID())));
361 361
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
362 362
 			 		$qst_name = $qstn_id = $qst->ID();
363 363
 			 		$ans_id = $answer->ID();
364
-			 		$qst_name = !empty( $ans_id ) ?  '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
364
+			 		$qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
365 365
 			 		$input_name = '';
366
-			 		$input_id = sanitize_key( $qst->display_text() );
366
+			 		$input_id = sanitize_key($qst->display_text());
367 367
 			 		$input_class = '';
368 368
 			 		$questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
369
-		 			$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn' . $input_name . $qst_name;
370
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
371
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
372
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
373
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
374
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
369
+		 			$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name;
370
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
371
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
372
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
373
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
374
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
375 375
 					//leave responses as-is, don't convert stuff into html entities please!
376
-					$questions[ $qg->ID() ][ 'QSG_questions'][ $qst->ID() ][ 'htmlentities' ] = false;
377
-					if ( $qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN' ) {
378
-						$QSOs = $qst->options(TRUE,$answer->value());
379
-						if ( is_array( $QSOs ) ) {
380
-							foreach ( $QSOs as $QSO_ID => $QSO ) {
381
-								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
376
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false;
377
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
378
+						$QSOs = $qst->options(TRUE, $answer->value());
379
+						if (is_array($QSOs)) {
380
+							foreach ($QSOs as $QSO_ID => $QSO) {
381
+								$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
382 382
 							}
383 383
 						}
384 384
 					}
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 	* 		@param		$QST
403 403
 	*		@return 		string		string
404 404
 	*/
405
-	private function _generate_question_input_name( $QST ) {
405
+	private function _generate_question_input_name($QST) {
406 406
 
407
-		if ( $QST->QST_system ) {
407
+		if ($QST->QST_system) {
408 408
 			$qst_name = $QST->QST_system;
409 409
 /*			switch( $QST->QST_system ) {
410 410
 
@@ -471,36 +471,36 @@  discard block
 block discarded – undo
471 471
 	 * @param bool    $count whether to return the count or not (default FALSE)
472 472
 	 * @return array 	EE_Event objects
473 473
 	 */
474
-	public function get_active_events( $query_params, $count = FALSE ) {
475
-		if ( array_key_exists( 0, $query_params ) ) {
474
+	public function get_active_events($query_params, $count = FALSE) {
475
+		if (array_key_exists(0, $query_params)) {
476 476
 			$where_params = $query_params[0];
477
-			unset( $query_params[0] );
477
+			unset($query_params[0]);
478 478
 		} else {
479 479
 			$where_params = array();
480 480
 		}
481 481
 
482 482
 		//if we have count make sure we don't include group by
483
-		if ( $count && isset( $query_params['group_by'] ) ) {
484
-			unset( $query_params['group_by'] );
483
+		if ($count && isset($query_params['group_by'])) {
484
+			unset($query_params['group_by']);
485 485
 		}
486 486
 
487 487
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
488 488
 		$where_params['status'] = 'publish';
489 489
 		//if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions
490
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
491
-			$where_params['Datetime.DTT_EVT_start******'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
490
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
491
+			$where_params['Datetime.DTT_EVT_start******'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
492 492
 		} else {
493
-			$where_params['Datetime.DTT_EVT_start'] = array('<',  EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
493
+			$where_params['Datetime.DTT_EVT_start'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
494 494
 		}
495 495
 
496
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
497
-			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
496
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
497
+			$where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
498 498
 		} else {
499
-			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
499
+			$where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
500 500
 		}
501 501
 		$query_params[0] = $where_params;
502 502
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY"
503
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
503
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
504 504
 	}
505 505
 
506 506
 
@@ -515,30 +515,30 @@  discard block
 block discarded – undo
515 515
 	 * @param bool    $count whether to return the count or not (default FALSE)
516 516
 	 * @return array               EE_Event objects
517 517
 	 */
518
-	public function get_upcoming_events( $query_params, $count = FALSE ) {
519
-		if ( array_key_exists( 0, $query_params ) ) {
518
+	public function get_upcoming_events($query_params, $count = FALSE) {
519
+		if (array_key_exists(0, $query_params)) {
520 520
 			$where_params = $query_params[0];
521
-			unset( $query_params[0] );
521
+			unset($query_params[0]);
522 522
 		} else {
523 523
 			$where_params = array();
524 524
 		}
525 525
 
526 526
 		//if we have count make sure we don't include group by
527
-		if ( $count && isset( $query_params['group_by'] ) ) {
528
-			unset( $query_params['group_by'] );
527
+		if ($count && isset($query_params['group_by'])) {
528
+			unset($query_params['group_by']);
529 529
 		}
530 530
 
531 531
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
532 532
 		$where_params['status'] = 'publish';
533 533
 		//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
534
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
535
-			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
534
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
535
+			$where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
536 536
 		} else {
537
-			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) );
537
+			$where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'));
538 538
 		}
539 539
 		$query_params[0] = $where_params;
540 540
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY"
541
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
541
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
542 542
 	}
543 543
 
544 544
 
@@ -550,54 +550,54 @@  discard block
 block discarded – undo
550 550
 	 * @param bool    $count whether to return the count or not (default FALSE)
551 551
 	 * @return array 	EE_Event objects
552 552
 	 */
553
-	public function get_expired_events( $query_params, $count = FALSE ) {
553
+	public function get_expired_events($query_params, $count = FALSE) {
554 554
 
555
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
555
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
556 556
 
557 557
 		//if we have count make sure we don't include group by
558
-		if ( $count && isset( $query_params['group_by'] ) ) {
559
-			unset( $query_params['group_by'] );
558
+		if ($count && isset($query_params['group_by'])) {
559
+			unset($query_params['group_by']);
560 560
 		}
561 561
 
562 562
 		//let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries.
563
-		if ( isset( $where_params['status'] ) ) {
564
-			unset( $where_params['status'] );
563
+		if (isset($where_params['status'])) {
564
+			unset($where_params['status']);
565 565
 		}
566 566
 		$exclude_query = $query_params;
567
-		if ( isset( $exclude_query[0] ) ) {
568
-			unset( $exclude_query[0] );
567
+		if (isset($exclude_query[0])) {
568
+			unset($exclude_query[0]);
569 569
 		}
570
-		$exclude_query[0] = array( 'Datetime.DTT_EVT_end' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) );
570
+		$exclude_query[0] = array('Datetime.DTT_EVT_end' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')));
571 571
 		//first get all events that have datetimes where its not expired.
572
-		$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Event_CPT.ID' );
573
-		$event_ids = array_keys( $event_ids );
572
+		$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID');
573
+		$event_ids = array_keys($event_ids);
574 574
 
575 575
 		//if we have any additional query_params, let's add them to the 'AND' condition
576 576
 		$and_condition = array(
577
-			'Datetime.DTT_EVT_end' => array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ),
578
-			'EVT_ID' =>  array( 'NOT IN', $event_ids )
577
+			'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')),
578
+			'EVT_ID' =>  array('NOT IN', $event_ids)
579 579
 			);
580 580
 
581
-		if ( isset( $where_params['OR'] ) ) {
581
+		if (isset($where_params['OR'])) {
582 582
 			$and_condition['OR'] = $where_params['OR'];
583
-			unset( $where_params['OR'] );
583
+			unset($where_params['OR']);
584 584
 		}
585 585
 
586
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
586
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
587 587
 			$and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
588
-			unset( $where_params['Datetime.DTT_EVT_end'] );
588
+			unset($where_params['Datetime.DTT_EVT_end']);
589 589
 		}
590 590
 
591
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
591
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
592 592
 			$and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
593
-			unset( $where_params['Datetime.DTT_EVT_start'] );
593
+			unset($where_params['Datetime.DTT_EVT_start']);
594 594
 		}
595 595
 
596 596
 		//merge remaining $where params with the and conditions.
597
-		$where_params['AND'] = array_merge( $and_condition, $where_params );
597
+		$where_params['AND'] = array_merge($and_condition, $where_params);
598 598
 		$query_params[0] = $where_params;
599 599
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY"
600
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
600
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
601 601
 	}
602 602
 
603 603
 
@@ -608,40 +608,40 @@  discard block
 block discarded – undo
608 608
 	 * @param  boolean $count        whether to return the count or not (default FALSE)
609 609
 	 * @return EE_Event[]            array of EE_Event objects
610 610
 	 */
611
-	public function get_inactive_events( $query_params, $count = FALSE ) {
612
-		$where_params = isset( $query_params[0] ) ? $query_params[0] : array();
611
+	public function get_inactive_events($query_params, $count = FALSE) {
612
+		$where_params = isset($query_params[0]) ? $query_params[0] : array();
613 613
 
614 614
 		//let's add in specific query_params for inactive events.
615
-		if ( isset( $where_params['status'] ) ) {
616
-			unset( $where_params['status'] );
615
+		if (isset($where_params['status'])) {
616
+			unset($where_params['status']);
617 617
 		}
618 618
 
619 619
 		//if we have count make sure we don't include group by
620
-		if ( $count && isset( $query_params['group_by'] ) ) {
621
-			unset( $query_params['group_by'] );
620
+		if ($count && isset($query_params['group_by'])) {
621
+			unset($query_params['group_by']);
622 622
 		}
623 623
 
624 624
 		//if we have any additional query_params, let's add them to the 'AND' condition
625
-		$where_params['AND']['status'] = array( '!=', 'publish' );
625
+		$where_params['AND']['status'] = array('!=', 'publish');
626 626
 
627
-		if ( isset( $where_params['OR'] ) ) {
627
+		if (isset($where_params['OR'])) {
628 628
 			$where_params['AND']['OR'] = $where_params['OR'];
629
-			unset( $where_params['OR'] );
629
+			unset($where_params['OR']);
630 630
 		}
631 631
 
632
-		if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
632
+		if (isset($where_params['Datetime.DTT_EVT_end'])) {
633 633
 			$where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end'];
634
-			unset( $where_params['Datetime.DTT_EVT_end'] );
634
+			unset($where_params['Datetime.DTT_EVT_end']);
635 635
 		}
636 636
 
637
-		if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) {
637
+		if (isset($where_params['Datetime.DTT_EVT_start'])) {
638 638
 			$where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start'];
639
-			unset( $where_params['Datetime.DTT_EVT_start'] );
639
+			unset($where_params['Datetime.DTT_EVT_start']);
640 640
 		}
641 641
 
642 642
 		$query_params[0] = $where_params;
643 643
 		// don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY"
644
-		return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params );
644
+		return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params);
645 645
 	}
646 646
 
647 647
 
@@ -649,13 +649,13 @@  discard block
 block discarded – undo
649 649
 	 * This is just injecting into the parent add_relationship_to so we do special handling on price relationships because we don't want to override any existing global default prices but instead insert NEW prices that get attached to the event.
650 650
 	 * See parent for param descriptions
651 651
 	 */
652
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
652
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
653 653
 
654
-		if ( $relationName == 'Price' ) {
654
+		if ($relationName == 'Price') {
655 655
 			//let's get the PRC object for the given ID to make sure that we aren't dealing with a default
656 656
 			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
657 657
 			//if EVT_ID = 0, then this is a default
658
-			if ( $prc_chk->get('EVT_ID') == 0 ) {
658
+			if ($prc_chk->get('EVT_ID') == 0) {
659 659
 				//let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
660 660
 				$prc_chk->set('PRC_ID', 0);
661 661
 			}
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		}
666 666
 
667 667
 		//otherwise carry on as normal
668
-		return parent::add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query);
668
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
669 669
 	}
670 670
 
671 671
 
Please login to merge, or discard this patch.
core/business/EE_Registration_Processor.class.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -514,7 +514,7 @@
 block discarded – undo
514 514
 		// set new  REG_Status
515 515
 		$this->set_new_reg_status( $registration->ID(), $registration->status_ID() );
516 516
 		return $this->reg_status_updated( $registration->ID() )
517
-		       && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved
517
+			   && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved
518 518
 			? true
519 519
 			: false;
520 520
 	}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -565,7 +565,7 @@
 block discarded – undo
565 565
 	 * @since 4.9.1
566 566
 	 * @param int                   $att_nmbr
567 567
 	 * @param EE_Line_Item | string $item
568
-	 * @return string
568
+	 * @return RegUrlLink
569 569
 	 */
570 570
 	public function generate_reg_url_link($att_nmbr, $item)
571 571
 	{
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\domain\entities\RegUrlLink;
4 4
 use EventEspresso\core\domain\services\registration\CreateRegistrationService;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
7
-EE_Registry::instance()->load_class( 'Processor_Base' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
7
+EE_Registry::instance()->load_class('Processor_Base');
8 8
 
9 9
 /**
10 10
  * Class EE_Registration_Processor
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public static function instance() {
68 68
 		// check if class object is instantiated
69
-		if ( ! self::$_instance instanceof EE_Registration_Processor ) {
69
+		if ( ! self::$_instance instanceof EE_Registration_Processor) {
70 70
 			self::$_instance = new self();
71 71
 		}
72 72
 		return self::$_instance;
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @param int $REG_ID
87 87
 	 * @return string
88 88
 	 */
89
-	public function old_reg_status( $REG_ID ) {
90
-		return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null;
89
+	public function old_reg_status($REG_ID) {
90
+		return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
91 91
 	}
92 92
 
93 93
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 * @param int $REG_ID
97 97
 	 * @param string $old_reg_status
98 98
 	 */
99
-	public function set_old_reg_status( $REG_ID, $old_reg_status ) {
99
+	public function set_old_reg_status($REG_ID, $old_reg_status) {
100 100
 		// only set the first time
101
-		if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) {
102
-			$this->_old_reg_status[ $REG_ID ] = $old_reg_status;
101
+		if ( ! isset($this->_old_reg_status[$REG_ID])) {
102
+			$this->_old_reg_status[$REG_ID] = $old_reg_status;
103 103
 		}
104 104
 	}
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param int $REG_ID
110 110
 	 * @return string
111 111
 	 */
112
-	public function new_reg_status( $REG_ID ) {
113
-		return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null;
112
+	public function new_reg_status($REG_ID) {
113
+		return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
114 114
 	}
115 115
 
116 116
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param int $REG_ID
120 120
 	 * @param string $new_reg_status
121 121
 	 */
122
-	public function set_new_reg_status( $REG_ID, $new_reg_status ) {
123
-		$this->_new_reg_status[ $REG_ID ] = $new_reg_status;
122
+	public function set_new_reg_status($REG_ID, $new_reg_status) {
123
+		$this->_new_reg_status[$REG_ID] = $new_reg_status;
124 124
 	}
125 125
 
126 126
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param int $REG_ID
132 132
 	 * @return bool
133 133
 	 */
134
-	public function reg_status_updated( $REG_ID ) {
135
-		return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false;
134
+	public function reg_status_updated($REG_ID) {
135
+		return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false;
136 136
 	}
137 137
 
138 138
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Registration $registration
142 142
 	 * @throws \EE_Error
143 143
 	 */
144
-	public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) {
145
-		$this->toggle_incomplete_registration_status_to_default( $registration, false );
146
-		$this->toggle_registration_status_for_default_approved_events( $registration, false );
147
-		$this->toggle_registration_status_if_no_monies_owing( $registration, false );
144
+	public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) {
145
+		$this->toggle_incomplete_registration_status_to_default($registration, false);
146
+		$this->toggle_registration_status_for_default_approved_events($registration, false);
147
+		$this->toggle_registration_status_if_no_monies_owing($registration, false);
148 148
 		$registration->save();
149 149
 		// trigger notifications
150
-		$this->trigger_registration_update_notifications( $registration );
150
+		$this->trigger_registration_update_notifications($registration);
151 151
 	}
152 152
 
153 153
 
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 	 * @return boolean
163 163
 	 * @throws \EE_Error
164 164
 	 */
165
-	public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) {
165
+	public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) {
166 166
 		// set initial REG_Status
167
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
167
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
168 168
 		// set incoming REG_Status
169
-		$this->set_new_reg_status( $registration->ID(), $new_reg_status );
169
+		$this->set_new_reg_status($registration->ID(), $new_reg_status);
170 170
 		// toggle reg status but only if it has changed and the user can do so
171 171
 		if (
172
-			$this->reg_status_updated( $registration->ID() ) &&
173
-			EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() )
172
+			$this->reg_status_updated($registration->ID()) &&
173
+			EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID())
174 174
 		) {
175 175
 			// change status to new value
176
-			if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) {
176
+			if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) {
177 177
 				$registration->save();
178 178
 			}
179 179
 			return TRUE;
@@ -193,30 +193,30 @@  discard block
 block discarded – undo
193 193
 	 * @return void
194 194
 	 * @throws \EE_Error
195 195
 	 */
196
-	public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) {
196
+	public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) {
197 197
 		$existing_reg_status = $registration->status_ID();
198 198
 		// set initial REG_Status
199
-		$this->set_old_reg_status( $registration->ID(), $existing_reg_status );
199
+		$this->set_old_reg_status($registration->ID(), $existing_reg_status);
200 200
 		// is the registration currently incomplete ?
201
-		if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) {
201
+		if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
202 202
 			// grab default reg status for the event, if set
203 203
 			$event_default_registration_status = $registration->event()->default_registration_status();
204 204
 			// if no default reg status is set for the event, then use the global value
205
-			$STS_ID = ! empty( $event_default_registration_status )
205
+			$STS_ID = ! empty($event_default_registration_status)
206 206
 				? $event_default_registration_status
207 207
 				: EE_Registry::instance()->CFG->registration->default_STS_ID;
208 208
 			// if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
209 209
 			$STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID;
210 210
 			// set incoming REG_Status
211
-			$this->set_new_reg_status( $registration->ID(), $STS_ID );
212
-			$registration->set_status( $STS_ID );
213
-			if ( $save ) {
211
+			$this->set_new_reg_status($registration->ID(), $STS_ID);
212
+			$registration->set_status($STS_ID);
213
+			if ($save) {
214 214
 				$registration->save();
215 215
 			}
216 216
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
217
-			if ( ! EE_Processor_Base::$IPN ) {
217
+			if ( ! EE_Processor_Base::$IPN) {
218 218
 				// otherwise, send out notifications
219
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
219
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
220 220
 			}
221 221
 			// DEBUG LOG
222 222
 			//$this->log(
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 	 * @return boolean
242 242
 	 * @throws \EE_Error
243 243
 	 */
244
-	public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) {
244
+	public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) {
245 245
 		$reg_status = $registration->status_ID();
246 246
 		// set initial REG_Status
247
-		$this->set_old_reg_status( $registration->ID(), $reg_status );
247
+		$this->set_old_reg_status($registration->ID(), $reg_status);
248 248
 		// if not already, toggle reg status to approved IF the event default reg status is approved
249 249
 		// ( as long as the registration wasn't cancelled or declined at some point )
250 250
 		if (
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 			$registration->event()->default_registration_status() === EEM_Registration::status_id_approved
255 255
 		) {
256 256
 			// set incoming REG_Status
257
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
257
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
258 258
 			// toggle status to approved
259
-			$registration->set_status( EEM_Registration::status_id_approved );
260
-			if ( $save ) {
259
+			$registration->set_status(EEM_Registration::status_id_approved);
260
+			if ($save) {
261 261
 				$registration->save();
262 262
 			}
263 263
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
264
-			if ( ! EE_Processor_Base::$IPN ) {
264
+			if ( ! EE_Processor_Base::$IPN) {
265 265
 				// otherwise, send out notifications
266
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
266
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
267 267
 			}
268 268
 			// DEBUG LOG
269 269
 			//$this->log(
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
 	 * @return bool
292 292
 	 * @throws \EE_Error
293 293
 	 */
294
-	public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) {
294
+	public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) {
295 295
 		// set initial REG_Status
296
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
296
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
297 297
 		//EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ );
298 298
 		// was a payment just made ?
299 299
 		if (
300
-			isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) &&
301
-			$additional_details[ 'payment_updates' ] &&
302
-			$additional_details[ 'last_payment' ] instanceof EE_Payment
300
+			isset($additional_details['payment_updates'], $additional_details['last_payment']) &&
301
+			$additional_details['payment_updates'] &&
302
+			$additional_details['last_payment'] instanceof EE_Payment
303 303
 		) {
304
-			$payment = $additional_details[ 'last_payment' ];
304
+			$payment = $additional_details['last_payment'];
305 305
 			$total_paid = 0;
306
-			foreach ( self::$_amount_paid as $reg => $amount_paid ) {
306
+			foreach (self::$_amount_paid as $reg => $amount_paid) {
307 307
 				$total_paid += $amount_paid;
308 308
 			}
309 309
 		} else {
@@ -327,30 +327,30 @@  discard block
 block discarded – undo
327 327
 					$registration->transaction()->is_completed() ||
328 328
 					$registration->transaction()->is_overpaid() ||
329 329
 					$registration->transaction()->is_free() ||
330
-					apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration )
330
+					apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration)
331 331
 				) || (
332 332
 					$payment instanceof EE_Payment &&
333 333
 					$payment->is_approved() &&
334 334
 					// this specific registration has not yet been paid for
335
-					! isset( self::$_amount_paid[ $registration->ID() ] ) &&
335
+					! isset(self::$_amount_paid[$registration->ID()]) &&
336 336
 					// payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
337 337
 					$payment->amount() - $total_paid >= $registration->final_price()
338 338
 				)
339 339
 			)
340 340
 		) {
341 341
 			// mark as paid
342
-			self::$_amount_paid[ $registration->ID() ] = $registration->final_price();
342
+			self::$_amount_paid[$registration->ID()] = $registration->final_price();
343 343
 			// track new REG_Status
344
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
344
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
345 345
 			// toggle status to approved
346
-			$registration->set_status( EEM_Registration::status_id_approved );
347
-			if ( $save ) {
346
+			$registration->set_status(EEM_Registration::status_id_approved);
347
+			if ($save) {
348 348
 				$registration->save();
349 349
 			}
350 350
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
351
-			if ( ! EE_Processor_Base::$IPN ) {
351
+			if ( ! EE_Processor_Base::$IPN) {
352 352
 				// otherwise, send out notifications
353
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
353
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
354 354
 			}
355 355
 			// DEBUG LOG
356 356
 			//$this->log(
@@ -376,19 +376,19 @@  discard block
 block discarded – undo
376 376
 	 * @param array 	$additional_details
377 377
 	 * @return void
378 378
 	 */
379
-	public function trigger_registration_update_notifications( $registration, $additional_details = array() ) {
379
+	public function trigger_registration_update_notifications($registration, $additional_details = array()) {
380 380
 		try {
381
-			if ( ! $registration instanceof EE_Registration ) {
382
-				throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) );
381
+			if ( ! $registration instanceof EE_Registration) {
382
+				throw new EE_Error(__('An invalid registration was received.', 'event_espresso'));
383 383
 			}
384
-			EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $registration->transaction(), $additional_details ), false, 'EE_Transaction: ' . $registration->transaction()->ID() );
384
+			EEH_Debug_Tools::log(__CLASS__, __FUNCTION__, __LINE__, array($registration->transaction(), $additional_details), false, 'EE_Transaction: '.$registration->transaction()->ID());
385 385
 			do_action(
386 386
 				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
387 387
 				$registration,
388 388
 				$additional_details
389 389
 			);
390
-		} catch( Exception $e ) {
391
-			EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() );
390
+		} catch (Exception $e) {
391
+			EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
392 392
 		}
393 393
 	}
394 394
 
@@ -402,22 +402,22 @@  discard block
 block discarded – undo
402 402
 	 * @return bool
403 403
 	 * @throws \EE_Error
404 404
 	 */
405
-	public function update_registration_after_checkout_or_payment(  EE_Registration $registration, $additional_details = array() ) {
405
+	public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) {
406 406
 		// set initial REG_Status
407
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
407
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
408 408
 
409 409
 		// if the registration status gets updated, then save the registration
410 410
 		if (
411
-			$this->toggle_registration_status_for_default_approved_events( $registration, false )
412
-			|| $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )
411
+			$this->toggle_registration_status_for_default_approved_events($registration, false)
412
+			|| $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)
413 413
 		) {
414 414
 			$registration->save();
415 415
 		}
416 416
 
417 417
 		// set new  REG_Status
418
-		$this->set_new_reg_status( $registration->ID(), $registration->status_ID() );
419
-		return $this->reg_status_updated( $registration->ID() )
420
-		       && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved
418
+		$this->set_new_reg_status($registration->ID(), $registration->status_ID());
419
+		return $this->reg_status_updated($registration->ID())
420
+		       && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved
421 421
 			? true
422 422
 			: false;
423 423
 	}
@@ -433,20 +433,20 @@  discard block
 block discarded – undo
433 433
 	 * @return void
434 434
 	 * @throws \EE_Error
435 435
 	 */
436
-	public function update_registration_final_prices( $transaction, $save_regs = true ) {
437
-		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
438
-		foreach( $transaction->registrations() as $registration ) {
436
+	public function update_registration_final_prices($transaction, $save_regs = true) {
437
+		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
438
+		foreach ($transaction->registrations() as $registration) {
439 439
 			/** @var EE_Line_Item $line_item */
440
-			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration );
441
-			if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) {
442
-				$registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] );
443
-				if( $save_regs ) {
440
+			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
441
+			if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
442
+				$registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
443
+				if ($save_regs) {
444 444
 					$registration->save();
445 445
 				}
446 446
 			}
447 447
 		}
448 448
 		//and make sure there's no rounding problem
449
-		$this->fix_reg_final_price_rounding_issue( $transaction );
449
+		$this->fix_reg_final_price_rounding_issue($transaction);
450 450
 	}
451 451
 
452 452
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @return boolean success verifying that there is NO difference after this method is done
467 467
 	 * @throws \EE_Error
468 468
 	 */
469
-	public function fix_reg_final_price_rounding_issue( $transaction ) {
469
+	public function fix_reg_final_price_rounding_issue($transaction) {
470 470
 		$reg_final_price_sum = EEM_Registration::instance()->sum(
471 471
 			array(
472 472
 				array(
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
 			),
476 476
 			'REG_final_price'
477 477
 		);
478
-		$diff =  $transaction->total() - (float) $reg_final_price_sum;
478
+		$diff = $transaction->total() - (float) $reg_final_price_sum;
479 479
 		//ok then, just grab one of the registrations
480
-		if( $diff !== 0 ) {
480
+		if ($diff !== 0) {
481 481
 			$a_reg = EEM_Registration::instance()->get_one(
482 482
 					array(
483 483
 						array(
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 					));
487 487
 			$success = $a_reg instanceof EE_Registration
488 488
 				? $a_reg->save(
489
-					array( 'REG_final_price' => $a_reg->final_price() + $diff )
489
+					array('REG_final_price' => $a_reg->final_price() + $diff)
490 490
 				)
491 491
 				: false;
492 492
 			return $success ? true : false;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		$total_ticket_count = 1
528 528
 	) {
529 529
 		EE_Error::doing_it_wrong(
530
-			__CLASS__ . '::' . __FUNCTION__,
530
+			__CLASS__.'::'.__FUNCTION__,
531 531
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
532 532
 				'\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'),
533 533
 			'4.9.1',
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	public function generate_reg_url_link($att_nmbr, $item)
571 571
 	{
572 572
 		EE_Error::doing_it_wrong(
573
-			__CLASS__ . '::' . __FUNCTION__,
573
+			__CLASS__.'::'.__FUNCTION__,
574 574
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
575 575
 				'EventEspresso\core\domain\entities\RegUrlLink'),
576 576
 			'4.9.1',
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 	public function generate_reg_code(EE_Registration $registration)
594 594
 	{
595 595
 		EE_Error::doing_it_wrong(
596
-			__CLASS__ . '::' . __FUNCTION__,
596
+			__CLASS__.'::'.__FUNCTION__,
597 597
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
598 598
 				'EventEspresso\core\domain\entities\RegCode'),
599 599
 			'4.9.1',
Please login to merge, or discard this patch.
core/db_classes/EE_Line_Item.class.php 3 patches
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 *                             		    date_format and the second value is the time format
51 51
 	 * @return EE_Line_Item
52 52
 	 */
53
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
54
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
55
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
53
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
54
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
55
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
56 56
 	}
57 57
 
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 *                          		the website will be used.
64 64
 	 * @return EE_Line_Item
65 65
 	 */
66
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
67
-		return new self( $props_n_values, TRUE, $timezone );
66
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
67
+		return new self($props_n_values, TRUE, $timezone);
68 68
 	}
69 69
 
70 70
 
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 * @param bool   $bydb
76 76
 	 * @param string $timezone
77 77
 	 */
78
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ) {
79
-		parent::__construct( $fieldValues, $bydb, $timezone );
80
-		if ( ! $this->get( 'LIN_code' ) ) {
81
-			$this->set_code( $this->generate_code() );
78
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') {
79
+		parent::__construct($fieldValues, $bydb, $timezone);
80
+		if ( ! $this->get('LIN_code')) {
81
+			$this->set_code($this->generate_code());
82 82
 		}
83 83
 	}
84 84
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return int
90 90
 	 */
91 91
 	public function ID() {
92
-		return $this->get( 'LIN_ID' );
92
+		return $this->get('LIN_ID');
93 93
 	}
94 94
 
95 95
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @return int
100 100
 	 */
101 101
 	public function TXN_ID() {
102
-		return $this->get( 'TXN_ID' );
102
+		return $this->get('TXN_ID');
103 103
 	}
104 104
 
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param int $TXN_ID
110 110
 	 * @return boolean
111 111
 	 */
112
-	public function set_TXN_ID( $TXN_ID ) {
113
-		$this->set( 'TXN_ID', $TXN_ID );
112
+	public function set_TXN_ID($TXN_ID) {
113
+		$this->set('TXN_ID', $TXN_ID);
114 114
 	}
115 115
 
116 116
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 * @return string
121 121
 	 */
122 122
 	public function name() {
123
-		$name =  $this->get( 'LIN_name' );
124
-		if( ! $name ){
125
-			$name = ucwords( str_replace( '-', ' ', $this->type() ) );
123
+		$name = $this->get('LIN_name');
124
+		if ( ! $name) {
125
+			$name = ucwords(str_replace('-', ' ', $this->type()));
126 126
 		}
127 127
 		return $name;
128 128
 	}
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @param string $name
135 135
 	 * @return boolean
136 136
 	 */
137
-	public function set_name( $name ) {
138
-		$this->set( 'LIN_name', $name );
137
+	public function set_name($name) {
138
+		$this->set('LIN_name', $name);
139 139
 	}
140 140
 
141 141
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return string
146 146
 	 */
147 147
 	public function desc() {
148
-		return $this->get( 'LIN_desc' );
148
+		return $this->get('LIN_desc');
149 149
 	}
150 150
 
151 151
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 * @param string $desc
156 156
 	 * @return boolean
157 157
 	 */
158
-	public function set_desc( $desc ) {
159
-		$this->set( 'LIN_desc', $desc );
158
+	public function set_desc($desc) {
159
+		$this->set('LIN_desc', $desc);
160 160
 	}
161 161
 
162 162
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @return int
167 167
 	 */
168 168
 	public function quantity() {
169
-		return $this->get( 'LIN_quantity' );
169
+		return $this->get('LIN_quantity');
170 170
 	}
171 171
 
172 172
 
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 * @param int $quantity
177 177
 	 * @return boolean
178 178
 	 */
179
-	public function set_quantity( $quantity ) {
180
-		$quantity = max( $quantity, 0 );
181
-		$this->set( 'LIN_quantity', $quantity );
179
+	public function set_quantity($quantity) {
180
+		$quantity = max($quantity, 0);
181
+		$this->set('LIN_quantity', $quantity);
182 182
 	}
183 183
 
184 184
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @return string
189 189
 	 */
190 190
 	public function OBJ_ID() {
191
-		return $this->get( 'OBJ_ID' );
191
+		return $this->get('OBJ_ID');
192 192
 	}
193 193
 
194 194
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param string $item_id
199 199
 	 * @return boolean
200 200
 	 */
201
-	public function set_OBJ_ID( $item_id ) {
202
-		$this->set( 'OBJ_ID', $item_id );
201
+	public function set_OBJ_ID($item_id) {
202
+		$this->set('OBJ_ID', $item_id);
203 203
 	}
204 204
 
205 205
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function OBJ_type() {
212
-		return $this->get( 'OBJ_type' );
212
+		return $this->get('OBJ_type');
213 213
 	}
214 214
 
215 215
 
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 * @param string $OBJ_type
220 220
 	 * @return boolean
221 221
 	 */
222
-	public function set_OBJ_type( $OBJ_type ) {
223
-		$this->set( 'OBJ_type', $OBJ_type );
222
+	public function set_OBJ_type($OBJ_type) {
223
+		$this->set('OBJ_type', $OBJ_type);
224 224
 	}
225 225
 
226 226
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return float
231 231
 	 */
232 232
 	public function unit_price() {
233
-		return $this->get( 'LIN_unit_price' );
233
+		return $this->get('LIN_unit_price');
234 234
 	}
235 235
 
236 236
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * @param float $unit_price
241 241
 	 * @return boolean
242 242
 	 */
243
-	public function set_unit_price( $unit_price ) {
244
-		$this->set( 'LIN_unit_price', $unit_price );
243
+	public function set_unit_price($unit_price) {
244
+		$this->set('LIN_unit_price', $unit_price);
245 245
 	}
246 246
 
247 247
 
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
 	 * @return boolean
253 253
 	 */
254 254
 	public function is_percent() {
255
-		if( $this->is_tax_sub_total() ) {
255
+		if ($this->is_tax_sub_total()) {
256 256
 			//tax subtotals HAVE a percent on them, that percentage only applies
257 257
 			//to taxable items, so its' an exception. Treat it like a flat line item
258 258
 			return false;
259 259
 		}
260
-		$unit_price = abs( $this->get( 'LIN_unit_price' ) );
261
-		$percent = abs( $this->get( 'LIN_percent' ) );
262
-		if ( $unit_price < .001 && $percent ) {
260
+		$unit_price = abs($this->get('LIN_unit_price'));
261
+		$percent = abs($this->get('LIN_percent'));
262
+		if ($unit_price < .001 && $percent) {
263 263
 			return TRUE;
264
-		} elseif ( $unit_price >= .001 && !$percent ) {
264
+		} elseif ($unit_price >= .001 && ! $percent) {
265 265
 			return FALSE;
266
-		} elseif ( $unit_price >= .001 && $percent ) {
267
-			throw new EE_Error( sprintf( __( "A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso" ), $unit_price, $percent ) );
266
+		} elseif ($unit_price >= .001 && $percent) {
267
+			throw new EE_Error(sprintf(__("A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso"), $unit_price, $percent));
268 268
 		} else {
269 269
 			// if they're both 0, assume its not a percent item
270 270
 			return FALSE;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return float
279 279
 	 */
280 280
 	public function percent() {
281
-		return $this->get( 'LIN_percent' );
281
+		return $this->get('LIN_percent');
282 282
 	}
283 283
 
284 284
 
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 	 * @param float $percent
289 289
 	 * @return boolean
290 290
 	 */
291
-	public function set_percent( $percent ) {
292
-		$this->set( 'LIN_percent', $percent );
291
+	public function set_percent($percent) {
292
+		$this->set('LIN_percent', $percent);
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return float
300 300
 	 */
301 301
 	public function total() {
302
-		return $this->get( 'LIN_total' );
302
+		return $this->get('LIN_total');
303 303
 	}
304 304
 
305 305
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 	 * @param float $total
310 310
 	 * @return boolean
311 311
 	 */
312
-	public function set_total( $total ) {
313
-		$this->set( 'LIN_total', $total );
312
+	public function set_total($total) {
313
+		$this->set('LIN_total', $total);
314 314
 	}
315 315
 
316 316
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @return int
321 321
 	 */
322 322
 	public function order() {
323
-		return $this->get( 'LIN_order' );
323
+		return $this->get('LIN_order');
324 324
 	}
325 325
 
326 326
 
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * Sets order
330 330
 	 * @param int $order
331 331
 	 */
332
-	public function set_order( $order ) {
333
-		$this->set( 'LIN_order', $order );
332
+	public function set_order($order) {
333
+		$this->set('LIN_order', $order);
334 334
 	}
335 335
 
336 336
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * @return int
341 341
 	 */
342 342
 	public function parent_ID() {
343
-		return $this->get( 'LIN_parent' );
343
+		return $this->get('LIN_parent');
344 344
 	}
345 345
 
346 346
 
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 * @param int $parent
351 351
 	 * @return boolean
352 352
 	 */
353
-	public function set_parent_ID( $parent ) {
354
-		$this->set( 'LIN_parent', $parent );
353
+	public function set_parent_ID($parent) {
354
+		$this->set('LIN_parent', $parent);
355 355
 	}
356 356
 
357 357
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @return string
362 362
 	 */
363 363
 	public function type() {
364
-		return $this->get( 'LIN_type' );
364
+		return $this->get('LIN_type');
365 365
 	}
366 366
 
367 367
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param string $type
372 372
 	 * @return boolean
373 373
 	 */
374
-	public function set_type( $type ) {
375
-		$this->set( 'LIN_type', $type );
374
+	public function set_type($type) {
375
+		$this->set('LIN_type', $type);
376 376
 	}
377 377
 
378 378
 
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 	 * @return EE_Line_Item
386 386
 	 */
387 387
 	public function parent() {
388
-		if( $this->ID() ) {
389
-			return $this->get_model()->get_one_by_ID( $this->parent_ID() );
388
+		if ($this->ID()) {
389
+			return $this->get_model()->get_one_by_ID($this->parent_ID());
390 390
 		} else {
391 391
 			return $this->_parent;
392 392
 		}
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 	 * @return EE_Line_Item[]
400 400
 	 */
401 401
 	public function children() {
402
-		if ( $this->ID() ) {
402
+		if ($this->ID()) {
403 403
 			return $this->get_model()->get_all(
404 404
 					array(
405
-						array( 'LIN_parent' => $this->ID() ),
406
-						'order_by' => array( 'LIN_order' => 'ASC' ) ) );
405
+						array('LIN_parent' => $this->ID()),
406
+						'order_by' => array('LIN_order' => 'ASC') ) );
407 407
 		} else {
408
-			if ( ! is_array( $this->_children ) ) {
408
+			if ( ! is_array($this->_children)) {
409 409
 				$this->_children = array();
410 410
 			}
411 411
 			return $this->_children;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @return string
420 420
 	 */
421 421
 	public function code() {
422
-		return $this->get( 'LIN_code' );
422
+		return $this->get('LIN_code');
423 423
 	}
424 424
 
425 425
 
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	 * @param string $code
430 430
 	 * @return boolean
431 431
 	 */
432
-	public function set_code( $code ) {
433
-		$this->set( 'LIN_code', $code );
432
+	public function set_code($code) {
433
+		$this->set('LIN_code', $code);
434 434
 	}
435 435
 
436 436
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 * @return boolean
441 441
 	 */
442 442
 	public function is_taxable() {
443
-		return $this->get( 'LIN_is_taxable' );
443
+		return $this->get('LIN_is_taxable');
444 444
 	}
445 445
 
446 446
 
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 	 * @param boolean $is_taxable
451 451
 	 * @return boolean
452 452
 	 */
453
-	public function set_is_taxable( $is_taxable ) {
454
-		$this->set( 'LIN_is_taxable', $is_taxable );
453
+	public function set_is_taxable($is_taxable) {
454
+		$this->set('LIN_is_taxable', $is_taxable);
455 455
 	}
456 456
 
457 457
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 */
467 467
 	public function get_object() {
468 468
 		$model_name_of_related_obj = $this->OBJ_type();
469
-		return $this->get_model()->has_relation(  $model_name_of_related_obj ) ? $this->get_first_related( $model_name_of_related_obj ) : NULL;
469
+		return $this->get_model()->has_relation($model_name_of_related_obj) ? $this->get_first_related($model_name_of_related_obj) : NULL;
470 470
 	}
471 471
 
472 472
 
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 	 * @param array $query_params
478 478
 	 * @return EE_Ticket
479 479
 	 */
480
-	public function ticket( $query_params = array() ) {
480
+	public function ticket($query_params = array()) {
481 481
 		//we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived.  This can be overridden via the incoming $query_params argument
482
-		$remove_defaults = array( 'default_where_conditions' => 'none' );
483
-		$query_params = array_merge( $remove_defaults, $query_params );
484
-		return $this->get_first_related( 'Ticket', $query_params );
482
+		$remove_defaults = array('default_where_conditions' => 'none');
483
+		$query_params = array_merge($remove_defaults, $query_params);
484
+		return $this->get_first_related('Ticket', $query_params);
485 485
 	}
486 486
 
487 487
 
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	 * @return EE_Datetime | NULL
492 492
 	 */
493 493
 	public function get_ticket_datetime() {
494
-		if ( $this->OBJ_type() === 'Ticket' ) {
494
+		if ($this->OBJ_type() === 'Ticket') {
495 495
 			$ticket = $this->ticket();
496
-			if ( $ticket instanceof EE_Ticket ) {
496
+			if ($ticket instanceof EE_Ticket) {
497 497
 				$datetime = $ticket->first_datetime();
498
-				if ( $datetime instanceof EE_Datetime ) {
498
+				if ($datetime instanceof EE_Datetime) {
499 499
 					return $datetime;
500 500
 				}
501 501
 			}
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 	 * @return string
512 512
 	 */
513 513
 	public function ticket_event_name() {
514
-		$event_name = __( "Unknown", "event_espresso" );
514
+		$event_name = __("Unknown", "event_espresso");
515 515
 		$event = $this->ticket_event();
516
-		if ( $event instanceof EE_Event ) {
516
+		if ($event instanceof EE_Event) {
517 517
 			$event_name = $event->name();
518 518
 		}
519 519
 		return $event_name;
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	public function ticket_event() {
528 528
 		$event = null;
529 529
 		$ticket = $this->ticket();
530
-		if ( $ticket instanceof EE_Ticket ) {
530
+		if ($ticket instanceof EE_Ticket) {
531 531
 			$datetime = $ticket->first_datetime();
532
-			if ( $datetime instanceof EE_Datetime ) {
532
+			if ($datetime instanceof EE_Datetime) {
533 533
 				$event = $datetime->event();
534 534
 			}
535 535
 		}
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 	 * @param string $time_format
545 545
 	 * @return string
546 546
 	 */
547
-	public function ticket_datetime_start( $date_format = '', $time_format = '' ) {
548
-		$first_datetime_string = __( "Unknown", "event_espresso" );
547
+	public function ticket_datetime_start($date_format = '', $time_format = '') {
548
+		$first_datetime_string = __("Unknown", "event_espresso");
549 549
 		$datetime = $this->get_ticket_datetime();
550
-		if ( $datetime ) {
551
-			$first_datetime_string = $datetime->start_date_and_time( $date_format, $time_format );
550
+		if ($datetime) {
551
+			$first_datetime_string = $datetime->start_date_and_time($date_format, $time_format);
552 552
 		}
553 553
 		return $first_datetime_string;
554 554
 	}
@@ -563,26 +563,26 @@  discard block
 block discarded – undo
563 563
 	 * @return bool success
564 564
 	 * @throws \EE_Error
565 565
 	 */
566
-	public function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ) {
566
+	public function add_child_line_item(EEI_Line_Item $line_item, $set_order = true) {
567 567
 		// should we calculate the LIN_order for this line item ?
568
-		if ( $set_order || $line_item->order() === null ) {
569
-			$line_item->set_order( count( $this->children() ) );
568
+		if ($set_order || $line_item->order() === null) {
569
+			$line_item->set_order(count($this->children()));
570 570
 		}
571
-		if ( $this->ID() ) {
571
+		if ($this->ID()) {
572 572
 			//check for any duplicate line items (with the same code), if so, this replaces it
573
-			$line_item_with_same_code = $this->get_child_line_item(  $line_item->code() );
574
-			if( $line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item ) {
575
-				$this->delete_child_line_item( $line_item_with_same_code->code() );
573
+			$line_item_with_same_code = $this->get_child_line_item($line_item->code());
574
+			if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) {
575
+				$this->delete_child_line_item($line_item_with_same_code->code());
576 576
 			}
577
-			$line_item->set_parent_ID( $this->ID() );
578
-			if( $this->TXN_ID() ){
579
-				$line_item->set_TXN_ID( $this->TXN_ID() );
577
+			$line_item->set_parent_ID($this->ID());
578
+			if ($this->TXN_ID()) {
579
+				$line_item->set_TXN_ID($this->TXN_ID());
580 580
 			}
581 581
 			return $line_item->save();
582 582
 		} else {
583
-			$this->_children[ $line_item->code() ] = $line_item;
584
-			if( $line_item->parent() != $this ) {
585
-				$line_item->set_parent( $this );
583
+			$this->_children[$line_item->code()] = $line_item;
584
+			if ($line_item->parent() != $this) {
585
+				$line_item->set_parent($this);
586 586
 			}
587 587
 			return TRUE;
588 588
 		}
@@ -596,16 +596,16 @@  discard block
 block discarded – undo
596 596
 	 * @param EE_Line_Item $line_item
597 597
 	 *
598 598
 	 */
599
-	public function set_parent( $line_item ) {
600
-		if ( $this->ID() ) {
601
-			if( ! $line_item->ID() ) {
599
+	public function set_parent($line_item) {
600
+		if ($this->ID()) {
601
+			if ( ! $line_item->ID()) {
602 602
 				$line_item->save();
603 603
 			}
604
-			$this->set_parent_ID( $line_item->ID() );
604
+			$this->set_parent_ID($line_item->ID());
605 605
 			$this->save();
606 606
 		} else {
607 607
 			$this->_parent = $line_item;
608
-			$this->set_parent_ID( $line_item->ID() );
608
+			$this->set_parent_ID($line_item->ID());
609 609
 		}
610 610
 	}
611 611
 
@@ -618,11 +618,11 @@  discard block
 block discarded – undo
618 618
 	 * @param string $code
619 619
 	 * @return EE_Line_Item
620 620
 	 */
621
-	public function get_child_line_item( $code ) {
622
-		if ( $this->ID() ) {
623
-			return $this->get_model()->get_one( array( array( 'LIN_parent' => $this->ID(), 'LIN_code' => $code ) ) );
621
+	public function get_child_line_item($code) {
622
+		if ($this->ID()) {
623
+			return $this->get_model()->get_one(array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code)));
624 624
 		} else {
625
-			return isset( $this->_children[ $code ] ) ? $this->_children[ $code ] : null;
625
+			return isset($this->_children[$code]) ? $this->_children[$code] : null;
626 626
 		}
627 627
 	}
628 628
 
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 	 * @return int
634 634
 	 */
635 635
 	public function delete_children_line_items() {
636
-		if ( $this->ID() ) {
637
-			return $this->get_model()->delete( array( array( 'LIN_parent' => $this->ID() ) ) );
636
+		if ($this->ID()) {
637
+			return $this->get_model()->delete(array(array('LIN_parent' => $this->ID())));
638 638
 		} else {
639
-			$count = count( $this->_children );
639
+			$count = count($this->_children);
640 640
 			$this->_children = array();
641 641
 			return $count;
642 642
 		}
@@ -653,25 +653,25 @@  discard block
 block discarded – undo
653 653
 	 * @param bool $stop_search_once_found
654 654
 	 * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet)
655 655
 	 */
656
-	public function delete_child_line_item( $code, $stop_search_once_found = true ) {
657
-		if ( $this->ID() ) {
656
+	public function delete_child_line_item($code, $stop_search_once_found = true) {
657
+		if ($this->ID()) {
658 658
 			$items_deleted = 0;
659
-			if( $this->code() == $code ) {
660
-				$items_deleted += EEH_Line_Item::delete_all_child_items( $this );
659
+			if ($this->code() == $code) {
660
+				$items_deleted += EEH_Line_Item::delete_all_child_items($this);
661 661
 				$items_deleted += (int) $this->delete();
662
-				if( $stop_search_once_found ){
662
+				if ($stop_search_once_found) {
663 663
 					return $items_deleted;
664 664
 				}
665 665
 			}
666
-			foreach( $this->children() as $child_line_item ) {
667
-				$items_deleted += $child_line_item->delete_child_line_item( $code, $stop_search_once_found );
666
+			foreach ($this->children() as $child_line_item) {
667
+				$items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found);
668 668
 			}
669 669
 			return $items_deleted;
670 670
 		} else {
671
-			if( isset( $this->_children[ $code ] ) ) {
672
-				unset( $this->_children[ $code ] );
671
+			if (isset($this->_children[$code])) {
672
+				unset($this->_children[$code]);
673 673
 				return 1;
674
-			}else{
674
+			} else {
675 675
 				return 0;
676 676
 			}
677 677
 		}
@@ -684,9 +684,9 @@  discard block
 block discarded – undo
684 684
 	 * @return boolean
685 685
 	 */
686 686
 	public function delete_if_childless_subtotal() {
687
-		if( $this->ID() &&
687
+		if ($this->ID() &&
688 688
 				$this->type() == EEM_Line_Item::type_sub_total &&
689
-				! $this->children() ) {
689
+				! $this->children()) {
690 690
 			return $this->delete();
691 691
 		} else {
692 692
 			return false;
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	 */
702 702
 	public function generate_code() {
703 703
 		// each line item in the cart requires a unique identifier
704
-		return md5( $this->get( 'OBJ_type' ) . $this->get( 'OBJ_ID' ) . microtime() );
704
+		return md5($this->get('OBJ_type').$this->get('OBJ_ID').microtime());
705 705
 	}
706 706
 
707 707
 
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * @return string like '2, 004.00', formatted according to the localized currency
775 775
 	 */
776 776
 	public function unit_price_no_code() {
777
-		return $this->get_pretty( 'LIN_unit_price', 'no_currency_code' );
777
+		return $this->get_pretty('LIN_unit_price', 'no_currency_code');
778 778
 	}
779 779
 
780 780
 
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 	 * @return string like '2, 004.00', formatted according to the localized currency
785 785
 	 */
786 786
 	public function total_no_code() {
787
-		return $this->get_pretty( 'LIN_total', 'no_currency_code' );
787
+		return $this->get_pretty('LIN_total', 'no_currency_code');
788 788
 	}
789 789
 
790 790
 
@@ -804,17 +804,17 @@  discard block
 block discarded – undo
804 804
 		$tax_total = $this->recalculate_taxes_and_tax_total();
805 805
 		$total = $pre_tax_total + $tax_total;
806 806
 		// no negative totals plz
807
-		$total = max( $total, 0 );
808
-		$this->set_total( $total );
807
+		$total = max($total, 0);
808
+		$this->set_total($total);
809 809
 		//only update the related transaction's total
810 810
 		//if we intend to save this line item and its a grand total
811
-		if(
811
+		if (
812 812
 			$this->allow_persist() &&
813 813
 			$this->type() === EEM_Line_Item::type_total &&
814 814
 			$this->transaction() instanceof EE_Transaction
815
-		){
816
-			$this->transaction()->set_total( $total );
817
-			if ( $this->transaction()->ID() ) {
815
+		) {
816
+			$this->transaction()->set_total($total);
817
+			if ($this->transaction()->ID()) {
818 818
 				$this->transaction()->save();
819 819
 			}
820 820
 		}
@@ -834,42 +834,42 @@  discard block
 block discarded – undo
834 834
 		$total = 0;
835 835
 		$my_children = $this->children();
836 836
 		// completely ignore tax totals, tax sub-totals, and cancelled line items, when calculating the pre-tax-total
837
-		if ( $this->is_tax_sub_total() || $this->is_tax() || $this->is_cancelled() ) {
837
+		if ($this->is_tax_sub_total() || $this->is_tax() || $this->is_cancelled()) {
838 838
 			return 0;
839 839
 		} elseif (
840
-			empty( $my_children )
841
-			&& ( $this->is_sub_line_item() || $this->is_line_item() )
840
+			empty($my_children)
841
+			&& ($this->is_sub_line_item() || $this->is_line_item())
842 842
 		) {
843 843
 			$total = $this->unit_price() * $this->quantity();
844
-		} elseif( $this->is_sub_total() || $this->is_total() ) {
845
-			$total = $this->_recalculate_pretax_total_for_subtotal( $total, $my_children );
846
-		} elseif ( ! empty( $my_children ) && $this->is_line_item() ) {
847
-			$total = $this->_recalculate_pretax_total_for_line_item( $total, $my_children );
844
+		} elseif ($this->is_sub_total() || $this->is_total()) {
845
+			$total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children);
846
+		} elseif ( ! empty($my_children) && $this->is_line_item()) {
847
+			$total = $this->_recalculate_pretax_total_for_line_item($total, $my_children);
848 848
 		}
849 849
 		//ensure all non-line items and non-sub-line-items have a quantity of 1
850
-		if( ! $this->is_line_item() && ! $this->is_sub_line_item() ) {
851
-			$this->set_quantity( 1 );
852
-			if( ! $this->is_percent() ) {
853
-				$this->set_unit_price( $this->total() );
850
+		if ( ! $this->is_line_item() && ! $this->is_sub_line_item()) {
851
+			$this->set_quantity(1);
852
+			if ( ! $this->is_percent()) {
853
+				$this->set_unit_price($this->total());
854 854
 			}
855 855
 		}
856 856
 
857 857
 		//we don't want to bother saving grand totals, because that needs to factor in taxes anyways
858 858
 		//so it ought to be
859
-		if( ! $this->is_total() ) {
860
-			$this->set_total( $total );
859
+		if ( ! $this->is_total()) {
860
+			$this->set_total($total);
861 861
 			//if not a percent line item, make sure we keep the unit price in sync
862
-			if(
863
-				! empty( $my_children )
862
+			if (
863
+				! empty($my_children)
864 864
 				&& $this->is_line_item()
865 865
 				&& ! $this->is_percent()
866 866
 			) {
867
-				if( $this->quantity() === 0 ){
867
+				if ($this->quantity() === 0) {
868 868
 					$new_unit_price = 0;
869 869
 				} else {
870 870
 					$new_unit_price = $this->total() / $this->quantity();
871 871
 				}
872
-				$this->set_unit_price( $new_unit_price );
872
+				$this->set_unit_price($new_unit_price);
873 873
 			}
874 874
 			$this->maybe_save();
875 875
 		}
@@ -889,39 +889,39 @@  discard block
 block discarded – undo
889 889
 	 * @return float
890 890
 	 * @throws \EE_Error
891 891
 	 */
892
-	protected function _recalculate_pretax_total_for_subtotal( $calculated_total_so_far, $my_children = null ) {
893
-		if( $my_children === null ) {
892
+	protected function _recalculate_pretax_total_for_subtotal($calculated_total_so_far, $my_children = null) {
893
+		if ($my_children === null) {
894 894
 			$my_children = $this->children();
895 895
 		}
896 896
 		//get the total of all its children
897
-		foreach ( $my_children as $child_line_item ) {
898
-			if ( $child_line_item instanceof EE_Line_Item ) {
897
+		foreach ($my_children as $child_line_item) {
898
+			if ($child_line_item instanceof EE_Line_Item) {
899 899
 				// percentage line items are based on total so far
900
-				if ( $child_line_item->is_percent() ) {
900
+				if ($child_line_item->is_percent()) {
901 901
 					//round as we go so that the line items add up ok
902 902
 					$percent_total = round(
903 903
 						$calculated_total_so_far * $child_line_item->percent() / 100,
904 904
 						EE_Registry::instance()->CFG->currency->dec_plc
905 905
 					);
906
-					$child_line_item->set_total( $percent_total );
906
+					$child_line_item->set_total($percent_total);
907 907
 					//so far all percent line items should have a quantity of 1
908 908
 					//(ie, no double percent discounts. Although that might be requested someday)
909
-					$child_line_item->set_quantity( 1 );
909
+					$child_line_item->set_quantity(1);
910 910
 					$child_line_item->maybe_save();
911 911
 					$calculated_total_so_far += $percent_total;
912 912
 				} else {
913 913
 					//verify flat sub-line-item quantities match their parent
914
-					if( $child_line_item->is_sub_line_item() ) {
915
-						$child_line_item->set_quantity( $this->quantity() );
914
+					if ($child_line_item->is_sub_line_item()) {
915
+						$child_line_item->set_quantity($this->quantity());
916 916
 					}
917 917
 					$calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
918 918
 				}
919 919
 			}
920 920
 		}
921 921
 
922
-		if( $this->is_sub_total() ){
922
+		if ($this->is_sub_total()) {
923 923
 			// no negative totals plz
924
-			$calculated_total_so_far = max( $calculated_total_so_far, 0 );
924
+			$calculated_total_so_far = max($calculated_total_so_far, 0);
925 925
 		}
926 926
 		return $calculated_total_so_far;
927 927
 	}
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	 * @return float
940 940
 	 * @throws \EE_Error
941 941
 	 */
942
-	protected function _recalculate_pretax_total_for_line_item( $calculated_total_so_far, $my_children = null ) {
943
-		if( $my_children === null ) {
942
+	protected function _recalculate_pretax_total_for_line_item($calculated_total_so_far, $my_children = null) {
943
+		if ($my_children === null) {
944 944
 			$my_children = $this->children();
945 945
 		}
946 946
 		//we need to keep track of the running total for a single item,
@@ -948,9 +948,9 @@  discard block
 block discarded – undo
948 948
 		$unit_price_for_total = 0;
949 949
 		$quantity_for_total = 1;
950 950
 		//get the total of all its children
951
-		foreach ( $my_children as $child_line_item ) {
952
-			if ( $child_line_item instanceof EE_Line_Item ) {
953
-				if ( $child_line_item->is_percent() ) {
951
+		foreach ($my_children as $child_line_item) {
952
+			if ($child_line_item instanceof EE_Line_Item) {
953
+				if ($child_line_item->is_percent()) {
954 954
 					//it should be the unit-price-so-far multiplied by teh percent multiplied by the quantity
955 955
 					//not total multiplied by percent, because that ignores rounding along-the-way
956 956
 					$percent_unit_price = round(
@@ -958,17 +958,17 @@  discard block
 block discarded – undo
958 958
 						EE_Registry::instance()->CFG->currency->dec_plc
959 959
 					);
960 960
 					$percent_total = $percent_unit_price * $quantity_for_total;
961
-					$child_line_item->set_total( $percent_total );
961
+					$child_line_item->set_total($percent_total);
962 962
 					//so far all percent line items should have a quantity of 1
963 963
 					//(ie, no double percent discounts. Although that might be requested someday)
964
-					$child_line_item->set_quantity( 1 );
964
+					$child_line_item->set_quantity(1);
965 965
 					$child_line_item->maybe_save();
966 966
 					$calculated_total_so_far += $percent_total;
967 967
 					$unit_price_for_total += $percent_unit_price;
968 968
 				} else {
969 969
 					//verify flat sub-line-item quantities match their parent
970
-					if( $child_line_item->is_sub_line_item() ) {
971
-						$child_line_item->set_quantity( $this->quantity() );
970
+					if ($child_line_item->is_sub_line_item()) {
971
+						$child_line_item->set_quantity($this->quantity());
972 972
 					}
973 973
 					$quantity_for_total = $child_line_item->quantity();
974 974
 					$calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
@@ -992,10 +992,10 @@  discard block
 block discarded – undo
992 992
 		//calculate the pretax total
993 993
 		$taxable_total = $this->taxable_total();
994 994
 		$tax_total = 0;
995
-		foreach ( $taxes as $tax ) {
995
+		foreach ($taxes as $tax) {
996 996
 			$total_on_this_tax = $taxable_total * $tax->percent() / 100;
997 997
 			//remember the total on this line item
998
-			$tax->set_total( $total_on_this_tax );
998
+			$tax->set_total($total_on_this_tax);
999 999
 			$tax_total += $tax->total();
1000 1000
 		}
1001 1001
 		$this->_recalculate_tax_sub_total();
@@ -1009,21 +1009,21 @@  discard block
 block discarded – undo
1009 1009
 	 * @return void
1010 1010
 	 */
1011 1011
 	private function _recalculate_tax_sub_total() {
1012
-		if ( $this->is_tax_sub_total() ) {
1012
+		if ($this->is_tax_sub_total()) {
1013 1013
 			$total = 0;
1014 1014
 			$total_percent = 0;
1015 1015
 			//simply loop through all its children (which should be taxes) and sum their total
1016
-			foreach ( $this->children() as $child_tax ) {
1017
-				if ( $child_tax instanceof EE_Line_Item ) {
1016
+			foreach ($this->children() as $child_tax) {
1017
+				if ($child_tax instanceof EE_Line_Item) {
1018 1018
 					$total += $child_tax->total();
1019 1019
 					$total_percent += $child_tax->percent();
1020 1020
 				}
1021 1021
 			}
1022
-			$this->set_total( $total );
1023
-			$this->set_percent( $total_percent );
1024
-		} elseif ( $this->is_total() ) {
1025
-			foreach ( $this->children() as $maybe_tax_subtotal ) {
1026
-				if ( $maybe_tax_subtotal instanceof EE_Line_Item ) {
1022
+			$this->set_total($total);
1023
+			$this->set_percent($total_percent);
1024
+		} elseif ($this->is_total()) {
1025
+			foreach ($this->children() as $maybe_tax_subtotal) {
1026
+				if ($maybe_tax_subtotal instanceof EE_Line_Item) {
1027 1027
 					$maybe_tax_subtotal->_recalculate_tax_sub_total();
1028 1028
 				}
1029 1029
 			}
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 	public function get_total_tax() {
1040 1040
 		$this->_recalculate_tax_sub_total();
1041 1041
 		$total = 0;
1042
-		foreach ( $this->tax_descendants() as $tax_line_item ) {
1043
-			if ( $tax_line_item instanceof EE_Line_Item ) {
1042
+		foreach ($this->tax_descendants() as $tax_line_item) {
1043
+			if ($tax_line_item instanceof EE_Line_Item) {
1044 1044
 				$total += $tax_line_item->total();
1045 1045
 			}
1046 1046
 		}
@@ -1054,15 +1054,15 @@  discard block
 block discarded – undo
1054 1054
 	 */
1055 1055
 	public function get_items_total() {
1056 1056
 		//by default, let's make sure we're consistent with the existing line item
1057
-		if( $this->is_total() ) {
1058
-			$pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal( $this );
1059
-			if( $pretax_subtotal_li instanceof EE_Line_Item ) {
1057
+		if ($this->is_total()) {
1058
+			$pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal($this);
1059
+			if ($pretax_subtotal_li instanceof EE_Line_Item) {
1060 1060
 				return $pretax_subtotal_li->total();
1061 1061
 			}
1062 1062
 		}
1063 1063
 		$total = 0;
1064
-		foreach ( $this->get_items() as $item ) {
1065
-			if ( $item instanceof EE_Line_Item ) {
1064
+		foreach ($this->get_items() as $item) {
1065
+			if ($item instanceof EE_Line_Item) {
1066 1066
 				$total += $item->total();
1067 1067
 			}
1068 1068
 		}
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 	 * @return EE_Line_Item[]
1078 1078
 	 */
1079 1079
 	public function tax_descendants() {
1080
-		return EEH_Line_Item::get_tax_descendants( $this );
1080
+		return EEH_Line_Item::get_tax_descendants($this);
1081 1081
 	}
1082 1082
 
1083 1083
 
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 	 * @return EE_Line_Item[]
1088 1088
 	 */
1089 1089
 	public function get_items() {
1090
-		return EEH_Line_Item::get_line_item_descendants( $this );
1090
+		return EEH_Line_Item::get_line_item_descendants($this);
1091 1091
 	}
1092 1092
 
1093 1093
 
@@ -1103,22 +1103,22 @@  discard block
 block discarded – undo
1103 1103
 	 */
1104 1104
 	public function taxable_total() {
1105 1105
 		$total = 0;
1106
-		if ( $this->children() ) {
1107
-			foreach ( $this->children() as $child_line_item ) {
1108
-				if ( $child_line_item->type() === EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
1106
+		if ($this->children()) {
1107
+			foreach ($this->children() as $child_line_item) {
1108
+				if ($child_line_item->type() === EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
1109 1109
 					//if it's a percent item, only take into account the percent
1110 1110
 					//that's taxable too (the taxable total so far)
1111
-					if( $child_line_item->is_percent() ) {
1112
-						$total = $total + ( $total * $child_line_item->percent() / 100 );
1113
-					}else{
1111
+					if ($child_line_item->is_percent()) {
1112
+						$total = $total + ($total * $child_line_item->percent() / 100);
1113
+					} else {
1114 1114
 						$total += $child_line_item->total();
1115 1115
 					}
1116
-				}elseif( $child_line_item->type() === EEM_Line_Item::type_sub_total ){
1116
+				}elseif ($child_line_item->type() === EEM_Line_Item::type_sub_total) {
1117 1117
 					$total += $child_line_item->taxable_total();
1118 1118
 				}
1119 1119
 			}
1120 1120
 		}
1121
-		return max( $total, 0 );
1121
+		return max($total, 0);
1122 1122
 	}
1123 1123
 
1124 1124
 
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 	 * @return EE_Transaction
1129 1129
 	 */
1130 1130
 	public function transaction() {
1131
-		return $this->get_first_related( 'Transaction' );
1131
+		return $this->get_first_related('Transaction');
1132 1132
 	}
1133 1133
 
1134 1134
 
@@ -1141,17 +1141,17 @@  discard block
 block discarded – undo
1141 1141
 	 * @param int $txn_id if none is provided, assumes $this->TXN_ID()
1142 1142
 	 * @return int count of items saved
1143 1143
 	 */
1144
-	public function save_this_and_descendants_to_txn( $txn_id = NULL ) {
1145
-		if ( ! $txn_id ) {
1144
+	public function save_this_and_descendants_to_txn($txn_id = NULL) {
1145
+		if ( ! $txn_id) {
1146 1146
 			$txn_id = $this->TXN_ID();
1147 1147
 		}
1148
-		$this->set_TXN_ID( $txn_id );
1148
+		$this->set_TXN_ID($txn_id);
1149 1149
 		$children = $this->children();
1150 1150
 		$this->save();
1151
-		foreach ( $children as $child_line_item ) {
1152
-			if ( $child_line_item instanceof EE_Line_Item ) {
1153
-				$child_line_item->set_parent_ID( $this->ID() );
1154
-				$child_line_item->save_this_and_descendants_to_txn( $txn_id );
1151
+		foreach ($children as $child_line_item) {
1152
+			if ($child_line_item instanceof EE_Line_Item) {
1153
+				$child_line_item->set_parent_ID($this->ID());
1154
+				$child_line_item->save_this_and_descendants_to_txn($txn_id);
1155 1155
 			}
1156 1156
 		}
1157 1157
 	}
@@ -1163,9 +1163,9 @@  discard block
 block discarded – undo
1163 1163
 	 * @param string $type one of the constants on EEM_Line_Item
1164 1164
 	 * @return EE_Line_Item[]
1165 1165
 	 */
1166
-	protected function _get_descendants_of_type( $type ) {
1167
-		EE_Error::doing_it_wrong( 'EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0' );
1168
-		return EEH_Line_Item::get_descendants_of_type( $this, $type );
1166
+	protected function _get_descendants_of_type($type) {
1167
+		EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0');
1168
+		return EEH_Line_Item::get_descendants_of_type($this, $type);
1169 1169
 	}
1170 1170
 
1171 1171
 
@@ -1175,9 +1175,9 @@  discard block
 block discarded – undo
1175 1175
 	 * @param string $type like one of the EEM_Line_Item::type_*
1176 1176
 	 * @return EE_Line_Item
1177 1177
 	 */
1178
-	public function get_nearest_descendant_of_type( $type ) {
1179
-		EE_Error::doing_it_wrong( 'EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0' );
1180
-		return EEH_Line_Item::get_nearest_descendant_of_type( $this, $type );
1178
+	public function get_nearest_descendant_of_type($type) {
1179
+		EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0');
1180
+		return EEH_Line_Item::get_nearest_descendant_of_type($this, $type);
1181 1181
 	}
1182 1182
 
1183 1183
 
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 	 * @return int count of items saved
1189 1189
 	 */
1190 1190
 	public function maybe_save() {
1191
-		if ( $this->ID() ) {
1191
+		if ($this->ID()) {
1192 1192
 			return $this->save();
1193 1193
 		}
1194 1194
 		return false;
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 			if( isset( $this->_children[ $code ] ) ) {
672 672
 				unset( $this->_children[ $code ] );
673 673
 				return 1;
674
-			}else{
674
+			} else{
675 675
 				return 0;
676 676
 			}
677 677
 		}
@@ -1110,10 +1110,10 @@  discard block
 block discarded – undo
1110 1110
 					//that's taxable too (the taxable total so far)
1111 1111
 					if( $child_line_item->is_percent() ) {
1112 1112
 						$total = $total + ( $total * $child_line_item->percent() / 100 );
1113
-					}else{
1113
+					} else{
1114 1114
 						$total += $child_line_item->total();
1115 1115
 					}
1116
-				}elseif( $child_line_item->type() === EEM_Line_Item::type_sub_total ){
1116
+				} elseif( $child_line_item->type() === EEM_Line_Item::type_sub_total ){
1117 1117
 					$total += $child_line_item->taxable_total();
1118 1118
 				}
1119 1119
 			}
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -218,24 +218,24 @@
 block discarded – undo
218 218
 	 * @return string
219 219
 	 */
220 220
 	function OBJ_type_i18n() {
221
-	    $obj_type = $this->OBJ_type();
222
-        switch ($obj_type) {
223
-            case 'Event':
224
-                $obj_type = __('Event', 'event_espresso');
225
-                break;
226
-            case 'Price':
227
-                $obj_type = __('Price', 'event_espresso');
228
-                break;
229
-            case 'Promotion':
230
-                $obj_type = __('Promotion', 'event_espresso');
231
-                break;
232
-            case 'Ticket':
233
-                $obj_type = __('Ticket', 'event_espresso');
234
-                break;
235
-            case 'Transaction':
236
-                $obj_type = __('Transaction', 'event_espresso');
237
-                break;
238
-        }
221
+		$obj_type = $this->OBJ_type();
222
+		switch ($obj_type) {
223
+			case 'Event':
224
+				$obj_type = __('Event', 'event_espresso');
225
+				break;
226
+			case 'Price':
227
+				$obj_type = __('Price', 'event_espresso');
228
+				break;
229
+			case 'Promotion':
230
+				$obj_type = __('Promotion', 'event_espresso');
231
+				break;
232
+			case 'Ticket':
233
+				$obj_type = __('Ticket', 'event_espresso');
234
+				break;
235
+			case 'Transaction':
236
+				$obj_type = __('Transaction', 'event_espresso');
237
+				break;
238
+		}
239 239
 		return apply_filters('FHEE__EE_Line_Item__OBJ_type_i18n', $obj_type, $this);
240 240
 	}
241 241
 
Please login to merge, or discard this patch.
core/helpers/EEH_Line_Item.helper.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -551,15 +551,15 @@  discard block
 block discarded – undo
551 551
 	}
552 552
 
553 553
 	/**
554
-	  * Given the grand total line item and a ticket, finds the event sub-total
555
-	  * line item the ticket's purchase should be added onto
556
-	  *
557
-	  * @access public
558
-	  * @param EE_Line_Item $grand_total the grand total line item
559
-	  * @param EE_Ticket $ticket
560
-	  * @throws \EE_Error
561
-	  * @return EE_Line_Item
562
-	  */
554
+	 * Given the grand total line item and a ticket, finds the event sub-total
555
+	 * line item the ticket's purchase should be added onto
556
+	 *
557
+	 * @access public
558
+	 * @param EE_Line_Item $grand_total the grand total line item
559
+	 * @param EE_Ticket $ticket
560
+	 * @throws \EE_Error
561
+	 * @return EE_Line_Item
562
+	 */
563 563
 	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
564 564
 		$first_datetime = $ticket->first_datetime();
565 565
 		if ( ! $first_datetime instanceof EE_Datetime ) {
@@ -807,22 +807,22 @@  discard block
 block discarded – undo
807 807
 		$add_to_existing_line_item = false
808 808
 	) {
809 809
 		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
810
-            $taxable_total = $total_line_item->taxable_total();
811
-
812
-            if( $add_to_existing_line_item ) {
813
-                $new_tax = $tax_subtotal->get_child_line_item( $code );
814
-	            EEM_Line_Item::instance()->delete(
815
-		            array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) )
816
-	            );
817
-            } else {
818
-                $new_tax = null;
819
-                $tax_subtotal->delete_children_line_items();
820
-            }
821
-            if( $new_tax ) {
822
-                $new_tax->set_total( $new_tax->total() + $amount );
823
-                $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 );
824
-            } else {
825
-                //no existing tax item. Create it
810
+			$taxable_total = $total_line_item->taxable_total();
811
+
812
+			if( $add_to_existing_line_item ) {
813
+				$new_tax = $tax_subtotal->get_child_line_item( $code );
814
+				EEM_Line_Item::instance()->delete(
815
+					array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) )
816
+				);
817
+			} else {
818
+				$new_tax = null;
819
+				$tax_subtotal->delete_children_line_items();
820
+			}
821
+			if( $new_tax ) {
822
+				$new_tax->set_total( $new_tax->total() + $amount );
823
+				$new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 );
824
+			} else {
825
+				//no existing tax item. Create it
826 826
 				$new_tax = EE_Line_Item::new_instance( array(
827 827
 					'TXN_ID'      => $total_line_item->TXN_ID(),
828 828
 					'LIN_name'    => $name ? $name : __( 'Tax', 'event_espresso' ),
@@ -835,16 +835,16 @@  discard block
 block discarded – undo
835 835
 				) );
836 836
 			}
837 837
 
838
-            $new_tax = apply_filters(
838
+			$new_tax = apply_filters(
839 839
 				'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal',
840 840
 				$new_tax,
841 841
 				$total_line_item
842
-            );
843
-            $new_tax->save();
844
-            $tax_subtotal->set_total( $new_tax->total() );
845
-            $tax_subtotal->save();
846
-            $total_line_item->recalculate_total_including_taxes();
847
-            return $new_tax;
842
+			);
843
+			$new_tax->save();
844
+			$tax_subtotal->set_total( $new_tax->total() );
845
+			$tax_subtotal->save();
846
+			$total_line_item->recalculate_total_including_taxes();
847
+			return $new_tax;
848 848
 	}
849 849
 
850 850
 
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 			if ( $child_line_item instanceof EE_Line_Item ) {
991 991
 				if (
992 992
 					$child_line_item->type() === $line_item_type
993
-				    && (
993
+					&& (
994 994
 						$child_line_item->OBJ_type() === $obj_type || $obj_type === null
995 995
 					)
996 996
 				) {
Please login to merge, or discard this patch.
Spacing   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 /**
3 3
  *
4 4
  * EEH_Line_Item
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @return boolean success
43 43
 	 * @throws \EE_Error
44 44
 	 */
45
-	public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL  ){
46
-		$items_subtotal = self::get_pre_tax_subtotal( $parent_line_item );
45
+	public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) {
46
+		$items_subtotal = self::get_pre_tax_subtotal($parent_line_item);
47 47
 		$line_item = EE_Line_Item::new_instance(array(
48 48
 			'LIN_name' => $name,
49 49
 			'LIN_desc' => $description,
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			'LIN_quantity' => $quantity,
52 52
 			'LIN_percent' => null,
53 53
 			'LIN_is_taxable' => $taxable,
54
-			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
54
+			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
55 55
 			'LIN_total' => (float) $unit_price * (int) $quantity,
56 56
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
57 57
 			'LIN_code' => $code,
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			$line_item,
62 62
 			$parent_line_item
63 63
 		);
64
-		return self::add_item( $parent_line_item, $line_item );
64
+		return self::add_item($parent_line_item, $line_item);
65 65
 	}
66 66
 
67 67
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return boolean success
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){
86
+	public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) {
87 87
 		$line_item = EE_Line_Item::new_instance(array(
88 88
 			'LIN_name' => $name,
89 89
 			'LIN_desc' => $description,
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'LIN_percent' => $percentage_amount,
92 92
 			'LIN_quantity' => NULL,
93 93
 			'LIN_is_taxable' => $taxable,
94
-			'LIN_total' => (float) ( $percentage_amount * ( $parent_line_item->total() / 100 ) ),
94
+			'LIN_total' => (float) ($percentage_amount * ($parent_line_item->total() / 100)),
95 95
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
96 96
 			'LIN_parent' => $parent_line_item->ID()
97 97
 		));
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			'FHEE__EEH_Line_Item__add_percentage_based_item__line_item',
100 100
 			$line_item
101 101
 		);
102
-		return self::add_item( $parent_line_item, $line_item );
102
+		return self::add_item($parent_line_item, $line_item);
103 103
 	}
104 104
 
105 105
 
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 	 * @return \EE_Line_Item
121 121
 	 * @throws \EE_Error
122 122
 	 */
123
-	public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){
124
-		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) {
125
-			throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) );
123
+	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
124
+		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) {
125
+			throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID()));
126 126
 		}
127 127
 		// either increment the qty for an existing ticket
128
-		$line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty );
128
+		$line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty);
129 129
 		// or add a new one
130
-		if ( ! $line_item instanceof EE_Line_Item ) {
131
-			$line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty );
130
+		if ( ! $line_item instanceof EE_Line_Item) {
131
+			$line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty);
132 132
 		}
133 133
 		$total_line_item->recalculate_total_including_taxes();
134 134
 		return $line_item;
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	 * @return \EE_Line_Item
145 145
 	 * @throws \EE_Error
146 146
 	 */
147
-	public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
147
+	public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
148 148
 		$line_item = null;
149
-		if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) {
150
-			$ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item );
151
-			foreach ( (array)$ticket_line_items as $ticket_line_item ) {
149
+		if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) {
150
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
151
+			foreach ((array) $ticket_line_items as $ticket_line_item) {
152 152
 				if (
153 153
 					$ticket_line_item instanceof EE_Line_Item
154 154
 					&& (int) $ticket_line_item->OBJ_ID() === (int) $ticket->ID()
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 				}
159 159
 			}
160 160
 		}
161
-		if ( $line_item instanceof EE_Line_Item ) {
162
-			EEH_Line_Item::increment_quantity( $line_item, $qty );
161
+		if ($line_item instanceof EE_Line_Item) {
162
+			EEH_Line_Item::increment_quantity($line_item, $qty);
163 163
 			return $line_item;
164 164
 		}
165 165
 		return null;
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 	 * @return void
177 177
 	 * @throws \EE_Error
178 178
 	 */
179
-	public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) {
180
-		if( ! $line_item->is_percent() ) {
179
+	public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) {
180
+		if ( ! $line_item->is_percent()) {
181 181
 			$qty += $line_item->quantity();
182
-			$line_item->set_quantity( $qty );
183
-			$line_item->set_total( $line_item->unit_price() * $qty );
182
+			$line_item->set_quantity($qty);
183
+			$line_item->set_total($line_item->unit_price() * $qty);
184 184
 			$line_item->save();
185 185
 		}
186
-		foreach( $line_item->children() as $child ) {
187
-			if( $child->is_sub_line_item() ) {
188
-				EEH_Line_Item::update_quantity( $child, $qty );
186
+		foreach ($line_item->children() as $child) {
187
+			if ($child->is_sub_line_item()) {
188
+				EEH_Line_Item::update_quantity($child, $qty);
189 189
 			}
190 190
 		}
191 191
 	}
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 * @return void
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	public static function decrement_quantity( EE_Line_Item $line_item, $qty = 1 ) {
205
-		if( ! $line_item->is_percent() ) {
204
+	public static function decrement_quantity(EE_Line_Item $line_item, $qty = 1) {
205
+		if ( ! $line_item->is_percent()) {
206 206
 			$qty = $line_item->quantity() - $qty;
207
-			$qty = max( $qty, 0 );
208
-			$line_item->set_quantity( $qty );
209
-			$line_item->set_total( $line_item->unit_price() * $qty );
207
+			$qty = max($qty, 0);
208
+			$line_item->set_quantity($qty);
209
+			$line_item->set_total($line_item->unit_price() * $qty);
210 210
 			$line_item->save();
211 211
 		}
212
-		foreach( $line_item->children() as $child ) {
213
-			if( $child->is_sub_line_item() ) {
214
-				EEH_Line_Item::update_quantity( $child, $qty );
212
+		foreach ($line_item->children() as $child) {
213
+			if ($child->is_sub_line_item()) {
214
+				EEH_Line_Item::update_quantity($child, $qty);
215 215
 			}
216 216
 		}
217 217
 	}
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
 	 * @param int          $new_quantity
227 227
 	 * @throws \EE_Error
228 228
 	 */
229
-	public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) {
230
-		if( ! $line_item->is_percent() ) {
231
-			$line_item->set_quantity( $new_quantity );
232
-			$line_item->set_total( $line_item->unit_price() * $new_quantity );
229
+	public static function update_quantity(EE_Line_Item $line_item, $new_quantity) {
230
+		if ( ! $line_item->is_percent()) {
231
+			$line_item->set_quantity($new_quantity);
232
+			$line_item->set_total($line_item->unit_price() * $new_quantity);
233 233
 			$line_item->save();
234 234
 		}
235
-		foreach( $line_item->children() as $child ) {
236
-			if( $child->is_sub_line_item() ) {
237
-				EEH_Line_Item::update_quantity( $child, $new_quantity );
235
+		foreach ($line_item->children() as $child) {
236
+			if ($child->is_sub_line_item()) {
237
+				EEH_Line_Item::update_quantity($child, $new_quantity);
238 238
 			}
239 239
 		}
240 240
 	}
@@ -249,44 +249,44 @@  discard block
 block discarded – undo
249 249
 	 * @return \EE_Line_Item
250 250
 	 * @throws \EE_Error
251 251
 	 */
252
-	public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
252
+	public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
253 253
 		$datetimes = $ticket->datetimes();
254
-		$first_datetime = reset( $datetimes );
255
-		if( $first_datetime instanceof EE_Datetime &&
256
-				$first_datetime->event() instanceof EE_Event ) {
254
+		$first_datetime = reset($datetimes);
255
+		if ($first_datetime instanceof EE_Datetime &&
256
+				$first_datetime->event() instanceof EE_Event) {
257 257
 			$first_datetime_name = $first_datetime->event()->name();
258 258
 		} else {
259
-			$first_datetime_name = __( 'Event', 'event_espresso' );
259
+			$first_datetime_name = __('Event', 'event_espresso');
260 260
 		}
261
-		$event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name );
261
+		$event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name);
262 262
 		// get event subtotal line
263
-		$events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket );
263
+		$events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket);
264 264
 		// add $ticket to cart
265
-		$line_item = EE_Line_Item::new_instance( array(
265
+		$line_item = EE_Line_Item::new_instance(array(
266 266
 			'LIN_name'       	=> $ticket->name(),
267
-			'LIN_desc'       		=> $ticket->description() !== '' ? $ticket->description() . ' ' . $event : $event,
267
+			'LIN_desc'       		=> $ticket->description() !== '' ? $ticket->description().' '.$event : $event,
268 268
 			'LIN_unit_price' 	=> $ticket->price(),
269 269
 			'LIN_quantity'   	=> $qty,
270 270
 			'LIN_is_taxable' 	=> $ticket->taxable(),
271
-			'LIN_order'      	=> count( $events_sub_total->children() ),
271
+			'LIN_order'      	=> count($events_sub_total->children()),
272 272
 			'LIN_total'      		=> $ticket->price() * $qty,
273 273
 			'LIN_type'       		=> EEM_Line_Item::type_line_item,
274 274
 			'OBJ_ID'         		=> $ticket->ID(),
275 275
 			'OBJ_type'       	=> 'Ticket'
276
-		) );
276
+		));
277 277
 		$line_item = apply_filters(
278 278
 			'FHEE__EEH_Line_Item__create_ticket_line_item__line_item',
279 279
 			$line_item
280 280
 		);
281
-		$events_sub_total->add_child_line_item( $line_item );
281
+		$events_sub_total->add_child_line_item($line_item);
282 282
 		//now add the sub-line items
283 283
 		$running_total_for_ticket = 0;
284
-		foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) {
284
+		foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) {
285 285
 			$sign = $price->is_discount() ? -1 : 1;
286 286
 			$price_total = $price->is_percent()
287 287
 				? $running_total_for_ticket * $price->amount() / 100
288 288
 				: $price->amount() * $qty;
289
-			$sub_line_item = EE_Line_Item::new_instance( array(
289
+			$sub_line_item = EE_Line_Item::new_instance(array(
290 290
 				'LIN_name'       	=> $price->name(),
291 291
 				'LIN_desc'       		=> $price->desc(),
292 292
 				'LIN_quantity'   	=> $price->is_percent() ? null : $qty,
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
 				'LIN_type'       		=> EEM_Line_Item::type_sub_line_item,
297 297
 				'OBJ_ID'         		=> $price->ID(),
298 298
 				'OBJ_type'       	=> 'Price'
299
-			) );
299
+			));
300 300
 			$sub_line_item = apply_filters(
301 301
 				'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item',
302 302
 				$sub_line_item
303 303
 			);
304
-			if ( $price->is_percent() ) {
305
-				$sub_line_item->set_percent( $sign * $price->amount() );
304
+			if ($price->is_percent()) {
305
+				$sub_line_item->set_percent($sign * $price->amount());
306 306
 			} else {
307
-				$sub_line_item->set_unit_price( $sign * $price->amount() );
307
+				$sub_line_item->set_unit_price($sign * $price->amount());
308 308
 			}
309 309
 			$running_total_for_ticket += $price_total;
310
-			$line_item->add_child_line_item( $sub_line_item );
310
+			$line_item->add_child_line_item($sub_line_item);
311 311
 		}
312 312
 		return $line_item;
313 313
 	}
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	 * @return boolean
328 328
 	 * @throws \EE_Error
329 329
 	 */
330
-	public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){
331
-		$pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item );
332
-		if ( $pre_tax_subtotal instanceof EE_Line_Item ){
330
+	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) {
331
+		$pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item);
332
+		if ($pre_tax_subtotal instanceof EE_Line_Item) {
333 333
 			$success = $pre_tax_subtotal->add_child_line_item($item);
334
-		}else{
334
+		} else {
335 335
 			return FALSE;
336 336
 		}
337 337
 		$total_line_item->recalculate_total_including_taxes();
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 	 * @return \EE_Line_Item
348 348
 	 * @throws \EE_Error
349 349
 	 */
350
-	public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){
351
-		$pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' );
350
+	public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) {
351
+		$pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal');
352 352
 		return $pre_tax_subtotal instanceof EE_Line_Item
353 353
 			? $pre_tax_subtotal
354
-			: self::create_pre_tax_subtotal( $total_line_item );
354
+			: self::create_pre_tax_subtotal($total_line_item);
355 355
 	}
356 356
 
357 357
 
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 * @return \EE_Line_Item
364 364
 	 * @throws \EE_Error
365 365
 	 */
366
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){
367
-		$taxes = $total_line_item->get_child_line_item( 'taxes' );
368
-		return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item );
366
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item) {
367
+		$taxes = $total_line_item->get_child_line_item('taxes');
368
+		return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item);
369 369
 	}
370 370
 
371 371
 
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 	 * @return void
379 379
 	 * @throws \EE_Error
380 380
 	 */
381
-	public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){
382
-		if( $transaction ){
381
+	public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) {
382
+		if ($transaction) {
383 383
 			/** @type EEM_Transaction $EEM_Transaction */
384
-			$EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' );
385
-			$TXN_ID = $EEM_Transaction->ensure_is_ID( $transaction );
386
-			$line_item->set_TXN_ID( $TXN_ID );
384
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
385
+			$TXN_ID = $EEM_Transaction->ensure_is_ID($transaction);
386
+			$line_item->set_TXN_ID($TXN_ID);
387 387
 		}
388 388
 	}
389 389
 
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @return \EE_Line_Item of type total
399 399
 	 * @throws \EE_Error
400 400
 	 */
401
-	public static function create_total_line_item( $transaction = NULL ){
402
-		$total_line_item = EE_Line_Item::new_instance( array(
401
+	public static function create_total_line_item($transaction = NULL) {
402
+		$total_line_item = EE_Line_Item::new_instance(array(
403 403
 			'LIN_code'	=> 'total',
404 404
 			'LIN_name'	=> __('Grand Total', 'event_espresso'),
405 405
 			'LIN_type'	=> EEM_Line_Item::type_total,
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 			'FHEE__EEH_Line_Item__create_total_line_item__total_line_item',
410 410
 			$total_line_item
411 411
 		);
412
-		self::set_TXN_ID( $total_line_item, $transaction );
413
-		self::create_pre_tax_subtotal( $total_line_item, $transaction );
414
-		self::create_taxes_subtotal( $total_line_item, $transaction );
412
+		self::set_TXN_ID($total_line_item, $transaction);
413
+		self::create_pre_tax_subtotal($total_line_item, $transaction);
414
+		self::create_taxes_subtotal($total_line_item, $transaction);
415 415
 		return $total_line_item;
416 416
 	}
417 417
 
@@ -425,19 +425,19 @@  discard block
 block discarded – undo
425 425
 	 * @return EE_Line_Item
426 426
 	 * @throws \EE_Error
427 427
 	 */
428
-	protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
429
-		$pre_tax_line_item = EE_Line_Item::new_instance( array(
428
+	protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
429
+		$pre_tax_line_item = EE_Line_Item::new_instance(array(
430 430
 			'LIN_code' 	=> 'pre-tax-subtotal',
431
-			'LIN_name' 	=> __( 'Pre-Tax Subtotal', 'event_espresso' ),
431
+			'LIN_name' 	=> __('Pre-Tax Subtotal', 'event_espresso'),
432 432
 			'LIN_type' 	=> EEM_Line_Item::type_sub_total
433
-		) );
433
+		));
434 434
 		$pre_tax_line_item = apply_filters(
435 435
 			'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item',
436 436
 			$pre_tax_line_item
437 437
 		);
438
-		self::set_TXN_ID( $pre_tax_line_item, $transaction );
439
-		$total_line_item->add_child_line_item( $pre_tax_line_item );
440
-		self::create_event_subtotal( $pre_tax_line_item, $transaction );
438
+		self::set_TXN_ID($pre_tax_line_item, $transaction);
439
+		$total_line_item->add_child_line_item($pre_tax_line_item);
440
+		self::create_event_subtotal($pre_tax_line_item, $transaction);
441 441
 		return $pre_tax_line_item;
442 442
 	}
443 443
 
@@ -452,21 +452,21 @@  discard block
 block discarded – undo
452 452
 	 * @return EE_Line_Item
453 453
 	 * @throws \EE_Error
454 454
 	 */
455
-	protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
455
+	protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
456 456
 		$tax_line_item = EE_Line_Item::new_instance(array(
457 457
 			'LIN_code'	=> 'taxes',
458 458
 			'LIN_name' 	=> __('Taxes', 'event_espresso'),
459 459
 			'LIN_type'	=> EEM_Line_Item::type_tax_sub_total,
460
-			'LIN_order' => 1000,//this should always come last
460
+			'LIN_order' => 1000, //this should always come last
461 461
 		));
462 462
 		$tax_line_item = apply_filters(
463 463
 			'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item',
464 464
 			$tax_line_item
465 465
 		);
466
-		self::set_TXN_ID( $tax_line_item, $transaction );
467
-		$total_line_item->add_child_line_item( $tax_line_item );
466
+		self::set_TXN_ID($tax_line_item, $transaction);
467
+		$total_line_item->add_child_line_item($tax_line_item);
468 468
 		//and lastly, add the actual taxes
469
-		self::apply_taxes( $total_line_item );
469
+		self::apply_taxes($total_line_item);
470 470
 		return $tax_line_item;
471 471
 	}
472 472
 
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
 	 * @return EE_Line_Item
482 482
 	 * @throws \EE_Error
483 483
 	 */
484
-	public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){
484
+	public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) {
485 485
 		$event_line_item = EE_Line_Item::new_instance(array(
486
-			'LIN_code'	=> self::get_event_code( $event ),
487
-			'LIN_name' 	=> self::get_event_name( $event ),
488
-			'LIN_desc' 	=> self::get_event_desc( $event ),
486
+			'LIN_code'	=> self::get_event_code($event),
487
+			'LIN_name' 	=> self::get_event_name($event),
488
+			'LIN_desc' 	=> self::get_event_desc($event),
489 489
 			'LIN_type'	=> EEM_Line_Item::type_sub_total,
490 490
 			'OBJ_type' 	=> 'Event',
491 491
 			'OBJ_ID' 		=>  $event instanceof EE_Event ? $event->ID() : 0
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 			'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item',
495 495
 			$event_line_item
496 496
 		);
497
-		self::set_TXN_ID( $event_line_item, $transaction );
498
-		$pre_tax_line_item->add_child_line_item( $event_line_item );
497
+		self::set_TXN_ID($event_line_item, $transaction);
498
+		$pre_tax_line_item->add_child_line_item($event_line_item);
499 499
 		return $event_line_item;
500 500
 	}
501 501
 
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 	 * @return string
509 509
 	 * @throws \EE_Error
510 510
 	 */
511
-	public static function get_event_code( $event ) {
512
-		return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' );
511
+	public static function get_event_code($event) {
512
+		return 'event-'.($event instanceof EE_Event ? $event->ID() : '0');
513 513
 	}
514 514
 
515 515
 	/**
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @param EE_Event $event
518 518
 	 * @return string
519 519
 	 */
520
-	public static function get_event_name( $event ) {
521
-		return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' );
520
+	public static function get_event_name($event) {
521
+		return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso');
522 522
 	}
523 523
 
524 524
 	/**
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	 * @param EE_Event $event
527 527
 	 * @return string
528 528
 	 */
529
-	public static function get_event_desc( $event ) {
529
+	public static function get_event_desc($event) {
530 530
 		return $event instanceof EE_Event ? $event->short_description() : '';
531 531
 	}
532 532
 
@@ -540,27 +540,27 @@  discard block
 block discarded – undo
540 540
 	  * @throws \EE_Error
541 541
 	  * @return EE_Line_Item
542 542
 	  */
543
-	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
543
+	public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) {
544 544
 		$first_datetime = $ticket->first_datetime();
545
-		if ( ! $first_datetime instanceof EE_Datetime ) {
545
+		if ( ! $first_datetime instanceof EE_Datetime) {
546 546
 			throw new EE_Error(
547
-				sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() )
547
+				sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())
548 548
 			);
549 549
 		}
550 550
 		$event = $first_datetime->event();
551
-		if ( ! $event instanceof EE_Event ) {
551
+		if ( ! $event instanceof EE_Event) {
552 552
 			throw new EE_Error(
553 553
 				sprintf(
554
-					__( 'The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso' ),
554
+					__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'),
555 555
 					$ticket->ID()
556 556
 				)
557 557
 			);
558 558
 		}
559
-		$events_sub_total = EEH_Line_Item::get_event_line_item( $grand_total, $event );
560
-		if ( ! $events_sub_total instanceof EE_Line_Item ) {
559
+		$events_sub_total = EEH_Line_Item::get_event_line_item($grand_total, $event);
560
+		if ( ! $events_sub_total instanceof EE_Line_Item) {
561 561
 			throw new EE_Error(
562 562
 				sprintf(
563
-					__( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ),
563
+					__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'),
564 564
 					$ticket->ID(),
565 565
 					$grand_total->ID()
566 566
 				)
@@ -579,31 +579,31 @@  discard block
 block discarded – undo
579 579
 	 * @return EE_Line_Item for the event subtotal which is a child of $grand_total
580 580
 	 * @throws \EE_Error
581 581
 	 */
582
-	public static function get_event_line_item( EE_Line_Item $grand_total, $event ) {
582
+	public static function get_event_line_item(EE_Line_Item $grand_total, $event) {
583 583
 		/** @type EE_Event $event */
584
-		$event = EEM_Event::instance()->ensure_is_obj( $event, true );
584
+		$event = EEM_Event::instance()->ensure_is_obj($event, true);
585 585
 		$event_line_item = NULL;
586 586
 		$found = false;
587
-		foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) {
587
+		foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) {
588 588
 			// default event subtotal, we should only ever find this the first time this method is called
589
-			if ( ! $event_line_item->OBJ_ID() ) {
589
+			if ( ! $event_line_item->OBJ_ID()) {
590 590
 				// let's use this! but first... set the event details
591
-				EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
591
+				EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
592 592
 				$found = true;
593 593
 				break;
594
-			} else if ( $event_line_item->OBJ_ID() === $event->ID() ) {
594
+			} else if ($event_line_item->OBJ_ID() === $event->ID()) {
595 595
 				// found existing line item for this event in the cart, so break out of loop and use this one
596 596
 				$found = true;
597 597
 				break;
598 598
 			}
599 599
 		}
600
-		if ( ! $found ) {
600
+		if ( ! $found) {
601 601
 			//there is no event sub-total yet, so add it
602
-			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total );
602
+			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total);
603 603
 			// create a new "event" subtotal below that
604
-			$event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event );
604
+			$event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event);
605 605
 			// and set the event details
606
-			EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
606
+			EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
607 607
 		}
608 608
 		return $event_line_item;
609 609
 	}
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 		EE_Event $event,
625 625
 		$transaction = null
626 626
 	) {
627
-		if ( $event instanceof EE_Event ) {
628
-			$event_line_item->set_code( self::get_event_code( $event ) );
629
-			$event_line_item->set_name( self::get_event_name( $event ) );
630
-			$event_line_item->set_desc( self::get_event_desc( $event ) );
631
-			$event_line_item->set_OBJ_ID( $event->ID() );
627
+		if ($event instanceof EE_Event) {
628
+			$event_line_item->set_code(self::get_event_code($event));
629
+			$event_line_item->set_name(self::get_event_name($event));
630
+			$event_line_item->set_desc(self::get_event_desc($event));
631
+			$event_line_item->set_OBJ_ID($event->ID());
632 632
 		}
633
-		self::set_TXN_ID( $event_line_item, $transaction );
633
+		self::set_TXN_ID($event_line_item, $transaction);
634 634
 	}
635 635
 
636 636
 
@@ -643,19 +643,19 @@  discard block
 block discarded – undo
643 643
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
644 644
 	 * @throws \EE_Error
645 645
 	 */
646
-	public static function apply_taxes( EE_Line_Item $total_line_item ){
646
+	public static function apply_taxes(EE_Line_Item $total_line_item) {
647 647
 		/** @type EEM_Price $EEM_Price */
648
-		$EEM_Price = EE_Registry::instance()->load_model( 'Price' );
648
+		$EEM_Price = EE_Registry::instance()->load_model('Price');
649 649
 		// get array of taxes via Price Model
650 650
 		$ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes();
651
-		ksort( $ordered_taxes );
652
-		$taxes_line_item = self::get_taxes_subtotal( $total_line_item );
651
+		ksort($ordered_taxes);
652
+		$taxes_line_item = self::get_taxes_subtotal($total_line_item);
653 653
 		//just to be safe, remove its old tax line items
654 654
 		$taxes_line_item->delete_children_line_items();
655 655
 		//loop thru taxes
656
-		foreach ( $ordered_taxes as $order => $taxes ) {
657
-			foreach ( $taxes as $tax ) {
658
-				if ( $tax instanceof EE_Price ) {
656
+		foreach ($ordered_taxes as $order => $taxes) {
657
+			foreach ($taxes as $tax) {
658
+				if ($tax instanceof EE_Price) {
659 659
 					$tax_line_item = EE_Line_Item::new_instance(
660 660
 						array(
661 661
 							'LIN_name'       => $tax->name(),
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 						'FHEE__EEH_Line_Item__apply_taxes__tax_line_item',
674 674
 						$tax_line_item
675 675
 					);
676
-					$taxes_line_item->add_child_line_item( $tax_line_item );
676
+					$taxes_line_item->add_child_line_item($tax_line_item);
677 677
 				}
678 678
 			}
679 679
 		}
@@ -690,10 +690,10 @@  discard block
 block discarded – undo
690 690
 	 * @return float
691 691
 	 * @throws \EE_Error
692 692
 	 */
693
-	public static function ensure_taxes_applied( $total_line_item ){
694
-		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
695
-		if( ! $taxes_subtotal->children()){
696
-			self::apply_taxes( $total_line_item );
693
+	public static function ensure_taxes_applied($total_line_item) {
694
+		$taxes_subtotal = self::get_taxes_subtotal($total_line_item);
695
+		if ( ! $taxes_subtotal->children()) {
696
+			self::apply_taxes($total_line_item);
697 697
 		}
698 698
 		return $taxes_subtotal->total();
699 699
 	}
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 	 * @return bool
708 708
 	 * @throws \EE_Error
709 709
 	 */
710
-	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
710
+	public static function delete_all_child_items(EE_Line_Item $parent_line_item) {
711 711
 		$deleted = 0;
712
-		foreach ( $parent_line_item->children() as $child_line_item ) {
713
-			if ( $child_line_item instanceof EE_Line_Item ) {
714
-				$deleted += EEH_Line_Item::delete_all_child_items( $child_line_item );
715
-				if ( $child_line_item->ID() ) {
712
+		foreach ($parent_line_item->children() as $child_line_item) {
713
+			if ($child_line_item instanceof EE_Line_Item) {
714
+				$deleted += EEH_Line_Item::delete_all_child_items($child_line_item);
715
+				if ($child_line_item->ID()) {
716 716
 					$child_line_item->delete();
717
-					unset( $child_line_item );
717
+					unset($child_line_item);
718 718
 				} else {
719
-					$parent_line_item->delete_child_line_item( $child_line_item->code() );
719
+					$parent_line_item->delete_child_line_item($child_line_item->code());
720 720
 				}
721 721
 				$deleted++;
722 722
 			}
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 	 * @param array|bool|string $line_item_codes
739 739
 	 * @return int number of items successfully removed
740 740
 	 */
741
-	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
741
+	public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) {
742 742
 
743
-		if( $total_line_item->type() !== EEM_Line_Item::type_total ){
743
+		if ($total_line_item->type() !== EEM_Line_Item::type_total) {
744 744
 			EE_Error::doing_it_wrong(
745 745
 				'EEH_Line_Item::delete_items',
746 746
 				__(
@@ -750,20 +750,20 @@  discard block
 block discarded – undo
750 750
 				'4.6.18'
751 751
 			);
752 752
 		}
753
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
753
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
754 754
 
755 755
 		// check if only a single line_item_id was passed
756
-		if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) {
756
+		if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) {
757 757
 			// place single line_item_id in an array to appear as multiple line_item_ids
758
-			$line_item_codes = array ( $line_item_codes );
758
+			$line_item_codes = array($line_item_codes);
759 759
 		}
760 760
 		$removals = 0;
761 761
 		// cycle thru line_item_ids
762
-		foreach ( $line_item_codes as $line_item_id ) {
762
+		foreach ($line_item_codes as $line_item_id) {
763 763
 			$removals += $total_line_item->delete_child_line_item($line_item_id);
764 764
 		}
765 765
 
766
-		if ( $removals > 0 ) {
766
+		if ($removals > 0) {
767 767
 			$total_line_item->recalculate_taxes_and_tax_total();
768 768
 			return $removals;
769 769
 		} else {
@@ -796,33 +796,33 @@  discard block
 block discarded – undo
796 796
 		$code = null,
797 797
 		$add_to_existing_line_item = false
798 798
 	) {
799
-		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
799
+		$tax_subtotal = self::get_taxes_subtotal($total_line_item);
800 800
             $taxable_total = $total_line_item->taxable_total();
801 801
 
802
-            if( $add_to_existing_line_item ) {
803
-                $new_tax = $tax_subtotal->get_child_line_item( $code );
802
+            if ($add_to_existing_line_item) {
803
+                $new_tax = $tax_subtotal->get_child_line_item($code);
804 804
 	            EEM_Line_Item::instance()->delete(
805
-		            array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) )
805
+		            array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID()))
806 806
 	            );
807 807
             } else {
808 808
                 $new_tax = null;
809 809
                 $tax_subtotal->delete_children_line_items();
810 810
             }
811
-            if( $new_tax ) {
812
-                $new_tax->set_total( $new_tax->total() + $amount );
813
-                $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 );
811
+            if ($new_tax) {
812
+                $new_tax->set_total($new_tax->total() + $amount);
813
+                $new_tax->set_percent($taxable_total ? $new_tax->total() / $taxable_total * 100 : 0);
814 814
             } else {
815 815
                 //no existing tax item. Create it
816
-				$new_tax = EE_Line_Item::new_instance( array(
816
+				$new_tax = EE_Line_Item::new_instance(array(
817 817
 					'TXN_ID'      => $total_line_item->TXN_ID(),
818
-					'LIN_name'    => $name ? $name : __( 'Tax', 'event_espresso' ),
818
+					'LIN_name'    => $name ? $name : __('Tax', 'event_espresso'),
819 819
 					'LIN_desc'    => $description ? $description : '',
820
-					'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0,
820
+					'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0,
821 821
 					'LIN_total'   => $amount,
822 822
 					'LIN_parent'  => $tax_subtotal->ID(),
823 823
 					'LIN_type'    => EEM_Line_Item::type_tax,
824 824
 					'LIN_code'    => $code
825
-				) );
825
+				));
826 826
 			}
827 827
 
828 828
             $new_tax = apply_filters(
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 				$total_line_item
832 832
             );
833 833
             $new_tax->save();
834
-            $tax_subtotal->set_total( $new_tax->total() );
834
+            $tax_subtotal->set_total($new_tax->total());
835 835
             $tax_subtotal->save();
836 836
             $total_line_item->recalculate_total_including_taxes();
837 837
             return $new_tax;
@@ -853,14 +853,14 @@  discard block
 block discarded – undo
853 853
 		$code_substring_for_whitelist = null
854 854
 	) {
855 855
 		$whitelisted = false;
856
-		if( $code_substring_for_whitelist !== null ) {
857
-			$whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false;
856
+		if ($code_substring_for_whitelist !== null) {
857
+			$whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false;
858 858
 		}
859
-		if( ! $whitelisted && $line_item->is_line_item() ) {
860
-			$line_item->set_is_taxable( $taxable );
859
+		if ( ! $whitelisted && $line_item->is_line_item()) {
860
+			$line_item->set_is_taxable($taxable);
861 861
 		}
862
-		foreach( $line_item->children() as $child_line_item ) {
863
-			EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist );
862
+		foreach ($line_item->children() as $child_line_item) {
863
+			EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist);
864 864
 		}
865 865
 	}
866 866
 
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
874 874
 	 * @return EE_Line_Item[]
875 875
 	 */
876
-	public static function get_event_subtotals( EE_Line_Item $parent_line_item ) {
877
-		return self::get_subtotals_of_object_type( $parent_line_item, 'Event' );
876
+	public static function get_event_subtotals(EE_Line_Item $parent_line_item) {
877
+		return self::get_subtotals_of_object_type($parent_line_item, 'Event');
878 878
 	}
879 879
 
880 880
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @param string $obj_type
888 888
 	 * @return EE_Line_Item[]
889 889
 	 */
890
-	public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
890
+	public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
891 891
 		return self::_get_descendants_by_type_and_object_type(
892 892
 			$parent_line_item,
893 893
 			EEM_Line_Item::type_sub_total,
@@ -904,8 +904,8 @@  discard block
 block discarded – undo
904 904
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
905 905
 	 * @return EE_Line_Item[]
906 906
 	 */
907
-	public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) {
908
-		return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' );
907
+	public static function get_ticket_line_items(EE_Line_Item $parent_line_item) {
908
+		return self::get_line_items_of_object_type($parent_line_item, 'Ticket');
909 909
 	}
910 910
 
911 911
 
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	 * @param string $obj_type
919 919
 	 * @return EE_Line_Item[]
920 920
 	 */
921
-	public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
922
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type );
921
+	public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
922
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type);
923 923
 	}
924 924
 
925 925
 
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
931 931
 	 * @return EE_Line_Item[]
932 932
 	 */
933
-	public static function get_tax_descendants( EE_Line_Item $parent_line_item ) {
934
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax );
933
+	public static function get_tax_descendants(EE_Line_Item $parent_line_item) {
934
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax);
935 935
 	}
936 936
 
937 937
 
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
943 943
 	 * @return EE_Line_Item[]
944 944
 	 */
945
-	public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) {
946
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item );
945
+	public static function get_line_item_descendants(EE_Line_Item $parent_line_item) {
946
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item);
947 947
 	}
948 948
 
949 949
 
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 	 * @param string $line_item_type one of the EEM_Line_Item constants
957 957
 	 * @return EE_Line_Item[]
958 958
 	 */
959
-	public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) {
960
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL );
959
+	public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) {
960
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL);
961 961
 	}
962 962
 
963 963
 
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 		$obj_type = null
977 977
 	) {
978 978
 		$objects = array();
979
-		foreach ( $parent_line_item->children() as $child_line_item ) {
980
-			if ( $child_line_item instanceof EE_Line_Item ) {
979
+		foreach ($parent_line_item->children() as $child_line_item) {
980
+			if ($child_line_item instanceof EE_Line_Item) {
981 981
 				if (
982 982
 					$child_line_item->type() === $line_item_type
983 983
 				    && (
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 		$OBJ_type = '',
1018 1018
 		$OBJ_IDs = array()
1019 1019
 	) {
1020
-		return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs );
1020
+		return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs);
1021 1021
 	}
1022 1022
 
1023 1023
 
@@ -1036,12 +1036,12 @@  discard block
 block discarded – undo
1036 1036
 		$OBJ_IDs
1037 1037
 	) {
1038 1038
 		$objects = array();
1039
-		foreach ( $parent_line_item->children() as $child_line_item ) {
1040
-			if ( $child_line_item instanceof EE_Line_Item ) {
1039
+		foreach ($parent_line_item->children() as $child_line_item) {
1040
+			if ($child_line_item instanceof EE_Line_Item) {
1041 1041
 				if (
1042
-					is_array( $OBJ_IDs )
1042
+					is_array($OBJ_IDs)
1043 1043
 					&& $child_line_item->OBJ_type() === $OBJ_type
1044
-					&& in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )
1044
+					&& in_array($child_line_item->OBJ_ID(), $OBJ_IDs)
1045 1045
 				) {
1046 1046
 					$objects[] = $child_line_item;
1047 1047
 				} else {
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 	 * @param string $type like one of the EEM_Line_Item::type_*
1072 1072
 	 * @return EE_Line_Item
1073 1073
 	 */
1074
-	public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) {
1075
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type );
1074
+	public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) {
1075
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type);
1076 1076
 	}
1077 1077
 
1078 1078
 
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
 	 * @param string $code any value used for LIN_code
1087 1087
 	 * @return EE_Line_Item
1088 1088
 	 */
1089
-	public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) {
1090
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code );
1089
+	public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) {
1090
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code);
1091 1091
 	}
1092 1092
 
1093 1093
 
@@ -1101,15 +1101,15 @@  discard block
 block discarded – undo
1101 1101
 	 * @param string $value any value stored in $search_field
1102 1102
 	 * @return EE_Line_Item
1103 1103
 	 */
1104
-	protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) {
1105
-		foreach( $parent_line_item->children() as $child ){
1106
-			if ( $child->get( $search_field ) == $value ){
1104
+	protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) {
1105
+		foreach ($parent_line_item->children() as $child) {
1106
+			if ($child->get($search_field) == $value) {
1107 1107
 				return $child;
1108 1108
 			}
1109 1109
 		}
1110
-		foreach( $parent_line_item->children() as $child ){
1111
-			$descendant_found = self::_get_nearest_descendant( $child, $search_field, $value );
1112
-			if ( $descendant_found ){
1110
+		foreach ($parent_line_item->children() as $child) {
1111
+			$descendant_found = self::_get_nearest_descendant($child, $search_field, $value);
1112
+			if ($descendant_found) {
1113 1113
 				return $descendant_found;
1114 1114
 			}
1115 1115
 		}
@@ -1126,22 +1126,22 @@  discard block
 block discarded – undo
1126 1126
 	 * @return void
1127 1127
 	 * @throws \EE_Error
1128 1128
 	 */
1129
-	public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){
1129
+	public static function visualize(EE_Line_Item $line_item, $indentation = 0) {
1130 1130
 		echo "\n<br />";
1131
-		for( $i = 0; $i < $indentation; $i++ ){
1131
+		for ($i = 0; $i < $indentation; $i++) {
1132 1132
 			echo " - ";
1133 1133
 		}
1134
-		if( $line_item->is_percent() ) {
1135
-			$breakdown = $line_item->percent() . '%';
1134
+		if ($line_item->is_percent()) {
1135
+			$breakdown = $line_item->percent().'%';
1136 1136
 		} else {
1137
-			$breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity();
1137
+			$breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity();
1138 1138
 		}
1139
-		echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")";
1140
-		if( $line_item->is_taxable() ){
1139
+		echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")";
1140
+		if ($line_item->is_taxable()) {
1141 1141
 			echo "  * taxable";
1142 1142
 		}
1143
-		if( $line_item->children() ){
1144
-			foreach($line_item->children() as $child){
1143
+		if ($line_item->children()) {
1144
+			foreach ($line_item->children() as $child) {
1145 1145
 				self::visualize($child, $indentation + 1);
1146 1146
 			}
1147 1147
 		}
@@ -1182,97 +1182,97 @@  discard block
 block discarded – undo
1182 1182
 	 *                                          is theirs, which can be done with
1183 1183
 	 *                                          `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );`
1184 1184
 	 */
1185
-	public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) {
1185
+	public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) {
1186 1186
 		//init running grand total if not already
1187
-		if ( ! isset( $running_totals[ 'total' ] ) ) {
1188
-			$running_totals[ 'total' ] = 0;
1187
+		if ( ! isset($running_totals['total'])) {
1188
+			$running_totals['total'] = 0;
1189 1189
 		}
1190
-		if( ! isset( $running_totals[ 'taxable' ] ) ) {
1191
-			$running_totals[ 'taxable' ] = array( 'total' => 0 );
1190
+		if ( ! isset($running_totals['taxable'])) {
1191
+			$running_totals['taxable'] = array('total' => 0);
1192 1192
 		}
1193
-		foreach ( $line_item->children() as $child_line_item ) {
1194
-			switch ( $child_line_item->type() ) {
1193
+		foreach ($line_item->children() as $child_line_item) {
1194
+			switch ($child_line_item->type()) {
1195 1195
 
1196 1196
 				case EEM_Line_Item::type_sub_total :
1197
-					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities );
1197
+					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities);
1198 1198
 					//combine arrays but preserve numeric keys
1199
-					$running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals );
1200
-					$running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ];
1201
-					$running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ];
1199
+					$running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals);
1200
+					$running_totals['total'] += $running_totals_from_subtotal['total'];
1201
+					$running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total'];
1202 1202
 					break;
1203 1203
 
1204 1204
 				case EEM_Line_Item::type_tax_sub_total :
1205 1205
 
1206 1206
 					//find how much the taxes percentage is
1207
-					if ( $child_line_item->percent() !== 0 ) {
1207
+					if ($child_line_item->percent() !== 0) {
1208 1208
 						$tax_percent_decimal = $child_line_item->percent() / 100;
1209 1209
 					} else {
1210 1210
 						$tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100;
1211 1211
 					}
1212 1212
 					//and apply to all the taxable totals, and add to the pretax totals
1213
-					foreach ( $running_totals as $line_item_id => $this_running_total ) {
1213
+					foreach ($running_totals as $line_item_id => $this_running_total) {
1214 1214
 						//"total" and "taxable" array key is an exception
1215
-						if ( $line_item_id === 'taxable' ) {
1215
+						if ($line_item_id === 'taxable') {
1216 1216
 							continue;
1217 1217
 						}
1218
-						$taxable_total = $running_totals[ 'taxable' ][ $line_item_id ];
1219
-						$running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal );
1218
+						$taxable_total = $running_totals['taxable'][$line_item_id];
1219
+						$running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal);
1220 1220
 					}
1221 1221
 					break;
1222 1222
 
1223 1223
 				case EEM_Line_Item::type_line_item :
1224 1224
 
1225 1225
 					// ticket line items or ????
1226
-					if ( $child_line_item->OBJ_type() === 'Ticket' ) {
1226
+					if ($child_line_item->OBJ_type() === 'Ticket') {
1227 1227
 						// kk it's a ticket
1228
-						if ( isset( $running_totals[ $child_line_item->ID() ] ) ) {
1228
+						if (isset($running_totals[$child_line_item->ID()])) {
1229 1229
 							//huh? that shouldn't happen.
1230
-							$running_totals[ 'total' ] += $child_line_item->total();
1230
+							$running_totals['total'] += $child_line_item->total();
1231 1231
 						} else {
1232 1232
 							//its not in our running totals yet. great.
1233
-							if ( $child_line_item->is_taxable() ) {
1233
+							if ($child_line_item->is_taxable()) {
1234 1234
 								$taxable_amount = $child_line_item->unit_price();
1235 1235
 							} else {
1236 1236
 								$taxable_amount = 0;
1237 1237
 							}
1238 1238
 							// are we only calculating totals for some tickets?
1239
-							if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) {
1240
-								$quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ];
1241
-								$running_totals[ $child_line_item->ID() ] = $quantity
1239
+							if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) {
1240
+								$quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()];
1241
+								$running_totals[$child_line_item->ID()] = $quantity
1242 1242
 									? $child_line_item->unit_price()
1243 1243
 									: 0;
1244
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity
1244
+								$running_totals['taxable'][$child_line_item->ID()] = $quantity
1245 1245
 									? $taxable_amount
1246 1246
 									: 0;
1247 1247
 							} else {
1248 1248
 								$quantity = $child_line_item->quantity();
1249
-								$running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price();
1250
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount;
1249
+								$running_totals[$child_line_item->ID()] = $child_line_item->unit_price();
1250
+								$running_totals['taxable'][$child_line_item->ID()] = $taxable_amount;
1251 1251
 							}
1252
-							$running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity;
1253
-							$running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity;
1252
+							$running_totals['taxable']['total'] += $taxable_amount * $quantity;
1253
+							$running_totals['total'] += $child_line_item->unit_price() * $quantity;
1254 1254
 						}
1255 1255
 					} else {
1256 1256
 						// it's some other type of item added to the cart
1257 1257
 						// it should affect the running totals
1258 1258
 						// basically we want to convert it into a PERCENT modifier. Because
1259 1259
 						// more clearly affect all registration's final price equally
1260
-						$line_items_percent_of_running_total = $running_totals[ 'total' ] > 0
1261
-							? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1
1260
+						$line_items_percent_of_running_total = $running_totals['total'] > 0
1261
+							? ($child_line_item->total() / $running_totals['total']) + 1
1262 1262
 							: 1;
1263
-						foreach ( $running_totals as $line_item_id => $this_running_total ) {
1263
+						foreach ($running_totals as $line_item_id => $this_running_total) {
1264 1264
 							//the "taxable" array key is an exception
1265
-							if ( $line_item_id === 'taxable' ) {
1265
+							if ($line_item_id === 'taxable') {
1266 1266
 								continue;
1267 1267
 							}
1268 1268
 							// update the running totals
1269 1269
 							// yes this actually even works for the running grand total!
1270
-							$running_totals[ $line_item_id ] =
1270
+							$running_totals[$line_item_id] =
1271 1271
 								$line_items_percent_of_running_total * $this_running_total;
1272 1272
 
1273
-							if ( $child_line_item->is_taxable() ) {
1274
-								$running_totals[ 'taxable' ][ $line_item_id ] =
1275
-									$line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ];
1273
+							if ($child_line_item->is_taxable()) {
1274
+								$running_totals['taxable'][$line_item_id] =
1275
+									$line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id];
1276 1276
 							}
1277 1277
 						}
1278 1278
 					}
@@ -1290,16 +1290,16 @@  discard block
 block discarded – undo
1290 1290
 	 * @return float | null
1291 1291
 	 * @throws \OutOfRangeException
1292 1292
 	 */
1293
-	public static function calculate_final_price_for_ticket_line_item( \EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item ) {
1293
+	public static function calculate_final_price_for_ticket_line_item(\EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item) {
1294 1294
 		static $final_prices_per_ticket_line_item = array();
1295
-		if ( empty( $final_prices_per_ticket_line_item ) ) {
1295
+		if (empty($final_prices_per_ticket_line_item)) {
1296 1296
 			$final_prices_per_ticket_line_item = \EEH_Line_Item::calculate_reg_final_prices_per_line_item(
1297 1297
 				$total_line_item
1298 1298
 			);
1299 1299
 		}
1300 1300
 		//ok now find this new registration's final price
1301
-		if ( isset( $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ] ) ) {
1302
-			return $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ];
1301
+		if (isset($final_prices_per_ticket_line_item[$ticket_line_item->ID()])) {
1302
+			return $final_prices_per_ticket_line_item[$ticket_line_item->ID()];
1303 1303
 		}
1304 1304
 		$message = sprintf(
1305 1305
 			__(
@@ -1308,10 +1308,10 @@  discard block
 block discarded – undo
1308 1308
 			),
1309 1309
 			$ticket_line_item->ID()
1310 1310
 		);
1311
-		if ( WP_DEBUG ) {
1312
-			throw new \OutOfRangeException( $message );
1311
+		if (WP_DEBUG) {
1312
+			throw new \OutOfRangeException($message);
1313 1313
 		} else {
1314
-			EE_Log::instance()->log( __CLASS__, __FUNCTION__, $message );
1314
+			EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message);
1315 1315
 		}
1316 1316
 		return null;
1317 1317
 	}
@@ -1327,15 +1327,15 @@  discard block
 block discarded – undo
1327 1327
 	 * @return \EE_Line_Item
1328 1328
 	 * @throws \EE_Error
1329 1329
 	 */
1330
-	public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) {
1331
-		$copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations );
1332
-		foreach ( $line_item->children() as $child_li ) {
1333
-			$copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) );
1330
+	public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) {
1331
+		$copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations);
1332
+		foreach ($line_item->children() as $child_li) {
1333
+			$copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations));
1334 1334
 		}
1335 1335
 		//if this is the grand total line item, make sure the totals all add up
1336 1336
 		//(we could have duplicated this logic AS we copied the line items, but
1337 1337
 		//it seems DRYer this way)
1338
-		if ( $copy_li->type() === EEM_Line_Item::type_total ) {
1338
+		if ($copy_li->type() === EEM_Line_Item::type_total) {
1339 1339
 			$copy_li->recalculate_total_including_taxes();
1340 1340
 		}
1341 1341
 		return $copy_li;
@@ -1352,24 +1352,24 @@  discard block
 block discarded – undo
1352 1352
 	 * @throws \EE_Error
1353 1353
 	 * @param EE_Registration[] $registrations
1354 1354
 	 */
1355
-	public static function billable_line_item( EE_Line_Item $line_item, $registrations ) {
1355
+	public static function billable_line_item(EE_Line_Item $line_item, $registrations) {
1356 1356
 		$new_li_fields = $line_item->model_field_array();
1357
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1357
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1358 1358
 			$line_item->OBJ_type() === 'Ticket'
1359 1359
 		) {
1360 1360
 			$count = 0;
1361
-			foreach ( $registrations as $registration ) {
1362
-				if ( $line_item->OBJ_ID() === $registration->ticket_ID() &&
1363
-					in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() )
1361
+			foreach ($registrations as $registration) {
1362
+				if ($line_item->OBJ_ID() === $registration->ticket_ID() &&
1363
+					in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment())
1364 1364
 				) {
1365 1365
 					$count++;
1366 1366
 				}
1367 1367
 			}
1368
-			$new_li_fields[ 'LIN_quantity' ] = $count;
1368
+			$new_li_fields['LIN_quantity'] = $count;
1369 1369
 		}
1370 1370
 		//don't set the total. We'll leave that up to the code that calculates it
1371
-		unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ], $new_li_fields[ 'LIN_total' ] );
1372
-		return EE_Line_Item::new_instance( $new_li_fields );
1371
+		unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent'], $new_li_fields['LIN_total']);
1372
+		return EE_Line_Item::new_instance($new_li_fields);
1373 1373
 	}
1374 1374
 
1375 1375
 
@@ -1382,19 +1382,19 @@  discard block
 block discarded – undo
1382 1382
 	 * @return \EE_Line_Item|null
1383 1383
 	 * @throws \EE_Error
1384 1384
 	 */
1385
-	public static function non_empty_line_items( EE_Line_Item $line_item ) {
1386
-		$copied_li = EEH_Line_Item::non_empty_line_item( $line_item );
1387
-		if ( $copied_li === null ) {
1385
+	public static function non_empty_line_items(EE_Line_Item $line_item) {
1386
+		$copied_li = EEH_Line_Item::non_empty_line_item($line_item);
1387
+		if ($copied_li === null) {
1388 1388
 			return null;
1389 1389
 		}
1390 1390
 		//if this is an event subtotal, we want to only include it if it
1391 1391
 		//has a non-zero total and at least one ticket line item child
1392 1392
 		$ticket_children = 0;
1393
-		foreach ( $line_item->children() as $child_li ) {
1394
-			$child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li );
1395
-			if ( $child_li_copy !== null ) {
1396
-				$copied_li->add_child_line_item( $child_li_copy );
1397
-				if ( $child_li_copy->type() === EEM_Line_Item::type_line_item &&
1393
+		foreach ($line_item->children() as $child_li) {
1394
+			$child_li_copy = EEH_Line_Item::non_empty_line_items($child_li);
1395
+			if ($child_li_copy !== null) {
1396
+				$copied_li->add_child_line_item($child_li_copy);
1397
+				if ($child_li_copy->type() === EEM_Line_Item::type_line_item &&
1398 1398
 					$child_li_copy->OBJ_type() === 'Ticket'
1399 1399
 				) {
1400 1400
 					$ticket_children++;
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
 	 * @return EE_Line_Item
1425 1425
 	 * @throws \EE_Error
1426 1426
 	 */
1427
-	public static function non_empty_line_item( EE_Line_Item $line_item ) {
1428
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1427
+	public static function non_empty_line_item(EE_Line_Item $line_item) {
1428
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1429 1429
 			$line_item->OBJ_type() === 'Ticket' &&
1430 1430
 			$line_item->quantity() === 0
1431 1431
 		) {
@@ -1433,8 +1433,8 @@  discard block
 block discarded – undo
1433 1433
 		}
1434 1434
 		$new_li_fields = $line_item->model_field_array();
1435 1435
 		//don't set the total. We'll leave that up to the code that calculates it
1436
-		unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ] );
1437
-		return EE_Line_Item::new_instance( $new_li_fields );
1436
+		unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent']);
1437
+		return EE_Line_Item::new_instance($new_li_fields);
1438 1438
 	}
1439 1439
 
1440 1440
 
@@ -1446,9 +1446,9 @@  discard block
 block discarded – undo
1446 1446
 	 * @return \EE_Line_Item
1447 1447
 	 * @throws \EE_Error
1448 1448
 	 */
1449
-	public static function get_items_subtotal( EE_Line_Item $total_line_item ){
1450
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' );
1451
-		return self::get_pre_tax_subtotal( $total_line_item );
1449
+	public static function get_items_subtotal(EE_Line_Item $total_line_item) {
1450
+		EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0');
1451
+		return self::get_pre_tax_subtotal($total_line_item);
1452 1452
 	}
1453 1453
 
1454 1454
 
@@ -1459,9 +1459,9 @@  discard block
 block discarded – undo
1459 1459
 	 * @return \EE_Line_Item
1460 1460
 	 * @throws \EE_Error
1461 1461
 	 */
1462
-	public static function create_default_total_line_item( $transaction = NULL) {
1463
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' );
1464
-		return self::create_total_line_item( $transaction );
1462
+	public static function create_default_total_line_item($transaction = NULL) {
1463
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0');
1464
+		return self::create_total_line_item($transaction);
1465 1465
 	}
1466 1466
 
1467 1467
 
@@ -1473,9 +1473,9 @@  discard block
 block discarded – undo
1473 1473
 	 * @return \EE_Line_Item
1474 1474
 	 * @throws \EE_Error
1475 1475
 	 */
1476
-	public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1477
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' );
1478
-		return self::create_pre_tax_subtotal( $total_line_item, $transaction );
1476
+	public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1477
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0');
1478
+		return self::create_pre_tax_subtotal($total_line_item, $transaction);
1479 1479
 	}
1480 1480
 
1481 1481
 
@@ -1487,9 +1487,9 @@  discard block
 block discarded – undo
1487 1487
 	 * @return \EE_Line_Item
1488 1488
 	 * @throws \EE_Error
1489 1489
 	 */
1490
-	public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1491
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' );
1492
-		return self::create_taxes_subtotal( $total_line_item, $transaction );
1490
+	public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1491
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0');
1492
+		return self::create_taxes_subtotal($total_line_item, $transaction);
1493 1493
 	}
1494 1494
 
1495 1495
 
@@ -1501,9 +1501,9 @@  discard block
 block discarded – undo
1501 1501
 	 * @return \EE_Line_Item
1502 1502
 	 * @throws \EE_Error
1503 1503
 	 */
1504
-	public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1505
-		EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' );
1506
-		return self::create_event_subtotal( $total_line_item, $transaction );
1504
+	public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1505
+		EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0');
1506
+		return self::create_event_subtotal($total_line_item, $transaction);
1507 1507
 	}
1508 1508
 
1509 1509
 
Please login to merge, or discard this patch.
core/exceptions/UnexpectedEntityException.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use DomainException;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
 	 * @param int        $code
29 29
 	 * @param \Exception $previous
30 30
 	 */
31
-	public function __construct( $entity, $expected_class, $message = '', $code = 0, \Exception $previous = null ) {
32
-		if ( empty( $message ) ) {
31
+	public function __construct($entity, $expected_class, $message = '', $code = 0, \Exception $previous = null) {
32
+		if (empty($message)) {
33 33
 			$message = sprintf(
34 34
 				__(
35 35
 					'The retrieved entity is an instance of "%1$s", but an instance of "%2$s" was expected.',
36 36
 					'event_espresso'
37 37
 				),
38
-				is_object( $entity ) ? get_class( $entity ) : gettype( $entity ),
38
+				is_object($entity) ? get_class($entity) : gettype($entity),
39 39
 				$expected_class
40 40
 			);
41 41
 		}
42
-		parent::__construct( $message, $code, $previous );
42
+		parent::__construct($message, $code, $previous);
43 43
 	}
44 44
 
45 45
 }
Please login to merge, or discard this patch.
core/exceptions/EntityConstructionException.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use DomainException;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	 * @param int $code
29 29
 	 * @param \Exception $previous
30 30
 	 */
31
-	public function __construct( $entity_class, $message = '', $code = 0, \Exception $previous = null ) {
32
-		if ( empty( $message ) ) {
31
+	public function __construct($entity_class, $message = '', $code = 0, \Exception $previous = null) {
32
+		if (empty($message)) {
33 33
 			$message = sprintf(
34 34
 				__(
35 35
 					'The "%1$s" entity could not be instantiated for an unknown reason',
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 				$entity_class
39 39
 			);
40 40
 		}
41
-		parent::__construct( $message, $code, $previous );
41
+		parent::__construct($message, $code, $previous);
42 42
 	}
43 43
 
44 44
 }
Please login to merge, or discard this patch.
core/exceptions/EntityNotFoundException.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use UnexpectedValueException;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 * @param int        $code
31 31
 	 * @param \Exception $previous
32 32
 	 */
33
-	public function __construct( $identifier_type, $identifier, $message = '', $code = 0, \Exception $previous = null ) {
34
-		if ( empty( $message ) ) {
33
+	public function __construct($identifier_type, $identifier, $message = '', $code = 0, \Exception $previous = null) {
34
+		if (empty($message)) {
35 35
 			$message = sprintf(
36 36
 				__(
37 37
 					'The requested entity with %1$s="%2$s" was not found.',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 				$identifier
42 42
 			);
43 43
 		}
44
-		parent::__construct( $message, $code, $previous );
44
+		parent::__construct($message, $code, $previous);
45 45
 	}
46 46
 
47 47
 
Please login to merge, or discard this patch.
core/services/collections/CollectionInterface.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -111,12 +111,12 @@
 block discarded – undo
111 111
 	public function previous();
112 112
 
113 113
 		/**
114
-	 * Returns the index of a given object, or false if not found
115
-	 *
116
-	 * @see http://stackoverflow.com/a/8736013
117
-	 * @param $object
118
-	 * @return boolean|int|string
119
-	 */
114
+		 * Returns the index of a given object, or false if not found
115
+		 *
116
+		 * @see http://stackoverflow.com/a/8736013
117
+		 * @param $object
118
+		 * @return boolean|int|string
119
+		 */
120 120
 	public function indexOf( $object );
121 121
 
122 122
 
Please login to merge, or discard this 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\services\collections;
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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param  mixed $identifier
26 26
 	 * @return bool
27 27
 	 */
28
-	public function add( $object, $identifier = null );
28
+	public function add($object, $identifier = null);
29 29
 
30 30
 	/**
31 31
 	 * setIdentifier
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param  mixed $identifier
38 38
 	 * @return bool
39 39
 	 */
40
-	public function setIdentifier( $object, $identifier = null );
40
+	public function setIdentifier($object, $identifier = null);
41 41
 
42 42
 	/**
43 43
 	 * get
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param mixed $identifier
49 49
 	 * @return mixed
50 50
 	 */
51
-	public function get( $identifier );
51
+	public function get($identifier);
52 52
 
53 53
 	/**
54 54
 	 * has
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param  mixed $identifier
61 61
 	 * @return bool
62 62
 	 */
63
-	public function has( $identifier );
63
+	public function has($identifier);
64 64
 
65 65
 	/**
66 66
 	 * hasObject
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @param $object
71 71
 	 * @return bool
72 72
 	 */
73
-	public function hasObject( $object );
73
+	public function hasObject($object);
74 74
 
75 75
 	/**
76 76
 	 * remove
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param $object
81 81
 	 * @return bool
82 82
 	 */
83
-	public function remove( $object );
83
+	public function remove($object);
84 84
 
85 85
 	/**
86 86
 	 * setCurrent
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param mixed $identifier
91 91
 	 * @return boolean
92 92
 	 */
93
-	public function setCurrent( $identifier ) ;
93
+	public function setCurrent($identifier);
94 94
 
95 95
 	/**
96 96
 	 * setCurrentUsingObject
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param $object
101 101
 	 * @return boolean
102 102
 	 */
103
-	public function setCurrentUsingObject( $object );
103
+	public function setCurrentUsingObject($object);
104 104
 
105 105
 	/**
106 106
 	 * Returns the object occupying the index before the current object,
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param $object
118 118
 	 * @return boolean|int|string
119 119
 	 */
120
-	public function indexOf( $object );
120
+	public function indexOf($object);
121 121
 
122 122
 
123 123
 	/**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param $index
128 128
 	 * @return mixed
129 129
 	 */
130
-	public function objectAtIndex( $index );
130
+	public function objectAtIndex($index);
131 131
 
132 132
 	/**
133 133
 	 * Returns the sequence of objects as specified by the offset and length
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @param int $length
138 138
 	 * @return array
139 139
 	 */
140
-	public function slice( $offset, $length );
140
+	public function slice($offset, $length);
141 141
 
142 142
 	/**
143 143
 	 * Inserts an object (or an array of objects) at a certain point
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param mixed   $objects A single object or an array of objects
147 147
 	 * @param integer $index
148 148
 	 */
149
-	public function insertAt( $objects, $index );
149
+	public function insertAt($objects, $index);
150 150
 
151 151
 	/**
152 152
 	 * Removes the object at the given index
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @see http://stackoverflow.com/a/8736013
155 155
 	 * @param integer $index
156 156
 	 */
157
-	public function removeAt( $index ) ;
157
+	public function removeAt($index);
158 158
 
159 159
 
160 160
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/Model_Data_Translator.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	
56 56
 	/**
57 57
 	 * Prepares an array of field values FOR use in JSON/REST API
58
-	 * @param type $field_obj
58
+	 * @param \EE_Model_Field_Base $field_obj
59 59
 	 * @param type $original_value_maybe_array
60 60
 	 * @param string $request_version (eg 4.8.36)
61 61
 	 * @return array
@@ -97,6 +97,7 @@  discard block
 block discarded – undo
97 97
 	* Prepares a field's value for display in the API
98 98
 	* @param \EE_Model_Field_Base $field_obj
99 99
 	* @param mixed $original_value
100
+	* @param string $requested_version
100 101
 	* @return mixed
101 102
 	*/
102 103
    public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 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\libraries\rest_api;
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
 
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 * @param string  $requested_version
42 42
 	 * @return mixed
43 43
 	 */
44
-	public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) {
45
-		if( is_array( $original_value_maybe_array ) ) {
44
+	public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) {
45
+		if (is_array($original_value_maybe_array)) {
46 46
 			$new_value_maybe_array = array();
47
-			foreach( $original_value_maybe_array as $array_key => $array_item ) {
48
-				$new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $array_item, $requested_version );
47
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
48
+				$new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json($field_obj, $array_item, $requested_version);
49 49
 			}
50 50
 		} else {
51
-			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version );
51
+			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version);
52 52
 		}
53 53
 		return $new_value_maybe_array;
54 54
 	}
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	 * @param string $request_version (eg 4.8.36)
61 61
 	 * @return array
62 62
 	 */
63
-	public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ){
64
-		if( is_array( $original_value_maybe_array ) ) {
63
+	public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) {
64
+		if (is_array($original_value_maybe_array)) {
65 65
 			$new_value_maybe_array = array();
66
-			foreach( $original_value_maybe_array as $array_key => $array_item ) {
67
-				$new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $array_item, $request_version );
66
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
67
+				$new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json($field_obj, $array_item, $request_version);
68 68
 			}
69 69
 		} else {
70
-			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $original_value_maybe_array, $request_version );
70
+			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json($field_obj, $original_value_maybe_array, $request_version);
71 71
 		}
72 72
 		return $new_value_maybe_array;
73 73
 	}
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 	 * @param string $requested_version
81 81
 	 * @return mixed
82 82
 	 */
83
-	public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) {
83
+	public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) {
84 84
 		$new_value = null;
85
-		if( $field_obj instanceof \EE_Infinite_Integer_Field
86
-			&& in_array( $original_value, array( null, '' ), true ) ) {
85
+		if ($field_obj instanceof \EE_Infinite_Integer_Field
86
+			&& in_array($original_value, array(null, ''), true)) {
87 87
 			$new_value = EE_INF;
88
-		} elseif( $field_obj instanceof \EE_Datetime_Field ) {
89
-			$new_value = rest_parse_date( $original_value );
88
+		} elseif ($field_obj instanceof \EE_Datetime_Field) {
89
+			$new_value = rest_parse_date($original_value);
90 90
 		} else {
91 91
 			$new_value = $original_value;
92 92
 		}
@@ -99,22 +99,22 @@  discard block
 block discarded – undo
99 99
 	* @param mixed $original_value
100 100
 	* @return mixed
101 101
 	*/
102
-   public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) {
103
-		if( $original_value === EE_INF ) {
102
+   public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) {
103
+		if ($original_value === EE_INF) {
104 104
 			$new_value = Model_Data_Translator::ee_inf_in_rest;
105
-		} elseif( $field_obj instanceof \EE_Datetime_Field ) {
106
-			if( $original_value instanceof \DateTime ) {
107
-				$new_value = $original_value->format( 'Y-m-d H:i:s' );
108
-			} elseif( is_int( $original_value ) ) {
109
-				$new_value = date( 'Y-m-d H:i:s', $original_value ); 
105
+		} elseif ($field_obj instanceof \EE_Datetime_Field) {
106
+			if ($original_value instanceof \DateTime) {
107
+				$new_value = $original_value->format('Y-m-d H:i:s');
108
+			} elseif (is_int($original_value)) {
109
+				$new_value = date('Y-m-d H:i:s', $original_value); 
110 110
 			} else {
111 111
 				$new_value = $original_value;
112 112
 			}
113
-			$new_value = mysql_to_rfc3339( $new_value );
113
+			$new_value = mysql_to_rfc3339($new_value);
114 114
 		} else {
115 115
 			$new_value = $original_value;
116 116
 		}
117
-		return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
117
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
118 118
 			$new_value,
119 119
 			$field_obj,
120 120
 			$original_value,
@@ -134,29 +134,29 @@  discard block
 block discarded – undo
134 134
 	 * @return array
135 135
 	 * @throws \EE_Error
136 136
 	 */
137
-	public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) {
137
+	public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) {
138 138
 		$query_param_for_models = array();
139
-		foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) {
139
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
140 140
 			$field = Model_Data_Translator::deduce_field_from_query_param( 
141
-				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), 
141
+				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), 
142 142
 				$model
143 143
 			);
144
-			if( $field instanceof \EE_Model_Field_Base ) {
144
+			if ($field instanceof \EE_Model_Field_Base) {
145 145
 				//did they specify an operator?
146
-				if( is_array( $query_param_value ) ) {
147
-					$op = $query_param_value[ 0 ];
148
-					$translated_value = array( $op );
149
-					if( isset( $query_param_value[ 1 ] ) ) {
150
-						$value = $query_param_value[ 1 ];
151
-						$translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version );
146
+				if (is_array($query_param_value)) {
147
+					$op = $query_param_value[0];
148
+					$translated_value = array($op);
149
+					if (isset($query_param_value[1])) {
150
+						$value = $query_param_value[1];
151
+						$translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version);
152 152
 					}
153 153
 				} else {
154
-					$translated_value  = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version );
154
+					$translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version);
155 155
 				}
156
-				$query_param_for_models[ $query_param_key ] = $translated_value;
156
+				$query_param_for_models[$query_param_key] = $translated_value;
157 157
 			} else {
158 158
 				//so it's not for a field, assume it's a logic query param key
159
-				$query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version );
159
+				$query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version);
160 160
 			}
161 161
 		}
162 162
 		return $query_param_for_models;
@@ -171,27 +171,27 @@  discard block
 block discarded – undo
171 171
 	 * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API
172 172
 	 * @return array which can be passed into the EE4 REST API when querying a model resource
173 173
 	 */
174
-	public static function prepare_query_params_for_rest_api( $model_query_params, \EEM_Base $model,  $requested_version = null ) {
175
-		if( $requested_version === null ) {
176
-			$requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ;
174
+	public static function prepare_query_params_for_rest_api($model_query_params, \EEM_Base $model, $requested_version = null) {
175
+		if ($requested_version === null) {
176
+			$requested_version = \EED_Core_Rest_Api::latest_rest_api_version();
177 177
 		}
178 178
 		$rest_query_params = $model_query_params;
179
-		if ( isset( $model_query_params[0] ) ) {
180
-			$rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
181
-				$model_query_params[ 0 ],
179
+		if (isset($model_query_params[0])) {
180
+			$rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
181
+				$model_query_params[0],
182 182
 				$model,
183 183
 				$requested_version
184 184
 			);
185
-			unset( $rest_query_params[0] );
185
+			unset($rest_query_params[0]);
186 186
 		}
187
-		if ( isset( $model_query_params[ 'having' ] ) ) {
188
-			$rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
189
-				$model_query_params[ 'having' ],
187
+		if (isset($model_query_params['having'])) {
188
+			$rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
189
+				$model_query_params['having'],
190 190
 				$model,
191 191
 				$requested_version
192 192
 			);
193 193
 		}
194
-		return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version );
194
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version);
195 195
 	}
196 196
 	
197 197
 	/**
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
 	 * @param string $requested_version eg "4.8.36"
202 202
 	 * @return array ready for use in the rest api query params
203 203
 	 */
204
-	public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) {
204
+	public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) {
205 205
 		$query_param_for_models = array();
206
-		foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) {
206
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
207 207
 			$field = Model_Data_Translator::deduce_field_from_query_param( 
208
-				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), 
208
+				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), 
209 209
 				$model
210 210
 			);
211
-			if( $field instanceof \EE_Model_Field_Base ) {
211
+			if ($field instanceof \EE_Model_Field_Base) {
212 212
 				//did they specify an operator?
213
-				if( is_array( $query_param_value ) ) {
214
-					$op = $query_param_value[ 0 ];
215
-					$translated_value = array( $op );
216
-					if( isset( $query_param_value[ 1 ] ) ) {
217
-						$value = $query_param_value[ 1 ];
218
-						$translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version );
213
+				if (is_array($query_param_value)) {
214
+					$op = $query_param_value[0];
215
+					$translated_value = array($op);
216
+					if (isset($query_param_value[1])) {
217
+						$value = $query_param_value[1];
218
+						$translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version);
219 219
 					}
220 220
 				} else {
221
-					$translated_value  = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version );
221
+					$translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version);
222 222
 				}
223
-				$query_param_for_models[ $query_param_key ] = $translated_value;
223
+				$query_param_for_models[$query_param_key] = $translated_value;
224 224
 			} else {
225 225
 				//so it's not for a field, assume it's a logic query param key
226
-				$query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version );
226
+				$query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version);
227 227
 			}
228 228
 		}
229 229
 		return $query_param_for_models;
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 	 * @param $condition_query_param_key
236 236
 	 * @return string
237 237
 	 */
238
-	public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) {
238
+	public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
239 239
 		$pos_of_star = strpos($condition_query_param_key, '*');
240
-		if($pos_of_star === FALSE){
240
+		if ($pos_of_star === FALSE) {
241 241
 			return $condition_query_param_key;
242
-		}else{
242
+		} else {
243 243
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
244 244
 			return $condition_query_param_sans_star;
245 245
 		}
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
 	 * @return \EE_Model_Field_Base
256 256
 	 * @throws \EE_Error
257 257
 	 */
258
-	public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){
258
+	public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) {
259 259
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
260 260
 		//which will help us find the database table and column
261 261
 
262
-		$query_param_parts = explode(".",$query_param_name);
263
-		if(empty($query_param_parts)){
264
-			throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
262
+		$query_param_parts = explode(".", $query_param_name);
263
+		if (empty($query_param_parts)) {
264
+			throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
265 265
 		}
266 266
 		$number_of_parts = count($query_param_parts);
267
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
268
-		if($number_of_parts == 1){
267
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
268
+		if ($number_of_parts == 1) {
269 269
 			$field_name = $last_query_param_part;
270
-		}else{// $number_of_parts >= 2
270
+		} else {// $number_of_parts >= 2
271 271
 			//the last part is the column name, and there are only 2parts. therefore...
272 272
 			$field_name = $last_query_param_part;
273
-			$model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]);
273
+			$model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]);
274 274
 		}
275
-		try{
275
+		try {
276 276
 			return $model->field_settings_for($field_name);
277
-		}catch(\EE_Error $e){
277
+		} catch (\EE_Error $e) {
278 278
 			return null;
279 279
 		}
280 280
 	}
Please login to merge, or discard this patch.