Completed
Branch BUG-9647-cpt-queries (303307)
by
unknown
201:19 queued 184:10
created
core/interfaces/EEI_Interfaces.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -310,23 +310,23 @@  discard block
 block discarded – undo
310 310
 	 * @param float $amount
311 311
 	 * @param string $name
312 312
 	 * @param string $description
313
-         * @param string $code
314
-         * @param boolean $add_to_existing_line_item if true and a duplicate line item with
315
-         *  the same code is found, $amount will be added onto it; otherwise will simply
316
-         *  set the taxes to match $amount
313
+	 * @param string $code
314
+	 * @param boolean $add_to_existing_line_item if true and a duplicate line item with
315
+	 *  the same code is found, $amount will be added onto it; otherwise will simply
316
+	 *  set the taxes to match $amount
317 317
 	 * @return EE_Line_Item the new tax created
318 318
 	 */
319 319
 	public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name  = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false );
320 320
 
321
-         /**
322
-         * Makes all the line items which are children of $line_item taxable (or not).
323
-         * Does NOT save the line items
324
-         * @param EE_Line_Item $line_item
325
-         * @param boolean $taxable
326
-         * @param string $code_substring_for_whitelist if this string is part of the line item's code
327
-         *  it will be whitelisted (ie, except from becoming taxable)
328
-         */
329
-        public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
321
+		 /**
322
+		  * Makes all the line items which are children of $line_item taxable (or not).
323
+		  * Does NOT save the line items
324
+		  * @param EE_Line_Item $line_item
325
+		  * @param boolean $taxable
326
+		  * @param string $code_substring_for_whitelist if this string is part of the line item's code
327
+		  *  it will be whitelisted (ie, except from becoming taxable)
328
+		  */
329
+		public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
330 330
 
331 331
 	/**
332 332
 	 * Adds a simple item ( unrelated to any other model object) to the total line item,
@@ -356,15 +356,15 @@  discard block
 block discarded – undo
356 356
  */
357 357
 interface EEHI_Money{
358 358
 		/**
359
-	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
360
-	 * This should be used to compare floats instead of normal '==' because floats
361
-	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
362
-	 * but actually differ by 0.00000001.
363
-	 * @param float $float1
364
-	 * @param float $float2
365
-	 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
366
-	 * @return boolean whether the equation is true or false
367
-	 */
359
+		 * For comparing floats. Default operator is '=', but see the $operator below for all options.
360
+		 * This should be used to compare floats instead of normal '==' because floats
361
+		 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
362
+		 * but actually differ by 0.00000001.
363
+		 * @param float $float1
364
+		 * @param float $float2
365
+		 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
366
+		 * @return boolean whether the equation is true or false
367
+		 */
368 368
 	public function compare_floats( $float1, $float2, $operator='=' );
369 369
 }
370 370
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Interface EEI_Base
7 7
  */
8
-interface EEI_Base{
8
+interface EEI_Base {
9 9
 	/**
10 10
 	 * gets the unique ID of the model object. If it hasn't been saved yet
11 11
 	 * to the database, this should be 0 or NULL
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row)
33 33
 	 * NOTE: if the values haven't changed, returns 0
34 34
 	 */
35
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL);
35
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL);
36 36
 
37 37
 	/**
38 38
 	 * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param boolean $unique
44 44
 	 * @return boolean
45 45
 	 */
46
-	public function add_extra_meta($meta_key,$meta_value,$unique = false);
46
+	public function add_extra_meta($meta_key, $meta_value, $unique = false);
47 47
 
48 48
 	/**
49 49
 	 * Deletes all the extra meta rows for this record as specified by key. If $meta_value
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param string $meta_value
53 53
 	 * @return int number of extra meta rows deleted
54 54
 	 */
55
-	public function delete_extra_meta($meta_key,$meta_value = NULL);
55
+	public function delete_extra_meta($meta_key, $meta_value = NULL);
56 56
 
57 57
 	/**
58 58
 	 * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param mixed $default if we don't find anything, what should we return?
64 64
 	 * @return mixed single value if $single; array if ! $single
65 65
 	 */
66
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL);
66
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL);
67 67
 }
68 68
 
69 69
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param 	EE_Response $response
91 91
 	 * @return 	EE_Response
92 92
 	 */
93
-	public function handle_request( EE_Request $request, EE_Response $response );
93
+	public function handle_request(EE_Request $request, EE_Response $response);
94 94
 }
95 95
 
96 96
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param EE_Request $request
107 107
 	 * @param EE_Response $response
108 108
 	 */
109
-	public function handle_response( EE_Request $request, EE_Response $response );
109
+	public function handle_response(EE_Request $request, EE_Response $response);
110 110
 }
111 111
 
112 112
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @param string $country
287 287
 	 * @param string $CNT_ISO
288 288
 	 */
289
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO );
289
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO);
290 290
 }
291 291
 
292 292
 
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
 /**
297 297
  * Interface EEHI_Line_Item
298 298
  */
299
-interface EEHI_Line_Item{
299
+interface EEHI_Line_Item {
300 300
 	/**
301 301
 	 * Adds an item to the purchase in the right spot
302 302
 	 * @param EE_Line_Item $total_line_item
303 303
 	 * @param EE_Line_Item $line_item
304 304
 	 */
305
-	public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item );
305
+	public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item);
306 306
 	/**
307 307
 	 * Overwrites the previous tax by clearing out the old taxes, and creates a new
308 308
 	 * tax and updates the total line item accordingly
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
          *  set the taxes to match $amount
317 317
 	 * @return EE_Line_Item the new tax created
318 318
 	 */
319
-	public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name  = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false );
319
+	public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false);
320 320
 
321 321
          /**
322 322
          * Makes all the line items which are children of $line_item taxable (or not).
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
          * @param string $code_substring_for_whitelist if this string is part of the line item's code
327 327
          *  it will be whitelisted (ie, except from becoming taxable)
328 328
          */
329
-        public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
329
+        public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null);
330 330
 
331 331
 	/**
332 332
 	 * Adds a simple item ( unrelated to any other model object) to the total line item,
@@ -340,21 +340,21 @@  discard block
 block discarded – undo
340 340
 	 * @param boolean $code if set to a value, ensures there is only one line item with that code
341 341
 	 * @return boolean success
342 342
 	 */
343
-	public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null );
343
+	public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null);
344 344
 
345 345
 	/**
346 346
 	 * Gets the line item for the taxes subtotal
347 347
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
348 348
 	 * @return \EE_Line_Item
349 349
 	 */
350
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item );
350
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item);
351 351
 }
352 352
 
353 353
 
354 354
 /**
355 355
  * Money-related helper
356 356
  */
357
-interface EEHI_Money{
357
+interface EEHI_Money {
358 358
 		/**
359 359
 	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
360 360
 	 * This should be used to compare floats instead of normal '==' because floats
@@ -365,13 +365,13 @@  discard block
 block discarded – undo
365 365
 	 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
366 366
 	 * @return boolean whether the equation is true or false
367 367
 	 */
368
-	public function compare_floats( $float1, $float2, $operator='=' );
368
+	public function compare_floats($float1, $float2, $operator = '=');
369 369
 }
370 370
 
371 371
 /**
372 372
  * Interface EEHI_Template
373 373
  */
374
-interface EEHI_Template{
374
+interface EEHI_Template {
375 375
 
376 376
 	/**
377 377
 	 * EEH_Template::format_currency
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * @param string   $cur_code_span_class
385 385
 	 * @return string the html output for the formatted money value
386 386
 	 */
387
-	public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' );
387
+	public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code');
388 388
 }
389 389
 
390 390
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 * @param array $options
400 400
 	 * @return mixed
401 401
 	 */
402
-	public function display_line_item( EE_Line_Item $line_item, $options = array() );
402
+	public function display_line_item(EE_Line_Item $line_item, $options = array());
403 403
 
404 404
 }
405 405
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @throws EE_Error
417 417
 	 * @return bool
418 418
 	 */
419
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' );
419
+	public static function ensure_file_exists_and_is_writable($full_file_path = '');
420 420
 
421 421
 	/**
422 422
 	 * ensure_folder_exists_and_is_writable
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	 * @throws EE_Error
426 426
 	 * @return bool
427 427
 	 */
428
-	public static function ensure_folder_exists_and_is_writable( $folder = '' );
428
+	public static function ensure_folder_exists_and_is_writable($folder = '');
429 429
 }
430 430
 
431 431
 // End of file EEI_Interfaces.php
Please login to merge, or discard this patch.
core/business/EE_Transaction_Processor.class.php 2 patches
Indentation   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
  * the interaction of EE_Transaction and EE_Registration model objects
8 8
  * Provides methods for manipulating and processing changes to an EE_Transaction
9 9
  * and it's related EE_Registrations with regards to the checkout/registration process
10
-
11
-*
10
+ *
12 11
 *@package     Event Espresso
13 12
  * @subpackage 	core
14 13
  * @author      Brent Christensen
@@ -704,7 +703,7 @@  discard block
 block discarded – undo
704 703
 						foreach ( $available_payment_methods as $available_payment_method ) {
705 704
 							if (
706 705
 								$available_payment_method instanceof EE_Payment_Method
707
-							    && $available_payment_method->open_by_default()
706
+								&& $available_payment_method->open_by_default()
708 707
 							) {
709 708
 								$PMD_ID = $available_payment_method->ID();
710 709
 								break;
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Transaction_Processor
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	 * @param array $registration_query_params
53 53
 	 *@return EE_Transaction_Processor instance
54 54
 	 */
55
-	public static function instance( $registration_query_params = array() ) {
55
+	public static function instance($registration_query_params = array()) {
56 56
 		// check if class object is instantiated
57
-		if ( ! self::$_instance instanceof EE_Transaction_Processor ) {
58
-			self::$_instance = new self( $registration_query_params );
57
+		if ( ! self::$_instance instanceof EE_Transaction_Processor) {
58
+			self::$_instance = new self($registration_query_params);
59 59
 		}
60 60
 		return self::$_instance;
61 61
 	}
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @param array $registration_query_params
67 67
 	 * @return EE_Transaction_Processor
68 68
 	 */
69
-	private function __construct( $registration_query_params = array() ) {
69
+	private function __construct($registration_query_params = array()) {
70 70
 		// make sure some query params are set for retrieving registrations
71
-		$this->_set_registration_query_params( $registration_query_params );
71
+		$this->_set_registration_query_params($registration_query_params);
72 72
 	}
73 73
 
74 74
 
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @access private
78 78
 	 * @param array $registration_query_params
79 79
 	 */
80
-	private function _set_registration_query_params( $registration_query_params ) {
81
-		$this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' ));
80
+	private function _set_registration_query_params($registration_query_params) {
81
+		$this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC'));
82 82
 	}
83 83
 
84 84
 
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	 * @param string $old_txn_status
97 97
 	 */
98
-	public function set_old_txn_status( $old_txn_status ) {
98
+	public function set_old_txn_status($old_txn_status) {
99 99
 		// only set the first time
100
-		if ( $this->_old_txn_status === null ) {
100
+		if ($this->_old_txn_status === null) {
101 101
 			$this->_old_txn_status = $old_txn_status;
102 102
 		}
103 103
 	}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	/**
117 117
 	 * @param string $new_txn_status
118 118
 	 */
119
-	public function set_new_txn_status( $new_txn_status ) {
119
+	public function set_new_txn_status($new_txn_status) {
120 120
 		$this->_new_txn_status = $new_txn_status;
121 121
 	}
122 122
 
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 	 * @param bool   $check_all
148 148
 	 * @return boolean | int
149 149
 	 */
150
-	private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) {
150
+	private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) {
151 151
 		$reg_steps = $transaction->reg_steps();
152
-		if ( ! is_array( $reg_steps ) || empty( $reg_steps )) {
152
+		if ( ! is_array($reg_steps) || empty($reg_steps)) {
153 153
 			return false;
154 154
 		}
155 155
 		// loop thru reg steps array)
156
-		foreach ( $reg_steps as $slug => $reg_step_completed ) {
156
+		foreach ($reg_steps as $slug => $reg_step_completed) {
157 157
 			// if NOT checking ALL steps (only checking one step)
158
-			if ( ! $check_all ) {
158
+			if ( ! $check_all) {
159 159
 				// and this is the one
160
-				if ( $slug === $reg_step_slug ) {
160
+				if ($slug === $reg_step_slug) {
161 161
 					return $reg_step_completed;
162 162
 				} else {
163 163
 					// skip to next reg step in loop
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				}
166 166
 			}
167 167
 			// $check_all must be true, else we would never have gotten to this point
168
-			if ( $slug === $reg_step_slug ) {
168
+			if ($slug === $reg_step_slug) {
169 169
 				// if we reach this point, then we are testing either:
170 170
 				// all_reg_steps_completed_except() or
171 171
 				// all_reg_steps_completed_except_final_step(),
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				// ie: "is everything completed except the final step?"
175 175
 				// "that is correct... the final step is not completed, but all others are."
176 176
 				return $reg_step_completed !== true ? true : false;
177
-			} else if ( $reg_step_completed !== true ) {
177
+			} else if ($reg_step_completed !== true) {
178 178
 				// if any reg step is NOT completed, then ALL steps are not completed
179 179
 				return false;
180 180
 			}
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	 * @param EE_Transaction $transaction
196 196
 	 * @return boolean
197 197
 	 */
198
-	public function all_reg_steps_completed( EE_Transaction $transaction ) {
199
-		return $this->_reg_steps_completed( $transaction );
198
+	public function all_reg_steps_completed(EE_Transaction $transaction) {
199
+		return $this->_reg_steps_completed($transaction);
200 200
 	}
201 201
 
202 202
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @param string $exception
214 214
 	 * @return boolean
215 215
 	 */
216
-	public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) {
217
-		return $this->_reg_steps_completed( $transaction, $exception );
216
+	public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') {
217
+		return $this->_reg_steps_completed($transaction, $exception);
218 218
 	}
219 219
 
220 220
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @param EE_Transaction $transaction
231 231
 	 * @return boolean
232 232
 	 */
233
-	public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) {
234
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration' );
233
+	public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) {
234
+		return $this->_reg_steps_completed($transaction, 'finalize_registration');
235 235
 	}
236 236
 
237 237
 
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param string $reg_step_slug
249 249
 	 * @return boolean | int
250 250
 	 */
251
-	public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
252
-		return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE );
251
+	public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
252
+		return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE);
253 253
 	}
254 254
 
255 255
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @param EE_Transaction $transaction
266 266
 	 * @return boolean | int
267 267
 	 */
268
-	public function final_reg_step_completed( EE_Transaction $transaction ) {
269
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE );
268
+	public function final_reg_step_completed(EE_Transaction $transaction) {
269
+		return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE);
270 270
 	}
271 271
 
272 272
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @return boolean
282 282
 	 * @throws \EE_Error
283 283
 	 */
284
-	public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) {
285
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, time() );
284
+	public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) {
285
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, time());
286 286
 	}
287 287
 
288 288
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @return boolean
298 298
 	 * @throws \EE_Error
299 299
 	 */
300
-	public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
301
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, true );
300
+	public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
301
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, true);
302 302
 	}
303 303
 
304 304
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 * @return boolean
314 314
 	 * @throws \EE_Error
315 315
 	 */
316
-	public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) {
317
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, false );
316
+	public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) {
317
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, false);
318 318
 	}
319 319
 
320 320
 
@@ -330,37 +330,37 @@  discard block
 block discarded – undo
330 330
 	 * @return boolean
331 331
 	 * @throws \EE_Error
332 332
 	 */
333
-	private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) {
333
+	private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) {
334 334
 		// validate status
335
-		$status = is_bool( $status ) || is_int( $status ) ? $status : false;
335
+		$status = is_bool($status) || is_int($status) ? $status : false;
336 336
 		// get reg steps array
337 337
 		$txn_reg_steps = $transaction->reg_steps();
338 338
 		// if reg step does NOT exist
339
-		if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) {
339
+		if ( ! isset($txn_reg_steps[$reg_step_slug])) {
340 340
 			return false;
341 341
 		}
342 342
 		// if  we're trying to complete a step that is already completed
343
-		if ( $txn_reg_steps[ $reg_step_slug ] === true ) {
343
+		if ($txn_reg_steps[$reg_step_slug] === true) {
344 344
 			return true;
345 345
 		}
346 346
 		// if  we're trying to complete a step that hasn't even started
347
-		if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) {
347
+		if ($status === true && $txn_reg_steps[$reg_step_slug] === false) {
348 348
 			return false;
349 349
 		}
350 350
 		// if current status value matches the incoming value (no change)
351 351
 		// type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890
352
-		if ( (int)$txn_reg_steps[ $reg_step_slug ] === (int)$status ) {
352
+		if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) {
353 353
 			// this will happen in cases where multiple AJAX requests occur during the same step
354 354
 			return true;
355 355
 		}
356 356
 		// if we're trying to set a start time, but it has already been set...
357
-		if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) {
357
+		if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) {
358 358
 			// skip the update below, but don't return FALSE so that errors won't be displayed
359 359
 			return true;
360 360
 		}
361 361
 		// update completed status
362
-		$txn_reg_steps[ $reg_step_slug ] = $status;
363
-		$transaction->set_reg_steps( $txn_reg_steps );
362
+		$txn_reg_steps[$reg_step_slug] = $status;
363
+		$transaction->set_reg_steps($txn_reg_steps);
364 364
 		$transaction->save();
365 365
 		// DEBUG LOG
366 366
 		//$this->log(
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
 	 * @param string $reg_step_slug
387 387
 	 * @return void
388 388
 	 */
389
-	public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) {
389
+	public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) {
390 390
 		// get reg steps array
391 391
 		$txn_reg_steps = $transaction->reg_steps();
392
-		unset( $txn_reg_steps[ $reg_step_slug ] );
393
-		$transaction->set_reg_steps( $txn_reg_steps );
392
+		unset($txn_reg_steps[$reg_step_slug]);
393
+		$transaction->set_reg_steps($txn_reg_steps);
394 394
 	}
395 395
 
396 396
 
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
 	 * @return    boolean
406 406
 	 * @throws \EE_Error
407 407
 	 */
408
-	public function toggle_failed_transaction_status( EE_Transaction $transaction ) {
408
+	public function toggle_failed_transaction_status(EE_Transaction $transaction) {
409 409
 		$existing_txn_status = $transaction->status_ID();
410 410
 		// set incoming TXN_Status
411
-		$this->set_old_txn_status( $existing_txn_status );
411
+		$this->set_old_txn_status($existing_txn_status);
412 412
 		// if TXN status is still set as "failed"...
413
-		if ( $existing_txn_status === EEM_Transaction::failed_status_code ) {
413
+		if ($existing_txn_status === EEM_Transaction::failed_status_code) {
414 414
 			// set incoming TXN_Status
415
-			$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
416
-			$transaction->set_status( EEM_Transaction::abandoned_status_code );
415
+			$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
416
+			$transaction->set_status(EEM_Transaction::abandoned_status_code);
417 417
 			$transaction->save();
418 418
 			return TRUE;
419 419
 		}
@@ -430,27 +430,27 @@  discard block
 block discarded – undo
430 430
 	 * @param  EE_Transaction $transaction
431 431
 	 * @return boolean
432 432
 	 */
433
-	public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) {
433
+	public function toggle_abandoned_transaction_status(EE_Transaction $transaction) {
434 434
 		// set incoming TXN_Status
435
-		$this->set_old_txn_status( $transaction->status_ID() );
435
+		$this->set_old_txn_status($transaction->status_ID());
436 436
 		// if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"...
437 437
 		$txn_status = $transaction->status_ID();
438 438
 		if (
439 439
 			$txn_status === EEM_Transaction::failed_status_code
440 440
 			|| $txn_status === EEM_Transaction::abandoned_status_code
441 441
 		) {
442
-			$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
442
+			$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
443 443
 			// if a contact record for the primary registrant has been created
444 444
 			if (
445 445
 				$transaction->primary_registration() instanceof EE_Registration
446 446
 				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
447 447
 			) {
448
-				$transaction->set_status( EEM_Transaction::incomplete_status_code );
449
-				$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
448
+				$transaction->set_status(EEM_Transaction::incomplete_status_code);
449
+				$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
450 450
 			} else {
451 451
 				// no contact record? yer abandoned!
452
-				$transaction->set_status( EEM_Transaction::abandoned_status_code );
453
-				$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
452
+				$transaction->set_status(EEM_Transaction::abandoned_status_code);
453
+				$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
454 454
 			}
455 455
 			return TRUE;
456 456
 		}
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 		);
484 484
 		// send messages
485 485
 		/** @type EE_Registration_Processor $registration_processor */
486
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
486
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
487 487
 		$registration_processor->trigger_registration_update_notifications(
488 488
 			$transaction->primary_registration(),
489
-			array( 'manually_updated' 	=> true )
489
+			array('manually_updated' 	=> true)
490 490
 		);
491 491
 		do_action(
492 492
 			'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
@@ -573,16 +573,16 @@  discard block
 block discarded – undo
573 573
 		$registration_query_params = array()
574 574
 	) {
575 575
 		// set incoming TXN_Status, and consider it new since old status should have been set
576
-		$this->set_new_txn_status( $transaction->status_ID() );
577
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' );
576
+		$this->set_new_txn_status($transaction->status_ID());
577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()');
578 578
 		// make sure some query params are set for retrieving registrations
579
-		$this->_set_registration_query_params( $registration_query_params );
579
+		$this->_set_registration_query_params($registration_query_params);
580 580
 		// get final reg step status
581
-		$finalized = $this->final_reg_step_completed( $transaction );
581
+		$finalized = $this->final_reg_step_completed($transaction);
582 582
 		// if the 'finalize_registration' step has been initiated (has a timestamp)
583 583
 		// but has not yet been fully completed (TRUE)
584
-		if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) {
585
-			$this->set_reg_step_completed( $transaction, 'finalize_registration' );
584
+		if (is_int($finalized) && $finalized !== false && $finalized !== true) {
585
+			$this->set_reg_step_completed($transaction, 'finalize_registration');
586 586
 			$finalized = true;
587 587
 		}
588 588
 		$transaction->save();
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 
606 606
 		// send messages
607 607
 		/** @type EE_Registration_Processor $registration_processor */
608
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
608
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
609 609
 		$registration_processor->trigger_registration_update_notifications(
610 610
 			$transaction->primary_registration(),
611 611
 			$update_params
@@ -641,22 +641,22 @@  discard block
 block discarded – undo
641 641
 	) {
642 642
 		$response = false;
643 643
 		/** @type EE_Registration_Processor $registration_processor */
644
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
644
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
645 645
 		// check that method exists
646
-		if ( ! method_exists( $registration_processor, $method_name )) {
647
-			throw new EE_Error( __( 'Method does not exist.', 'event_espresso' ));
646
+		if ( ! method_exists($registration_processor, $method_name)) {
647
+			throw new EE_Error(__('Method does not exist.', 'event_espresso'));
648 648
 		}
649 649
 		// make sure some query params are set for retrieving registrations
650
-		$this->_set_registration_query_params( $registration_query_params );
650
+		$this->_set_registration_query_params($registration_query_params);
651 651
 		// loop through cached registrations
652
-		foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) {
653
-			if ( $registration instanceof EE_Registration ) {
654
-				if ( $additional_param ) {
655
-					$response = $registration_processor->{$method_name}( $registration, $additional_param )
652
+		foreach ($transaction->registrations($this->_registration_query_params) as $registration) {
653
+			if ($registration instanceof EE_Registration) {
654
+				if ($additional_param) {
655
+					$response = $registration_processor->{$method_name}($registration, $additional_param)
656 656
 						? true
657 657
 						: $response;
658 658
 				} else {
659
-					$response = $registration_processor->{$method_name}( $registration )
659
+					$response = $registration_processor->{$method_name}($registration)
660 660
 						? true
661 661
 						: $response;
662 662
 				}
@@ -683,28 +683,28 @@  discard block
 block discarded – undo
683 683
 	public function set_transaction_payment_method_based_on_registration_statuses(
684 684
 		EE_Registration $edited_registration
685 685
 	) {
686
-		if ( $edited_registration instanceof EE_Registration ) {
686
+		if ($edited_registration instanceof EE_Registration) {
687 687
 			$transaction = $edited_registration->transaction();
688
-			if ( $transaction instanceof EE_Transaction ) {
688
+			if ($transaction instanceof EE_Transaction) {
689 689
 				$all_not_approved = true;
690
-				foreach ( $transaction->registrations() as $registration ) {
691
-					if ( $registration instanceof EE_Registration ) {
690
+				foreach ($transaction->registrations() as $registration) {
691
+					if ($registration instanceof EE_Registration) {
692 692
 						// if any REG != "Not Approved" then toggle to false
693 693
 						$all_not_approved = $registration->is_not_approved() ? $all_not_approved : false;
694 694
 					}
695 695
 				}
696 696
 				// if ALL Registrations are "Not Approved"
697
-				if ( $all_not_approved ) {
698
-					$transaction->set_payment_method_ID( null );
697
+				if ($all_not_approved) {
698
+					$transaction->set_payment_method_ID(null);
699 699
 					$transaction->save();
700 700
 				} else {
701 701
 					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
702 702
 						$transaction,
703 703
 						EEM_Payment_Method::scope_cart
704 704
 					);
705
-					if ( ! empty( $available_payment_methods ) ) {
705
+					if ( ! empty($available_payment_methods)) {
706 706
 						$PMD_ID = 0;
707
-						foreach ( $available_payment_methods as $available_payment_method ) {
707
+						foreach ($available_payment_methods as $available_payment_method) {
708 708
 							if (
709 709
 								$available_payment_method instanceof EE_Payment_Method
710 710
 							    && $available_payment_method->open_by_default()
@@ -713,22 +713,22 @@  discard block
 block discarded – undo
713 713
 								break;
714 714
 							}
715 715
 						}
716
-						if ( ! $PMD_ID ) {
717
-							$first_payment_method = reset( $available_payment_methods );
718
-							if ( $first_payment_method instanceof EE_Payment_Method ) {
716
+						if ( ! $PMD_ID) {
717
+							$first_payment_method = reset($available_payment_methods);
718
+							if ($first_payment_method instanceof EE_Payment_Method) {
719 719
 								$PMD_ID = $first_payment_method->ID();
720 720
 							} else {
721 721
 								EE_Error::add_error(
722
-									__( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ),
722
+									__('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'),
723 723
 									__FILE__, __LINE__, __FUNCTION__
724 724
 								);
725 725
 							}
726 726
 						}
727
-						$transaction->set_payment_method_ID( $PMD_ID );
727
+						$transaction->set_payment_method_ID($PMD_ID);
728 728
 						$transaction->save();
729 729
 					} else {
730 730
 						EE_Error::add_error(
731
-							__( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ),
731
+							__('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'),
732 732
 							__FILE__, __LINE__, __FUNCTION__
733 733
 						);
734 734
 					}
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Gateway.lib.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @subpackage		core/libraries/payment_methods
16 16
  * @author			Mike Nelson
17 17
  */
18
-abstract class EE_Gateway{
18
+abstract class EE_Gateway {
19 19
 	/**
20 20
 	 * a constant used as a possible value for $_currencies_supported to indicate
21 21
 	 * that ALL currencies are supported by this gateway
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * @return EE_Gateway
95 95
 	 */
96
-	public function __construct(){
96
+	public function __construct() {
97 97
 	}
98 98
 
99 99
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * beginning again)
106 106
 	 * @return array
107 107
 	 */
108
-	public function __sleep(){
108
+	public function __sleep() {
109 109
 		$properties = get_object_vars($this);
110
-		unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] );
110
+		unset($properties['_pay_model'], $properties['_pay_log']);
111 111
 		return array_keys($properties);
112 112
 	}
113 113
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * see $_supports_sending_refunds
116 116
 	 * @return boolean
117 117
 	 */
118
-	public function supports_sending_refunds(){
118
+	public function supports_sending_refunds() {
119 119
 		return $this->_supports_sending_refunds;
120 120
 	}
121 121
 	/**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * see $_supports_receiving_refunds
124 124
 	 * @return boolean
125 125
 	 */
126
-	public function supports_receiving_refunds(){
126
+	public function supports_receiving_refunds() {
127 127
 		return $this->_supports_receiving_refunds;
128 128
 	}
129 129
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @return EE_Payment for the refund
139 139
 	 * @throws EE_Error
140 140
 	 */
141
-	public function do_direct_refund( EE_Payment $payment, $refund_info = null ) {
141
+	public function do_direct_refund(EE_Payment $payment, $refund_info = null) {
142 142
 		return NULL;
143 143
 	}
144 144
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * etc
150 150
 	 * @param array $settings_array
151 151
 	 */
152
-	public function set_settings($settings_array){
153
-		foreach($settings_array as $name => $value){
152
+	public function set_settings($settings_array) {
153
+		foreach ($settings_array as $name => $value) {
154 154
 			$property_name = "_".$name;
155 155
 			$this->{$property_name} = $value;
156 156
 		}
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 	 * See this class description
160 160
 	 * @param EEMI_Payment $payment_model
161 161
 	 */
162
-	public function set_payment_model($payment_model){
162
+	public function set_payment_model($payment_model) {
163 163
 		$this->_pay_model = $payment_model;
164 164
 	}
165 165
 	/**
166 166
 	 * See this class description
167 167
 	 * @param EEMI_Payment_Log $payment_log_model
168 168
 	 */
169
-	public function set_payment_log($payment_log_model){
169
+	public function set_payment_log($payment_log_model) {
170 170
 		$this->_pay_log = $payment_log_model;
171 171
 	}
172 172
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * See this class description
175 175
 	 * @param EEHI_Template $template_helper
176 176
 	 */
177
-	public function set_template_helper($template_helper){
177
+	public function set_template_helper($template_helper) {
178 178
 		$this->_template = $template_helper;
179 179
 	}
180 180
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * See this class description
183 183
 	 * @param EEHI_Line_Item $line_item_helper
184 184
 	 */
185
-	public function set_line_item_helper( $line_item_helper ){
185
+	public function set_line_item_helper($line_item_helper) {
186 186
 		$this->_line_item = $line_item_helper;
187 187
 	}
188 188
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * See this class description
191 191
 	 * @param EEHI_Money $money_helper
192 192
 	 */
193
-	public function set_money_helper( $money_helper ){
193
+	public function set_money_helper($money_helper) {
194 194
 		$this->_money = $money_helper;
195 195
 	}
196 196
 
@@ -199,23 +199,23 @@  discard block
 block discarded – undo
199 199
 	 * @param $message
200 200
 	 * @param $payment
201 201
 	 */
202
-	public function log($message,$payment){
203
-		if($payment instanceof EEI_Payment){
204
-			$type='Payment';
202
+	public function log($message, $payment) {
203
+		if ($payment instanceof EEI_Payment) {
204
+			$type = 'Payment';
205 205
 			$id = $payment->ID();
206
-		}else{
206
+		} else {
207 207
 			$type = 'Payment_Method';
208 208
 			$id = $this->_ID;
209 209
 		}
210
-		$this->_pay_log->gateway_log($message,$id,$type);
210
+		$this->_pay_log->gateway_log($message, $id, $type);
211 211
 	}
212 212
 	/**
213 213
 	 * Formats the amount so it can generally be sent to gateways
214 214
 	 * @param float $amount
215 215
 	 * @return string
216 216
 	 */
217
-	public function format_currency($amount){
218
-		return number_format( $amount, 2, '.', '' );
217
+	public function format_currency($amount) {
218
+		return number_format($amount, 2, '.', '');
219 219
 //		return $this->_template->format_currency($amount, true);
220 220
 	}
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * or a string indicating they're all supported (EE_gateway::all_currencies_supported)
225 225
 	 * @return mixed array or string
226 226
 	 */
227
-	public function currencies_supported(){
227
+	public function currencies_supported() {
228 228
 		return $this->_currencies_supported;
229 229
 	}
230 230
 
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
 	 * @param EE_Transaction  $transaction
237 237
 	 * @return float
238 238
 	 */
239
-	protected function _sum_items_and_taxes( EE_Transaction  $transaction){
239
+	protected function _sum_items_and_taxes(EE_Transaction  $transaction) {
240 240
 		$total_line_item = $transaction->total_line_item();
241 241
 		$total = 0;
242
-		foreach($total_line_item->get_items() as $item_line_item ){
243
-			$total += max( $item_line_item->total(), 0 );
242
+		foreach ($total_line_item->get_items() as $item_line_item) {
243
+			$total += max($item_line_item->total(), 0);
244 244
 		}
245
-		foreach($total_line_item->tax_descendants() as $tax_line_item ){
246
-			$total += max( $tax_line_item->total(), 0 );
245
+		foreach ($total_line_item->tax_descendants() as $tax_line_item) {
246
+			$total += max($tax_line_item->total(), 0);
247 247
 		}
248 248
 		return $total;
249 249
 	}
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 	 * @param EEI_Payment $payment
255 255
 	 * @return boolean
256 256
 	 */
257
-	protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){
257
+	protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) {
258 258
 		return  $this->_money->compare_floats(
259
-					$this->_sum_items_and_taxes( $payment->transaction() ),
259
+					$this->_sum_items_and_taxes($payment->transaction()),
260 260
 					$payment->transaction()->total() ) &&
261 261
 				$this->_money->compare_floats(
262 262
 					$payment->amount(),
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @param EE_Payment $payment
275 275
 	 * @return void
276 276
 	 */
277
-	public function update_txn_based_on_payment( $payment ){
277
+	public function update_txn_based_on_payment($payment) {
278 278
 		//maybe update the transaction or line items or registrations
279 279
 		//but most gateways don't need to do this, because they only update the payment
280 280
 	}
Please login to merge, or discard this patch.
core/EE_Payment_Processor.core.php 3 patches
Indentation   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class EE_Payment_Processor extends EE_Processor_Base {
15 15
 	/**
16
-     * 	@var EE_Payment_Processor $_instance
16
+	 * 	@var EE_Payment_Processor $_instance
17 17
 	 * 	@access 	private
18
-     */
18
+	 */
19 19
 	private static $_instance;
20 20
 
21 21
 
@@ -50,7 +50,6 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately.
52 52
 	 * Saves the payment that is generated
53
-
54 53
 	 *
55 54
 *@param EE_Payment_Method    $payment_method
56 55
 	 * @param EE_Transaction       $transaction
@@ -130,7 +129,6 @@  discard block
 block discarded – undo
130 129
 
131 130
 
132 131
 	/**
133
-
134 132
 	 * @param EE_Base_Class|int $transaction
135 133
 	 * @param EE_Payment_Method $payment_method
136 134
 	 * @throws EE_Error
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 /**
4 4
  *
5 5
  * EE_Payment_Processor
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function instance() {
29 29
 		// check if class object is instantiated
30
-		if ( ! self::$_instance instanceof EE_Payment_Processor ) {
30
+		if ( ! self::$_instance instanceof EE_Payment_Processor) {
31 31
 			self::$_instance = new self();
32 32
 		}
33 33
 		return self::$_instance;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *@return EE_Payment_Processor
43 43
 	 */
44 44
 	private function __construct() {
45
-		do_action( 'AHEE__EE_Payment_Processor__construct' );
45
+		do_action('AHEE__EE_Payment_Processor__construct');
46 46
 	}
47 47
 
48 48
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$update_txn = true,
82 82
 		$cancel_url = ''
83 83
 	) {
84
-		if( (float)$amount < 0 ) {
84
+		if ((float) $amount < 0) {
85 85
 			throw new EE_Error(
86 86
 				sprintf(
87 87
 					__(
@@ -94,33 +94,33 @@  discard block
 block discarded – undo
94 94
 			);
95 95
 		}
96 96
 		// verify payment method
97
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE );
97
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE);
98 98
 		// verify transaction
99
-		EEM_Transaction::instance()->ensure_is_obj( $transaction );
100
-		$transaction->set_payment_method_ID( $payment_method->ID() );
99
+		EEM_Transaction::instance()->ensure_is_obj($transaction);
100
+		$transaction->set_payment_method_ID($payment_method->ID());
101 101
 		// verify payment method type
102
-		if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
102
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
103 103
 			$payment = $payment_method->type_obj()->process_payment(
104 104
 				$transaction,
105
-				min( $amount, $transaction->remaining() ),//make sure we don't overcharge
105
+				min($amount, $transaction->remaining()), //make sure we don't overcharge
106 106
 				$billing_form,
107 107
 				$return_url,
108
-				add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ),
108
+				add_query_arg(array('ee_cancel_payment' => true), $cancel_url),
109 109
 				$method,
110 110
 				$by_admin
111 111
 			);
112 112
 			// check if payment method uses an off-site gateway
113
-			if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) {
113
+			if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) {
114 114
 				// don't process payments for off-site gateways yet because no payment has occurred yet
115
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
115
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
116 116
 			}
117 117
 			return $payment;
118 118
 		} else {
119 119
 			EE_Error::add_error(
120 120
 				sprintf(
121
-					__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
121
+					__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
122 122
 					'<br/>',
123
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
123
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
124 124
 				), __FILE__, __FUNCTION__, __LINE__
125 125
 			);
126 126
 			return NULL;
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 * @throws EE_Error
137 137
 	 * @return string
138 138
 	 */
139
-	public function get_ipn_url_for_payment_method( $transaction, $payment_method ){
139
+	public function get_ipn_url_for_payment_method($transaction, $payment_method) {
140 140
 		/** @type \EE_Transaction $transaction */
141
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
141
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
142 142
 		$primary_reg = $transaction->primary_registration();
143
-		if( ! $primary_reg instanceof EE_Registration ){
143
+		if ( ! $primary_reg instanceof EE_Registration) {
144 144
 			throw new EE_Error(
145 145
 				sprintf(
146 146
 					__(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				)
152 152
 			);
153 153
 		}
154
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true);
154
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
155 155
 		$url = add_query_arg(
156 156
 			array(
157 157
 				'e_reg_url_link'=>$primary_reg->reg_url_link(),
@@ -188,92 +188,92 @@  discard block
 block discarded – undo
188 188
 		$update_txn = true,
189 189
 		$separate_IPN_request = true
190 190
 	) {
191
-		EE_Registry::instance()->load_model( 'Change_Log' );
192
-		$_req_data = $this->_remove_unusable_characters_from_array( $_req_data );
193
-		EE_Processor_Base::set_IPN( $separate_IPN_request );
191
+		EE_Registry::instance()->load_model('Change_Log');
192
+		$_req_data = $this->_remove_unusable_characters_from_array($_req_data);
193
+		EE_Processor_Base::set_IPN($separate_IPN_request);
194 194
 		$obj_for_log = null;
195
-		if( $transaction instanceof EE_Transaction ){
195
+		if ($transaction instanceof EE_Transaction) {
196 196
 			$obj_for_log = $transaction;
197
-			if( $payment_method instanceof EE_Payment_Method ) {
197
+			if ($payment_method instanceof EE_Payment_Method) {
198 198
 				$obj_for_log = EEM_Payment::instance()->get_one(
199 199
 					array(
200
-						array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ),
201
-						'order_by' => array( 'PAY_timestamp' => 'desc' )
200
+						array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()),
201
+						'order_by' => array('PAY_timestamp' => 'desc')
202 202
 					)
203 203
 				);
204 204
 			}
205
-		} else if( $payment_method instanceof EE_Payment ) {
205
+		} else if ($payment_method instanceof EE_Payment) {
206 206
 			$obj_for_log = $payment_method;
207 207
 		}
208 208
 		$log = EEM_Change_Log::instance()->log(
209 209
 			EEM_Change_Log::type_gateway,
210
-			array( 'IPN data received' => $_req_data ),
210
+			array('IPN data received' => $_req_data),
211 211
 			$obj_for_log
212 212
 		);
213
-		try{
213
+		try {
214 214
 			/**
215 215
 			 * @var EE_Payment $payment
216 216
 			 */
217 217
 			$payment = NULL;
218
-			if($transaction && $payment_method){
218
+			if ($transaction && $payment_method) {
219 219
 				/** @type EE_Transaction $transaction */
220 220
 				$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
221 221
 				/** @type EE_Payment_Method $payment_method */
222 222
 				$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
223
-				if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
224
-						$payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction );
223
+				if ($payment_method->type_obj() instanceof EE_PMT_Base) {
224
+						$payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
225 225
 						$log->set_object($payment);
226 226
 				} else {
227 227
 					// not a payment
228 228
 					EE_Error::add_error(
229 229
 						sprintf(
230
-							__( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ),
230
+							__('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'),
231 231
 							'<br/>',
232
-							EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
232
+							EE_Registry::instance()->CFG->organization->get_pretty('email')
233 233
 						),
234 234
 						__FILE__, __FUNCTION__, __LINE__
235 235
 					);
236 236
 				}
237
-			}else{
237
+			} else {
238 238
 				//that's actually pretty ok. The IPN just wasn't able
239 239
 				//to identify which transaction or payment method this was for
240 240
 				// give all active payment methods a chance to claim it
241 241
 				$active_payment_methods = EEM_Payment_Method::instance()->get_all_active();
242
-				foreach( $active_payment_methods as $active_payment_method ){
243
-					try{
244
-						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data );
242
+				foreach ($active_payment_methods as $active_payment_method) {
243
+					try {
244
+						$payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
245 245
 						$payment_method = $active_payment_method;
246 246
 						EEM_Change_Log::instance()->log(
247 247
 							EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment
248 248
 						);
249 249
 						break;
250
-					} catch( EE_Error $e ) {
250
+					} catch (EE_Error $e) {
251 251
 						//that's fine- it apparently couldn't handle the IPN
252 252
 					}
253 253
 				}
254 254
 
255 255
 			}
256 256
 // 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
257
-			if( $payment instanceof EE_Payment){
257
+			if ($payment instanceof EE_Payment) {
258 258
 				$payment->save();
259 259
 				//  update the TXN
260
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request );
261
-			}else{
260
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
261
+			} else {
262 262
 				//we couldn't find the payment for this IPN... let's try and log at least SOMETHING
263
-				if($payment_method){
263
+				if ($payment_method) {
264 264
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method);
265
-				}elseif($transaction){
265
+				}elseif ($transaction) {
266 266
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction);
267 267
 				}
268 268
 			}
269 269
 			return $payment;
270 270
 
271
-		} catch( EE_Error $e ) {
271
+		} catch (EE_Error $e) {
272 272
 			do_action(
273 273
 				'AHEE__log', __FILE__, __FUNCTION__, sprintf(
274
-					__( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ),
275
-					print_r( $transaction, TRUE ),
276
-					print_r( $_req_data, TRUE ),
274
+					__('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'),
275
+					print_r($transaction, TRUE),
276
+					print_r($_req_data, TRUE),
277 277
 					$e->getMessage()
278 278
 				)
279 279
 			);
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 	 * @param  array $request_data
289 289
 	 * @return array
290 290
 	 */
291
-	protected function _remove_unusable_characters_from_array( array $request_data ) {
291
+	protected function _remove_unusable_characters_from_array(array $request_data) {
292 292
 		$return_data = array();
293
-		foreach( $request_data as $key => $value ) {
294
-			$return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value );
293
+		foreach ($request_data as $key => $value) {
294
+			$return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value);
295 295
 		}
296 296
 		return $return_data;
297 297
 	}
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param string $request_data
304 304
 	 * @return string
305 305
 	 */
306
-	protected function _remove_unusable_characters( $request_data ) {
307
-		return preg_replace( '/[^[:print:]]/', '', $request_data );
306
+	protected function _remove_unusable_characters($request_data) {
307
+		return preg_replace('/[^[:print:]]/', '', $request_data);
308 308
 	}
309 309
 
310 310
 
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 	 * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO,
327 327
 	 *                                      to call handle_ipn() for offsite gateways that don't receive separate IPNs
328 328
 	 */
329
-	public function finalize_payment_for( $transaction, $update_txn = TRUE ){
329
+	public function finalize_payment_for($transaction, $update_txn = TRUE) {
330 330
 		/** @var $transaction EE_Transaction */
331
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
331
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
332 332
 		$last_payment_method = $transaction->payment_method();
333
-		if ( $last_payment_method instanceof EE_Payment_Method ) {
334
-			$payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction );
335
-			$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
333
+		if ($last_payment_method instanceof EE_Payment_Method) {
334
+			$payment = $last_payment_method->type_obj()->finalize_payment_for($transaction);
335
+			$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
336 336
 			return $payment;
337 337
 		} else {
338 338
 			return NULL;
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 		EE_Payment $payment_to_refund,
356 356
 		$refund_info = array()
357 357
 	) {
358
-		if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) {
359
-			$payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info );
360
-			$this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund );
358
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) {
359
+			$payment_method->type_obj()->process_refund($payment_to_refund, $refund_info);
360
+			$this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
361 361
 		}
362 362
 		return $payment_to_refund;
363 363
 	}
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 	 *                        TXN is locked before updating
399 399
 	 * @throws \EE_Error
400 400
 	 */
401
-	public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){
401
+	public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) {
402 402
 		$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful';
403 403
 		/** @type EE_Transaction $transaction */
404
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
404
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
405 405
 		// can we freely update the TXN at this moment?
406
-		if ( $IPN && $transaction->is_locked() ) {
406
+		if ($IPN && $transaction->is_locked()) {
407 407
 			// don't update the transaction at this exact moment
408 408
 			// because the TXN is active in another request
409 409
 			EE_Cron_Tasks::schedule_update_transaction_with_payment(
@@ -413,45 +413,45 @@  discard block
 block discarded – undo
413 413
 			);
414 414
 		} else {
415 415
 			// verify payment and that it has been saved
416
-			if ( $payment instanceof EE_Payment && $payment->ID() ) {
417
-				if(
416
+			if ($payment instanceof EE_Payment && $payment->ID()) {
417
+				if (
418 418
 					$payment->payment_method() instanceof EE_Payment_Method
419 419
 					&& $payment->payment_method()->type_obj() instanceof EE_PMT_Base
420
-				){
421
-					$payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment );
420
+				) {
421
+					$payment->payment_method()->type_obj()->update_txn_based_on_payment($payment);
422 422
 					// update TXN registrations with payment info
423
-					$this->process_registration_payments( $transaction, $payment );
423
+					$this->process_registration_payments($transaction, $payment);
424 424
 				}
425 425
 				$do_action = $payment->just_approved()
426 426
 					? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful'
427 427
 					: $do_action;
428 428
 			} else {
429 429
 				// send out notifications
430
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
430
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
431 431
 				$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made';
432 432
 			}
433 433
 			// if this is an IPN, then we want to know the initial TXN status prior to updating the TXN
434 434
 			// so that we know whether the status has changed and notifications should be triggered
435
-			if ( $IPN ) {
435
+			if ($IPN) {
436 436
 				/** @type EE_Transaction_Processor $transaction_processor */
437
-				$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
438
-				$transaction_processor->set_old_txn_status( $transaction->status_ID() );
437
+				$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
438
+				$transaction_processor->set_old_txn_status($transaction->status_ID());
439 439
 			}
440
-			if ( $payment->status() !== EEM_Payment::status_id_failed ) {
440
+			if ($payment->status() !== EEM_Payment::status_id_failed) {
441 441
 				/** @type EE_Transaction_Payments $transaction_payments */
442
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
442
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
443 443
 				// set new value for total paid
444
-				$transaction_payments->calculate_total_payments_and_update_status( $transaction );
444
+				$transaction_payments->calculate_total_payments_and_update_status($transaction);
445 445
 				// call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ???
446
-				if ( $update_txn ) {
447
-					$this->_post_payment_processing( $transaction, $payment, $IPN );
446
+				if ($update_txn) {
447
+					$this->_post_payment_processing($transaction, $payment, $IPN);
448 448
 				}
449 449
 			}
450 450
 			// granular hook for others to use.
451
-			do_action( $do_action, $transaction, $payment );
452
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' );
451
+			do_action($do_action, $transaction, $payment);
452
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action');
453 453
 			//global hook for others to use.
454
-			do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment );
454
+			do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment);
455 455
 		}
456 456
 	}
457 457
 
@@ -471,25 +471,25 @@  discard block
 block discarded – undo
471 471
 		$registrations = array()
472 472
 	) {
473 473
 		// only process if payment was successful
474
-		if ( $payment->status() !== EEM_Payment::status_id_approved ) {
474
+		if ($payment->status() !== EEM_Payment::status_id_approved) {
475 475
 			return;
476 476
 		}
477 477
 		//EEM_Registration::instance()->show_next_x_db_queries();
478
-		if ( empty( $registrations )) {
478
+		if (empty($registrations)) {
479 479
 			// find registrations with monies owing that can receive a payment
480 480
 			$registrations = $transaction->registrations(
481 481
 				array(
482 482
 					array(
483 483
 						// only these reg statuses can receive payments
484
-						'STS_ID'           => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ),
485
-						'REG_final_price'  => array( '!=', 0 ),
486
-						'REG_final_price*' => array( '!=', 'REG_paid', true ),
484
+						'STS_ID'           => array('IN', EEM_Registration::reg_statuses_that_allow_payment()),
485
+						'REG_final_price'  => array('!=', 0),
486
+						'REG_final_price*' => array('!=', 'REG_paid', true),
487 487
 					)
488 488
 				)
489 489
 			);
490 490
 		}
491 491
 		// still nothing ??!??
492
-		if ( empty( $registrations )) {
492
+		if (empty($registrations)) {
493 493
 			return;
494 494
 		}
495 495
 		// todo: break out the following logic into a separate strategy class
@@ -501,28 +501,28 @@  discard block
 block discarded – undo
501 501
 
502 502
 		$refund = $payment->is_a_refund();
503 503
 		// how much is available to apply to registrations?
504
-		$available_payment_amount = abs( $payment->amount() );
505
-		foreach ( $registrations as $registration ) {
506
-			if ( $registration instanceof EE_Registration ) {
504
+		$available_payment_amount = abs($payment->amount());
505
+		foreach ($registrations as $registration) {
506
+			if ($registration instanceof EE_Registration) {
507 507
 				// nothing left?
508
-				if ( $available_payment_amount <= 0 ) {
508
+				if ($available_payment_amount <= 0) {
509 509
 					break;
510 510
 				}
511
-				if ( $refund ) {
512
-					$available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount );
511
+				if ($refund) {
512
+					$available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
513 513
 				} else {
514
-					$available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount );
514
+					$available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
515 515
 				}
516 516
 			}
517 517
 		}
518
-		if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) {
518
+		if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
519 519
 			EE_Error::add_attention(
520 520
 				sprintf(
521
-					__( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ),
522
-					EEH_Template::format_currency( $available_payment_amount ),
523
-					implode( ', ',  array_keys( $registrations ) ),
521
+					__('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'),
522
+					EEH_Template::format_currency($available_payment_amount),
523
+					implode(', ', array_keys($registrations)),
524 524
 					'<br/>',
525
-					EEH_Template::format_currency( $payment->amount() )
525
+					EEH_Template::format_currency($payment->amount())
526 526
 				),
527 527
 				__FILE__, __FUNCTION__, __LINE__
528 528
 			);
@@ -540,17 +540,17 @@  discard block
 block discarded – undo
540 540
 	 * @return float
541 541
 	 * @throws \EE_Error
542 542
 	 */
543
-	public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) {
543
+	public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) {
544 544
 		$owing = $registration->final_price() - $registration->paid();
545
-		if ( $owing > 0 ) {
545
+		if ($owing > 0) {
546 546
 			// don't allow payment amount to exceed the available payment amount, OR the amount owing
547
-			$payment_amount = min( $available_payment_amount, $owing );
547
+			$payment_amount = min($available_payment_amount, $owing);
548 548
 			// update $available_payment_amount
549 549
 			$available_payment_amount -= $payment_amount;
550 550
 			//calculate and set new REG_paid
551
-			$registration->set_paid( $registration->paid() + $payment_amount );
551
+			$registration->set_paid($registration->paid() + $payment_amount);
552 552
 			// now save it
553
-			$this->_apply_registration_payment( $registration, $payment, $payment_amount );
553
+			$this->_apply_registration_payment($registration, $payment, $payment_amount);
554 554
 		}
555 555
 		return $available_payment_amount;
556 556
 	}
@@ -566,19 +566,19 @@  discard block
 block discarded – undo
566 566
 	 * @return float
567 567
 	 * @throws \EE_Error
568 568
 	 */
569
-	protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) {
569
+	protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) {
570 570
 		// find any existing reg payment records for this registration and payment
571 571
 		$existing_reg_payment = EEM_Registration_Payment::instance()->get_one(
572
-			array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) )
572
+			array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID()))
573 573
 		);
574 574
 		// if existing registration payment exists
575
-		if ( $existing_reg_payment instanceof EE_Registration_Payment ) {
575
+		if ($existing_reg_payment instanceof EE_Registration_Payment) {
576 576
 			// then update that record
577
-			$existing_reg_payment->set_amount( $payment_amount );
577
+			$existing_reg_payment->set_amount($payment_amount);
578 578
 			$existing_reg_payment->save();
579 579
 		} else {
580 580
 			// or add new relation between registration and payment and set amount
581
-			$registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) );
581
+			$registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount));
582 582
 			// make it stick
583 583
 			$registration->save();
584 584
 		}
@@ -595,21 +595,21 @@  discard block
 block discarded – undo
595 595
 	 * @return float
596 596
 	 * @throws \EE_Error
597 597
 	 */
598
-	public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) {
598
+	public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) {
599 599
 		//EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ );
600
-		if ( $registration->paid() > 0 ) {
600
+		if ($registration->paid() > 0) {
601 601
 			// ensure $available_refund_amount is NOT negative
602
-			$available_refund_amount = (float)abs( $available_refund_amount );
602
+			$available_refund_amount = (float) abs($available_refund_amount);
603 603
 			// don't allow refund amount to exceed the available payment amount, OR the amount paid
604
-			$refund_amount = min( $available_refund_amount, (float)$registration->paid() );
604
+			$refund_amount = min($available_refund_amount, (float) $registration->paid());
605 605
 			// update $available_payment_amount
606 606
 			$available_refund_amount -= $refund_amount;
607 607
 			//calculate and set new REG_paid
608
-			$registration->set_paid( $registration->paid() - $refund_amount );
608
+			$registration->set_paid($registration->paid() - $refund_amount);
609 609
 			// convert payment amount back to a negative value for storage in the db
610
-			$refund_amount = (float)abs( $refund_amount ) * -1;
610
+			$refund_amount = (float) abs($refund_amount) * -1;
611 611
 			// now save it
612
-			$this->_apply_registration_payment( $registration, $payment, $refund_amount );
612
+			$this->_apply_registration_payment($registration, $payment, $refund_amount);
613 613
 		}
614 614
 		return $available_refund_amount;
615 615
 	}
@@ -628,21 +628,21 @@  discard block
 block discarded – undo
628 628
 	 * @param bool           $IPN
629 629
 	 * @throws \EE_Error
630 630
 	 */
631
-	protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) {
631
+	protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) {
632 632
 
633 633
 		/** @type EE_Transaction_Processor $transaction_processor */
634
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
634
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
635 635
 		// is the Payment Options Reg Step completed ?
636
-		$payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' );
636
+		$payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options');
637 637
 		// if the Payment Options Reg Step is completed...
638 638
 		$revisit = $payment_options_step_completed === true ? true : false;
639 639
 		// then this is kinda sorta a revisit with regards to payments at least
640
-		$transaction_processor->set_revisit( $revisit );
640
+		$transaction_processor->set_revisit($revisit);
641 641
 		// if this is an IPN, let's consider the Payment Options Reg Step completed if not already
642 642
 		if (
643 643
 			$IPN &&
644 644
 			$payment_options_step_completed !== true &&
645
-			( $payment->is_approved() || $payment->is_pending() )
645
+			($payment->is_approved() || $payment->is_pending())
646 646
 		) {
647 647
 			$payment_options_step_completed = $transaction_processor->set_reg_step_completed(
648 648
 				$transaction,
@@ -650,34 +650,34 @@  discard block
 block discarded – undo
650 650
 			);
651 651
 		}
652 652
 		/** @type EE_Transaction_Payments $transaction_payments */
653
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
653
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
654 654
 		// maybe update status, but don't save transaction just yet
655
-		$transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false );
655
+		$transaction_payments->update_transaction_status_based_on_total_paid($transaction, false);
656 656
 		// check if 'finalize_registration' step has been completed...
657
-		$finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' );
657
+		$finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration');
658 658
 		//  if this is an IPN and the final step has not been initiated
659
-		if ( $IPN && $payment_options_step_completed && $finalized === false ) {
659
+		if ($IPN && $payment_options_step_completed && $finalized === false) {
660 660
 			// and if it hasn't already been set as being started...
661
-			$finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' );
661
+			$finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration');
662 662
 		}
663 663
 		$transaction->save();
664 664
 		// because the above will return false if the final step was not fully completed, we need to check again...
665
-		if ( $IPN && $finalized !== false ) {
665
+		if ($IPN && $finalized !== false) {
666 666
 			// and if we are all good to go, then send out notifications
667
-			add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
667
+			add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
668 668
 			//ok, now process the transaction according to the payment
669
-			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment );
669
+			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment);
670 670
 		}
671 671
 		// DEBUG LOG
672 672
 		$payment_method = $payment->payment_method();
673
-		if ( $payment_method instanceof EE_Payment_Method ) {
673
+		if ($payment_method instanceof EE_Payment_Method) {
674 674
 			$payment_method_type_obj = $payment_method->type_obj();
675
-			if ( $payment_method_type_obj instanceof EE_PMT_Base ) {
675
+			if ($payment_method_type_obj instanceof EE_PMT_Base) {
676 676
 				$gateway = $payment_method_type_obj->get_gateway();
677
-				if ( $gateway instanceof EE_Gateway ){
677
+				if ($gateway instanceof EE_Gateway) {
678 678
 					$gateway->log(
679 679
 						array(
680
-							'message'               => __( 'Post Payment Transaction Details', 'event_espresso' ),
680
+							'message'               => __('Post Payment Transaction Details', 'event_espresso'),
681 681
 							'transaction'           => $transaction->model_field_array(),
682 682
 							'finalized'             => $finalized,
683 683
 							'IPN'                   => $IPN,
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 						__FILE__, __FUNCTION__, __LINE__
235 235
 					);
236 236
 				}
237
-			}else{
237
+			} else{
238 238
 				//that's actually pretty ok. The IPN just wasn't able
239 239
 				//to identify which transaction or payment method this was for
240 240
 				// give all active payment methods a chance to claim it
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 				$payment->save();
259 259
 				//  update the TXN
260 260
 				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request );
261
-			}else{
261
+			} else{
262 262
 				//we couldn't find the payment for this IPN... let's try and log at least SOMETHING
263 263
 				if($payment_method){
264 264
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method);
265
-				}elseif($transaction){
265
+				} elseif($transaction){
266 266
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction);
267 267
 				}
268 268
 			}
Please login to merge, or discard this patch.
core/db_classes/EE_Base_Class.class.php 4 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -47,25 +47,25 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 	/**
50
-    *	date format
51
-	*
52
-    *	pattern or format for displaying dates
53
-	*
54
-	*	@access	protected
55
-    *	@var string
56
-    */
50
+	 *	date format
51
+	 *
52
+	 *	pattern or format for displaying dates
53
+	 *
54
+	 *	@access	protected
55
+	 *	@var string
56
+	 */
57 57
 	protected $_dt_frmt;
58 58
 
59 59
 
60 60
 
61
-    /**
62
-    *	time format
63
-	*
64
-    *	pattern or format for displaying time
65
-	*
66
-	*	@access	protected
67
-    *	@var string
68
-    */
61
+	/**
62
+	 *	time format
63
+	 *
64
+	 *	pattern or format for displaying time
65
+	 *
66
+	 *	@access	protected
67
+	 *	@var string
68
+	 */
69 69
 	protected $_tm_frmt;
70 70
 
71 71
 
@@ -1420,24 +1420,24 @@  discard block
 block discarded – undo
1420 1420
 	 *
1421 1421
 	 * @throws \EE_Error
1422 1422
 	 */
1423
-        public function refresh_cache_of_related_objects() {
1424
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1425
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1426
-                    $related_objects = $this->_model_relations[ $relation_name ];
1427
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1428
-                        //this relation only stores a single model object, not an array
1429
-                        //but let's make it consistent
1430
-                        $related_objects = array( $related_objects );
1431
-                    }
1432
-                    foreach( $related_objects as $related_object ) {
1433
-                        //only refresh their cache if they're in memory
1434
-                        if( $related_object instanceof EE_Base_Class ) {
1423
+		public function refresh_cache_of_related_objects() {
1424
+			foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1425
+				if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1426
+					$related_objects = $this->_model_relations[ $relation_name ];
1427
+					if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1428
+						//this relation only stores a single model object, not an array
1429
+						//but let's make it consistent
1430
+						$related_objects = array( $related_objects );
1431
+					}
1432
+					foreach( $related_objects as $related_object ) {
1433
+						//only refresh their cache if they're in memory
1434
+						if( $related_object instanceof EE_Base_Class ) {
1435 1435
 							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1436
-                        }
1437
-                    }
1438
-                }
1439
-            }
1440
-        }
1436
+						}
1437
+					}
1438
+				}
1439
+			}
1440
+		}
1441 1441
 
1442 1442
 
1443 1443
 
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
 		if ( self::_get_model( $classname )->has_primary_key_field() ) {
1679 1679
 			$primary_id_ref = self::_get_primary_key_name( $classname );
1680 1680
 			if ( array_key_exists( $primary_id_ref, $props_n_values )
1681
-			     && ! empty( $props_n_values[ $primary_id_ref ] )
1681
+				 && ! empty( $props_n_values[ $primary_id_ref ] )
1682 1682
 			) {
1683 1683
 				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1684 1684
 					$props_n_values[ $primary_id_ref ]
@@ -1830,9 +1830,9 @@  discard block
 block discarded – undo
1830 1830
 			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1831 1831
 			//clear cache so future get_many_related and get_first_related() return new results.
1832 1832
 			$this->clear_cache( $relationName, $otherObject, TRUE );
1833
-                        if( $otherObject instanceof EE_Base_Class ) {
1834
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1835
-                        }
1833
+						if( $otherObject instanceof EE_Base_Class ) {
1834
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1835
+						}
1836 1836
 		} else {
1837 1837
 			//this thing doesn't exist in the DB,  so just cache it
1838 1838
 			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
@@ -1846,18 +1846,18 @@  discard block
 block discarded – undo
1846 1846
 			}
1847 1847
 			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1848 1848
 		}
1849
-                if( $otherObject instanceof EE_Base_Class ) {
1850
-                    //fix the reciprocal relation too
1851
-                    if( $otherObject->ID() ) {
1852
-                            //its saved so assumed relations exist in the DB, so we can just
1853
-                            //clear the cache so future queries use the updated info in the DB
1854
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1855
-                    } else {
1856
-
1857
-                            //it's not saved, so it caches relations like this
1858
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1859
-                    }
1860
-                }
1849
+				if( $otherObject instanceof EE_Base_Class ) {
1850
+					//fix the reciprocal relation too
1851
+					if( $otherObject->ID() ) {
1852
+							//its saved so assumed relations exist in the DB, so we can just
1853
+							//clear the cache so future queries use the updated info in the DB
1854
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1855
+					} else {
1856
+
1857
+							//it's not saved, so it caches relations like this
1858
+							$otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1859
+					}
1860
+				}
1861 1861
 		return $otherObject;
1862 1862
 	}
1863 1863
 
@@ -1888,9 +1888,9 @@  discard block
 block discarded – undo
1888 1888
 			//this doesn't exist in the DB, just remove it from the cache
1889 1889
 			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1890 1890
 		}
1891
-                if( $otherObject instanceof EE_Base_Class ) {
1892
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1893
-                }
1891
+				if( $otherObject instanceof EE_Base_Class ) {
1892
+					$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1893
+				}
1894 1894
 		return $otherObject;
1895 1895
 	}
1896 1896
 
@@ -1913,11 +1913,11 @@  discard block
 block discarded – undo
1913 1913
 			//this doesn't exist in the DB, just remove it from the cache
1914 1914
 			$otherObjects = $this->clear_cache( $relationName, null, true );
1915 1915
 		}
1916
-                if( is_array( $otherObjects ) ) {
1917
-                    foreach ( $otherObjects as $otherObject ) {
1918
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1919
-                    }
1920
-                }
1916
+				if( is_array( $otherObjects ) ) {
1917
+					foreach ( $otherObjects as $otherObject ) {
1918
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1919
+					}
1920
+				}
1921 1921
 		return $otherObjects;
1922 1922
 	}
1923 1923
 
Please login to merge, or discard this patch.
Braces   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171 171
 			if($relation_obj instanceof EE_Belongs_To_Relation){
172 172
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
173
+			} else{
174 174
 				$this->_model_relations[$relation_name] = array();
175 175
 			}
176 176
 		}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
217 217
 				$field_settings = $this->get_model()->field_settings_for( $field_name )){
218 218
 			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
219
-		}else{
219
+		} else{
220 220
 			return NULL;
221 221
 		}
222 222
 	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 						: $this->set( $field_name, $this->_fields[$field_name] );
274 274
 				}
275 275
 
276
-			}else{
276
+			} else{
277 277
 				$this->_fields[$field_name] = $holder_of_value;
278 278
 			}
279 279
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 			}
305 305
 			//let's unset any cache for this field_name from the $_cached_properties property.
306 306
 			$this->_clear_cached_property( $field_name );
307
-		}else{
307
+		} else{
308 308
 			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
309 309
 		}
310 310
 
@@ -653,10 +653,10 @@  discard block
 block discarded – undo
653 653
 		if($clear_all){
654 654
 			$obj_removed = true;
655 655
 			$this->_model_relations[$relationName]  = null;
656
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
656
+		} elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
657 657
 			$obj_removed = $this->_model_relations[$relationName];
658 658
 			$this->_model_relations[$relationName]  = null;
659
-		}else{
659
+		} else{
660 660
 			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
661 661
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
662 662
 				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
@@ -676,20 +676,20 @@  discard block
 block discarded – undo
676 676
 					}
677 677
 					if($index_found_at){
678 678
 						$index_in_cache = $index_found_at;
679
-					}else{
679
+					} else{
680 680
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
681 681
 						//if it wasn't in it to begin with. So we're done
682 682
 						return $object_to_remove_or_index_into_array;
683 683
 					}
684 684
 				}
685
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
685
+			} elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
686 686
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
687 687
 				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
688 688
 					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
689 689
 						$index_in_cache = $index;
690 690
 					}
691 691
 				}
692
-			}else{
692
+			} else{
693 693
 				$index_in_cache = $object_to_remove_or_index_into_array;
694 694
 			}
695 695
 			//supposedly we've found it. But it could just be that the client code
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
760 760
 		if(is_array($cached_array_or_object)){
761 761
 			return array_shift($cached_array_or_object);
762
-		}else{
762
+		} else{
763 763
 			return $cached_array_or_object;
764 764
 		}
765 765
 	}
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 				if( $model_object->ID() ){
791 791
 					$model->add_to_entity_map( $model_object );
792 792
 				}
793
-			}else{
793
+			} else{
794 794
 				throw new EE_Error(
795 795
 					sprintf(
796 796
 						__(
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
 				if( $field_obj->is_nullable()){
926 926
 					//if the field allows nulls, then let it be null
927 927
 					$field_value = NULL;
928
-				}else{
928
+				} else{
929 929
 					$field_value = $field_obj->get_default_value();
930 930
 				}
931
-			}else{
931
+			} else{
932 932
 				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
933 933
 			}
934 934
 			$this->_fields[$field_name] = $field_value;
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 						$this->_update_cached_related_model_objs_fks();
1514 1514
 					}
1515 1515
 				}
1516
-			}else{//PK is NOT auto-increment
1516
+			} else{//PK is NOT auto-increment
1517 1517
 				//so check if one like it already exists in the db
1518 1518
 				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1519 1519
 					if( WP_DEBUG && ! $this->in_entity_map() ){
@@ -1528,12 +1528,12 @@  discard block
 block discarded – undo
1528 1528
 						);
1529 1529
 					}
1530 1530
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1531
-				}else{
1531
+				} else{
1532 1532
 					$results = $this->get_model()->insert($save_cols_n_values);
1533 1533
 					$this->_update_cached_related_model_objs_fks();
1534 1534
 				}
1535 1535
 			}
1536
-		}else{//there is NO primary key
1536
+		} else{//there is NO primary key
1537 1537
 			$already_in_db = false;
1538 1538
 			foreach($this->get_model()->unique_indexes() as $index){
1539 1539
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 			if( $already_in_db ){
1545 1545
 				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1546 1546
 				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1547
-			}else{
1547
+			} else{
1548 1548
 				$results = $this->get_model()->insert( $save_cols_n_values );
1549 1549
 			}
1550 1550
 		}
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 		//make sure this has been saved
1607 1607
 		if( ! $this->ID()){
1608 1608
 			$id = $this->save();
1609
-		}else{
1609
+		} else{
1610 1610
 			$id = $this->ID();
1611 1611
 		}
1612 1612
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 						$this->_add_relation_to($related_model_obj, $relationName);
1626 1626
 						$related_model_obj->save_new_cached_related_model_objs();
1627 1627
 //					}
1628
-				}else{
1628
+				} else{
1629 1629
 					foreach($this->_model_relations[$relationName] as $related_model_obj){
1630 1630
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1631 1631
 						//but ONLY if it DOES NOT exist in the DB
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 	private static function _get_model_classname( $model_name = null){
1775 1775
 		if(strpos($model_name,"EE_")===0){
1776 1776
 			$model_classname=str_replace("EE_","EEM_",$model_name);
1777
-		}else{
1777
+		} else{
1778 1778
 			$model_classname = "EEM_".$model_name;
1779 1779
 		}
1780 1780
 		return $model_classname;
@@ -1815,7 +1815,7 @@  discard block
 block discarded – undo
1815 1815
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1816 1816
 		if( $this->get_model()->has_primary_key_field() ) {
1817 1817
 			return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ];
1818
-		}else{
1818
+		} else{
1819 1819
 			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1820 1820
 		}
1821 1821
 	}
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 			//if there are query parameters, forget about caching the related model objects.
1952 1952
 			if( $query_params ){
1953 1953
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1954
-			}else{
1954
+			} else{
1955 1955
 				//did we already cache the result of this query?
1956 1956
 				$cached_results = $this->get_all_from_cache($relationName);
1957 1957
 				if ( ! $cached_results ){
@@ -1961,11 +1961,11 @@  discard block
 block discarded – undo
1961 1961
 					foreach($related_model_objects as $related_model_object){
1962 1962
 						$this->cache($relationName, $related_model_object);
1963 1963
 					}
1964
-				}else{
1964
+				} else{
1965 1965
 					$related_model_objects = $cached_results;
1966 1966
 				}
1967 1967
 			}
1968
-		}else{
1968
+		} else{
1969 1969
 			//this doesn't exist in the DB, so just get the related things from the cache
1970 1970
 			$related_model_objects = $this->get_all_from_cache($relationName);
1971 1971
 		}
@@ -2020,18 +2020,18 @@  discard block
 block discarded – undo
2020 2020
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
2021 2021
 			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2022 2022
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2023
-			}else{
2023
+			} else{
2024 2024
 				//first, check if we've already cached the result of this query
2025 2025
 				$cached_result = $this->get_one_from_cache($relationName);
2026 2026
 				if ( ! $cached_result ){
2027 2027
 
2028 2028
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2029 2029
 					$this->cache($relationName,$related_model_object);
2030
-				}else{
2030
+				} else{
2031 2031
 					$related_model_object = $cached_result;
2032 2032
 				}
2033 2033
 			}
2034
-		}else{
2034
+		} else{
2035 2035
 			$related_model_object = null;
2036 2036
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
2037 2037
 			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 	public function delete_related($relationName,$query_params = array()){
2064 2064
 		if($this->ID()){
2065 2065
 			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
2066
-		}else{
2066
+		} else{
2067 2067
 			$count = count($this->get_all_from_cache($relationName));
2068 2068
 			$this->clear_cache($relationName,NULL,TRUE);
2069 2069
 		}
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
 	public function delete_related_permanently($relationName,$query_params = array()){
2088 2088
 		if($this->ID()){
2089 2089
 			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2090
-		}else{
2090
+		} else{
2091 2091
 			$count = count($this->get_all_from_cache($relationName));
2092 2092
 		}
2093 2093
 		$this->clear_cache($relationName,NULL,TRUE);
@@ -2317,10 +2317,10 @@  discard block
 block discarded – undo
2317 2317
 			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2318 2318
 			if ( $result instanceof EE_Extra_Meta ){
2319 2319
 				return $result->value();
2320
-			}else{
2320
+			} else{
2321 2321
 				return $default;
2322 2322
 			}
2323
-		}else{
2323
+		} else{
2324 2324
 			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2325 2325
 			if($results){
2326 2326
 				$values = array();
@@ -2330,7 +2330,7 @@  discard block
 block discarded – undo
2330 2330
 					}
2331 2331
 				}
2332 2332
 				return $values;
2333
-			}else{
2333
+			} else{
2334 2334
 				return $default;
2335 2335
 			}
2336 2336
 		}
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2362 2362
 				}
2363 2363
 			}
2364
-		}else{
2364
+		} else{
2365 2365
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2366 2366
 			foreach($extra_meta_objs as $extra_meta_obj){
2367 2367
 				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2389 2389
 		if($field_we_can_use){
2390 2390
 			return $this->get($field_we_can_use->get_name());
2391
-		}else{
2391
+		} else{
2392 2392
 			$first_few_properties = $this->model_field_array();
2393 2393
 			$first_few_properties = array_slice($first_few_properties,0,3);
2394 2394
 			$name_parts = array();
@@ -2412,7 +2412,7 @@  discard block
 block discarded – undo
2412 2412
 		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2413 2413
 			//well, if we looked, did we find it in the entity map?
2414 2414
 			return TRUE;
2415
-		}else{
2415
+		} else{
2416 2416
 			return FALSE;
2417 2417
 		}
2418 2418
 	}
@@ -2426,7 +2426,7 @@  discard block
 block discarded – undo
2426 2426
 	public function refresh_from_db(){
2427 2427
 		if( $this->ID() && $this->in_entity_map() ){
2428 2428
 			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2429
-		}else{
2429
+		} else{
2430 2430
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2431 2431
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2432 2432
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
Please login to merge, or discard this patch.
Spacing   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2
-do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2
+do_action('AHEE_log', __FILE__, ' FILE LOADED', '');
3 3
 /**
4 4
  *
5 5
  * Event Espresso
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -117,59 +117,59 @@  discard block
 block discarded – undo
117 117
 	 * @throws EE_Error
118 118
 	 * @return \EE_Base_Class
119 119
 	 */
120
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
120
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
121 121
 
122
-		$className=get_class($this);
122
+		$className = get_class($this);
123 123
 
124
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
125
-		$model=$this->get_model();
126
-		$model_fields = $model->field_settings( FALSE );
124
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
125
+		$model = $this->get_model();
126
+		$model_fields = $model->field_settings(FALSE);
127 127
 		// ensure $fieldValues is an array
128
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
128
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
129 129
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
130 130
 		// verify client code has not passed any invalid field names
131
-		foreach($fieldValues as $field_name=> $field_value){
132
-			if( ! isset( $model_fields[ $field_name] ) ){
133
-				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields))));
131
+		foreach ($fieldValues as $field_name=> $field_value) {
132
+			if ( ! isset($model_fields[$field_name])) {
133
+				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields))));
134 134
 			}
135 135
 		}
136 136
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
137
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
137
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
138 138
 
139
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
139
+		if ( ! empty($date_formats) && is_array($date_formats)) {
140 140
 			$this->_dt_frmt = $date_formats[0];
141 141
 			$this->_tm_frmt = $date_formats[1];
142 142
 		} else {
143 143
 			//set default formats for date and time
144
-			$this->_dt_frmt = get_option( 'date_format' );
145
-			$this->_tm_frmt = get_option( 'time_format' );
144
+			$this->_dt_frmt = get_option('date_format');
145
+			$this->_tm_frmt = get_option('time_format');
146 146
 		}
147 147
 
148 148
 		//if db model is instantiating
149
-		if ( $bydb ){
149
+		if ($bydb) {
150 150
 			//client code has indicated these field values are from the database
151
-			foreach( $model_fields as $fieldName => $field ){
152
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
151
+			foreach ($model_fields as $fieldName => $field) {
152
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
153 153
 			}
154 154
 		} else {
155 155
 			//we're constructing a brand
156 156
 			//new instance of the model object. Generally, this means we'll need to do more field validation
157
-			foreach( $model_fields as $fieldName => $field ){
158
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
157
+			foreach ($model_fields as $fieldName => $field) {
158
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
159 159
 			}
160 160
 		}
161 161
 
162 162
 		//remember what values were passed to this constructor
163 163
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
164 164
 		//remember in entity mapper
165
-		if( ! $bydb  && $model->has_primary_key_field() && $this->ID() ){
165
+		if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) {
166 166
 			$model->add_to_entity_map($this);
167 167
 		}
168 168
 		//setup all the relations
169
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
170
-			if($relation_obj instanceof EE_Belongs_To_Relation){
169
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
170
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
171 171
 				$this->_model_relations[$relation_name] = NULL;
172
-			}else{
172
+			} else {
173 173
 				$this->_model_relations[$relation_name] = array();
174 174
 			}
175 175
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * Action done at the end of each model object construction
178 178
 		 * @param EE_Base_Class $this the model object just created
179 179
 		 */
180
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
180
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
181 181
 	}
182 182
 
183 183
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param boolean $allow_persist
198 198
 	 * @return boolean
199 199
 	 */
200
-	public function set_allow_persist( $allow_persist ) {
200
+	public function set_allow_persist($allow_persist) {
201 201
 		return $this->_allow_persist = $allow_persist;
202 202
 	}
203 203
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @return mixed|null
212 212
 	 * @throws \EE_Error
213 213
 	 */
214
-	public function get_original( $field_name ){
215
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216
-				$field_settings = $this->get_model()->field_settings_for( $field_name )){
217
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
214
+	public function get_original($field_name) {
215
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
216
+				$field_settings = $this->get_model()->field_settings_for($field_name)) {
217
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
218
+		} else {
219 219
 			return NULL;
220 220
 		}
221 221
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Base_Class $obj
226 226
 	 * @return string
227 227
 	 */
228
-	public function get_class($obj){
228
+	public function get_class($obj) {
229 229
 		return get_class($obj);
230 230
 	}
231 231
 
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
 	 * @param bool      $use_default
241 241
 	 * @throws \EE_Error
242 242
 	 */
243
-	public function set( $field_name, $field_value, $use_default = FALSE ){
244
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
245
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
243
+	public function set($field_name, $field_value, $use_default = FALSE) {
244
+		$field_obj = $this->get_model()->field_settings_for($field_name);
245
+		if ($field_obj instanceof EE_Model_Field_Base) {
246 246
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
247
-			if ( $field_obj instanceof EE_Datetime_Field ) {
248
-				$field_obj->set_timezone( $this->_timezone );
249
-				$field_obj->set_date_format( $this->_dt_frmt );
250
-				$field_obj->set_time_format( $this->_tm_frmt );
247
+			if ($field_obj instanceof EE_Datetime_Field) {
248
+				$field_obj->set_timezone($this->_timezone);
249
+				$field_obj->set_date_format($this->_dt_frmt);
250
+				$field_obj->set_time_format($this->_tm_frmt);
251 251
 			}
252 252
 
253 253
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
254 254
 			//should the value be null?
255
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
255
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
256 256
 				$this->_fields[$field_name] = $field_obj->get_default_value();
257 257
 
258 258
 				/**
@@ -264,26 +264,26 @@  discard block
 block discarded – undo
264 264
 				 */
265 265
 				if (
266 266
 					$field_obj instanceof EE_Datetime_Field
267
-					&& $this->_fields[ $field_name ] !== null
267
+					&& $this->_fields[$field_name] !== null
268 268
 					&& ! $this->_fields[$field_name] instanceof DateTime
269 269
 				) {
270
-					empty( $this->_fields[$field_name] )
271
-						? $this->set( $field_name, time() )
272
-						: $this->set( $field_name, $this->_fields[$field_name] );
270
+					empty($this->_fields[$field_name])
271
+						? $this->set($field_name, time())
272
+						: $this->set($field_name, $this->_fields[$field_name]);
273 273
 				}
274 274
 
275
-			}else{
275
+			} else {
276 276
 				$this->_fields[$field_name] = $holder_of_value;
277 277
 			}
278 278
 
279 279
 			//if we're not in the constructor...
280 280
 			//now check if what we set was a primary key
281
-			if(
281
+			if (
282 282
 				//note: props_n_values_provided_in_constructor is only set at the END of the constructor
283 283
 				$this->_props_n_values_provided_in_constructor
284 284
 				&& $field_value
285
-				&& $field_name === self::_get_primary_key_name( get_class( $this ) )
286
-			){
285
+				&& $field_name === self::_get_primary_key_name(get_class($this))
286
+			) {
287 287
 				//if so, we want all this object's fields to be filled either with
288 288
 				//what we've explicitly set on this model
289 289
 				//or what we have in the db
@@ -291,20 +291,20 @@  discard block
 block discarded – undo
291 291
 				$fields_on_model = self::_get_model(get_class($this))->field_settings();
292 292
 
293 293
 				$obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value);
294
-				foreach($fields_on_model as $field_obj){
295
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
296
-						&& $field_obj->get_name() !== $field_name ){
294
+				foreach ($fields_on_model as $field_obj) {
295
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
296
+						&& $field_obj->get_name() !== $field_name) {
297 297
 
298
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
298
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
299 299
 					}
300 300
 				}
301 301
 				//oh this model object has an ID? well make sure its in the entity mapper
302 302
 				$this->get_model()->add_to_entity_map($this);
303 303
 			}
304 304
 			//let's unset any cache for this field_name from the $_cached_properties property.
305
-			$this->_clear_cached_property( $field_name );
306
-		}else{
307
-			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
305
+			$this->_clear_cached_property($field_name);
306
+		} else {
307
+			throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name));
308 308
 		}
309 309
 
310 310
 	}
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 	 * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs.
322 322
 	 * @throws \EE_Error
323 323
 	 */
324
-	public function set_field_or_extra_meta( $field_name, $field_value ) {
325
-		if ( $this->get_model()->has_field( $field_name ) ) {
326
-			$this->set( $field_name, $field_value );
324
+	public function set_field_or_extra_meta($field_name, $field_value) {
325
+		if ($this->get_model()->has_field($field_name)) {
326
+			$this->set($field_name, $field_value);
327 327
 			return true;
328 328
 		} else {
329 329
 			//ensure this object is saved first so that extra meta can be properly related.
330 330
 			$this->save();
331
-			return $this->update_extra_meta( $field_name, $field_value );
331
+			return $this->update_extra_meta($field_name, $field_value);
332 332
 		}
333 333
 	}
334 334
 
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 	 * @return mixed|null  value for the field if found.  null if not found.
350 350
 	 * @throws \EE_Error
351 351
 	 */
352
-	public function get_field_or_extra_meta( $field_name ) {
353
-		if ( $this->get_model()->has_field( $field_name ) ) {
354
-			$column_value = $this->get( $field_name );
352
+	public function get_field_or_extra_meta($field_name) {
353
+		if ($this->get_model()->has_field($field_name)) {
354
+			$column_value = $this->get($field_name);
355 355
 		} else {
356 356
 			//This isn't a column in the main table, let's see if it is in the extra meta.
357
-			$column_value = $this->get_extra_meta( $field_name, true, null );
357
+			$column_value = $this->get_extra_meta($field_name, true, null);
358 358
 		}
359 359
 		return $column_value;
360 360
 	}
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
 	 * @return void
371 371
 	 * @throws \EE_Error
372 372
 	 */
373
-	public function set_timezone( $timezone = '' ) {
374
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
373
+	public function set_timezone($timezone = '') {
374
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
375 375
 		//make sure we clear all cached properties because they won't be relevant now
376 376
 		$this->_clear_cached_properties();
377 377
 
378 378
 		//make sure we update field settings and the date for all EE_Datetime_Fields
379
-		$model_fields = $this->get_model()->field_settings( false );
380
-		foreach ( $model_fields as $field_name => $field_obj ) {
381
-			if ( $field_obj instanceof EE_Datetime_Field ) {
382
-				$field_obj->set_timezone( $this->_timezone );
383
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
384
-					$this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) );
379
+		$model_fields = $this->get_model()->field_settings(false);
380
+		foreach ($model_fields as $field_name => $field_obj) {
381
+			if ($field_obj instanceof EE_Datetime_Field) {
382
+				$field_obj->set_timezone($this->_timezone);
383
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
384
+					$this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone));
385 385
 				}
386 386
 			}
387 387
 		}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @param string $format   should be a format recognizable by PHP date() functions.
412 412
 	 */
413
-	public function set_date_format( $format ) {
413
+	public function set_date_format($format) {
414 414
 		$this->_dt_frmt = $format;
415 415
 		//clear cached_properties because they won't be relevant now.
416 416
 		$this->_clear_cached_properties();
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @since 4.6
427 427
 	 * @param string $format should be a format recognizable by PHP date() functions.
428 428
 	 */
429
-	public function set_time_format( $format ) {
429
+	public function set_time_format($format) {
430 430
 		$this->_tm_frmt = $format;
431 431
 		//clear cached_properties because they won't be relevant now.
432 432
 		$this->_clear_cached_properties();
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @return mixed string|array
445 445
 	 */
446
-	public function get_format( $full = true ) {
447
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
446
+	public function get_format($full = true) {
447
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
448 448
 	}
449 449
 
450 450
 
@@ -462,17 +462,17 @@  discard block
 block discarded – undo
462 462
 	 * @throws EE_Error
463 463
 	 * @return mixed    index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array)
464 464
 	 */
465
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
465
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
466 466
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
467
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
467
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
468 468
 			return FALSE;
469 469
 		}
470 470
 		// also get "how" the object is related, or throw an error
471
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
472
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
471
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
472
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
473 473
 		}
474 474
 		// how many things are related ?
475
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
475
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
476 476
 			// if it's a "belongs to" relationship, then there's only one related model object  eg, if this is a registration, there's only 1 attendee for it
477 477
 			// so for these model objects just set it to be cached
478 478
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -480,26 +480,26 @@  discard block
 block discarded – undo
480 480
 		} else {
481 481
 			// otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type.
482 482
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
483
-			if( ! is_array( $this->_model_relations[$relationName] )) {
483
+			if ( ! is_array($this->_model_relations[$relationName])) {
484 484
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
485
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
485
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
486 486
 			}
487 487
 			// first check for a cache_id which is normally empty
488
-			if ( ! empty( $cache_id )) {
488
+			if ( ! empty($cache_id)) {
489 489
 				// if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on
490
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
490
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
491 491
 				$return = $cache_id;
492
-			} elseif ( $object_to_cache->ID() ) {
492
+			} elseif ($object_to_cache->ID()) {
493 493
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
494
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
494
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
495 495
 				$return = $object_to_cache->ID();
496 496
 			} else {
497 497
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
498 498
 				$this->_model_relations[$relationName][] = $object_to_cache;
499 499
 				  // move the internal pointer to the end of the array
500
-				end( $this->_model_relations[$relationName] );
500
+				end($this->_model_relations[$relationName]);
501 501
 				// and grab the key so that we can return it
502
-				$return = key( $this->_model_relations[$relationName] );
502
+				$return = key($this->_model_relations[$relationName]);
503 503
 			}
504 504
 
505 505
 		}
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	 * @return void
519 519
 	 * @throws \EE_Error
520 520
 	 */
521
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
521
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
522 522
 		//first make sure this property exists
523 523
 		$this->get_model()->field_settings_for($fieldname);
524 524
 
525
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
525
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
526 526
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
527 527
 	}
528 528
 
@@ -543,36 +543,36 @@  discard block
 block discarded – undo
543 543
 	 * @return mixed                   whatever the value for the property is we're retrieving
544 544
 	 * @throws \EE_Error
545 545
 	 */
546
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
546
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
547 547
 		//verify the field exists
548 548
 		$this->get_model()->field_settings_for($fieldname);
549 549
 
550 550
 		$cache_type = $pretty ? 'pretty' : 'standard';
551
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
551
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
552 552
 
553
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
553
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
554 554
 			return $this->_cached_properties[$fieldname][$cache_type];
555 555
 		}
556 556
 
557 557
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
558
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
558
+		if ($field_obj instanceof EE_Model_Field_Base) {
559 559
 			/**
560 560
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
561 561
 			 * formats are correct.
562 562
 			 */
563
-			if ( $field_obj instanceof EE_Datetime_Field ) {
564
-				$field_obj->set_timezone( $this->_timezone );
565
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
566
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
563
+			if ($field_obj instanceof EE_Datetime_Field) {
564
+				$field_obj->set_timezone($this->_timezone);
565
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
566
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
567 567
 			}
568 568
 
569
-			if( ! isset($this->_fields[$fieldname])){
569
+			if ( ! isset($this->_fields[$fieldname])) {
570 570
 				$this->_fields[$fieldname] = NULL;
571 571
 			}
572 572
 			$value = $pretty
573 573
 				? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref)
574
-				: $field_obj->prepare_for_get($this->_fields[$fieldname] );
575
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
574
+				: $field_obj->prepare_for_get($this->_fields[$fieldname]);
575
+			$this->_set_cached_property($fieldname, $value, $cache_type);
576 576
 			return $value;
577 577
 		}
578 578
 		return null;
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
599 599
 	 * @return void
600 600
 	 */
601
-	protected function _clear_cached_property( $property_name ) {
602
-		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
603
-			unset( $this->_cached_properties[ $property_name ] );
601
+	protected function _clear_cached_property($property_name) {
602
+		if (isset($this->_cached_properties[$property_name])) {
603
+			unset($this->_cached_properties[$property_name]);
604 604
 		}
605 605
 	}
606 606
 
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
 	 * @return EE_Base_Class
615 615
 	 * @throws \EE_Error
616 616
 	 */
617
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
617
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
618 618
 		$other_model_instance = self::_get_model_instance_with_name(
619
-			self::_get_model_classname( $model_name ),
619
+			self::_get_model_classname($model_name),
620 620
 			$this->_timezone
621 621
 		);
622
-		return $other_model_instance->ensure_is_obj( $object_or_id );
622
+		return $other_model_instance->ensure_is_obj($object_or_id);
623 623
 	}
624 624
 
625 625
 
@@ -636,32 +636,32 @@  discard block
 block discarded – undo
636 636
 	 * @throws EE_Error
637 637
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
638 638
 	 */
639
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
639
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
640 640
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
641 641
 		$index_in_cache = '';
642
-		if( ! $relationship_to_model){
642
+		if ( ! $relationship_to_model) {
643 643
 			throw new EE_Error(
644 644
 				sprintf(
645
-					__( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ),
645
+					__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'),
646 646
 					$relationName,
647
-					get_class( $this )
647
+					get_class($this)
648 648
 				)
649 649
 			);
650 650
 		}
651
-		if($clear_all){
651
+		if ($clear_all) {
652 652
 			$obj_removed = true;
653 653
 			$this->_model_relations[$relationName]  = null;
654
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
654
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
655 655
 			$obj_removed = $this->_model_relations[$relationName];
656 656
 			$this->_model_relations[$relationName]  = null;
657
-		}else{
658
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
657
+		} else {
658
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
659 659
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
660
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
660
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
661 661
 					$index_found_at = NULL;
662 662
 					//find this object in the array even though it has a different key
663
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
664
-						if(
663
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
664
+						if (
665 665
 							$obj instanceof EE_Base_Class
666 666
 							&& (
667 667
 								$obj == $object_to_remove_or_index_into_array
@@ -672,34 +672,34 @@  discard block
 block discarded – undo
672 672
 							break;
673 673
 						}
674 674
 					}
675
-					if($index_found_at){
675
+					if ($index_found_at) {
676 676
 						$index_in_cache = $index_found_at;
677
-					}else{
677
+					} else {
678 678
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
679 679
 						//if it wasn't in it to begin with. So we're done
680 680
 						return $object_to_remove_or_index_into_array;
681 681
 					}
682 682
 				}
683
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
683
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
684 684
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
685
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
686
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
685
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
686
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
687 687
 						$index_in_cache = $index;
688 688
 					}
689 689
 				}
690
-			}else{
690
+			} else {
691 691
 				$index_in_cache = $object_to_remove_or_index_into_array;
692 692
 			}
693 693
 			//supposedly we've found it. But it could just be that the client code
694 694
 			//provided a bad index/object
695 695
 			if (
696 696
 				isset(
697
-					$this->_model_relations[ $relationName ],
698
-					$this->_model_relations[ $relationName ][ $index_in_cache ]
697
+					$this->_model_relations[$relationName],
698
+					$this->_model_relations[$relationName][$index_in_cache]
699 699
 				)
700 700
 			) {
701
-				$obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ];
702
-				unset( $this->_model_relations[ $relationName ][ $index_in_cache ] );
701
+				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
702
+				unset($this->_model_relations[$relationName][$index_in_cache]);
703 703
 			} else {
704 704
 				//that thing was never cached anyways.
705 705
 				$obj_removed = null;
@@ -720,24 +720,24 @@  discard block
 block discarded – undo
720 720
 	 * @return boolean TRUE on success, FALSE on fail
721 721
 	 * @throws \EE_Error
722 722
 	 */
723
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
723
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
724 724
 		// verify that incoming object is of the correct type
725
-		$obj_class = 'EE_' . $relationName;
726
-		if ( $newly_saved_object instanceof $obj_class ) {
725
+		$obj_class = 'EE_'.$relationName;
726
+		if ($newly_saved_object instanceof $obj_class) {
727 727
 			/* @type EE_Base_Class $newly_saved_object*/
728 728
 			// now get the type of relation
729
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
729
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
730 730
 			// if this is a 1:1 relationship
731
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
731
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
732 732
 				// then just replace the cached object with the newly saved object
733 733
 				$this->_model_relations[$relationName] = $newly_saved_object;
734 734
 				return TRUE;
735 735
 			// or if it's some kind of sordid feral polyamorous relationship...
736
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
736
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
737 737
 				// then remove the current cached item
738
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
738
+				unset($this->_model_relations[$relationName][$current_cache_id]);
739 739
 				// and cache the newly saved object using it's new ID
740
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
740
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
741 741
 				return TRUE;
742 742
 			}
743 743
 		}
@@ -753,11 +753,11 @@  discard block
 block discarded – undo
753 753
 	 * @param string $relationName
754 754
 	 * @return EE_Base_Class
755 755
 	 */
756
-	public function get_one_from_cache($relationName){
757
-		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
758
-		if(is_array($cached_array_or_object)){
756
+	public function get_one_from_cache($relationName) {
757
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null;
758
+		if (is_array($cached_array_or_object)) {
759 759
 			return array_shift($cached_array_or_object);
760
-		}else{
760
+		} else {
761 761
 			return $cached_array_or_object;
762 762
 		}
763 763
 	}
@@ -772,23 +772,23 @@  discard block
 block discarded – undo
772 772
 	 * @throws \EE_Error
773 773
 	 * @return EE_Base_Class[] NOT necessarily indexed by primary keys
774 774
 	 */
775
-	public function get_all_from_cache($relationName){
776
-		$objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
775
+	public function get_all_from_cache($relationName) {
776
+		$objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array();
777 777
 		// if the result is not an array, but exists, make it an array
778
-		$objects = is_array( $objects ) ? $objects : array( $objects );
778
+		$objects = is_array($objects) ? $objects : array($objects);
779 779
 		//bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143
780 780
 		//basically, if this model object was stored in the session, and these cached model objects
781 781
 		//already have IDs, let's make sure they're in their model's entity mapper
782 782
 		//otherwise we will have duplicates next time we call
783 783
 		// EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
784
-		$model = EE_Registry::instance()->load_model( $relationName );
785
-		foreach( $objects as $model_object ){
786
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
784
+		$model = EE_Registry::instance()->load_model($relationName);
785
+		foreach ($objects as $model_object) {
786
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
787 787
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
788
-				if( $model_object->ID() ){
789
-					$model->add_to_entity_map( $model_object );
788
+				if ($model_object->ID()) {
789
+					$model->add_to_entity_map($model_object);
790 790
 				}
791
-			}else{
791
+			} else {
792 792
 				throw new EE_Error(
793 793
 					sprintf(
794 794
 						__(
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 							'event_espresso'
797 797
 						),
798 798
 						$relationName,
799
-						gettype( $model_object )
799
+						gettype($model_object)
800 800
 					)
801 801
 				);
802 802
 			}
@@ -818,15 +818,15 @@  discard block
 block discarded – undo
818 818
 	 * @return array|EE_Base_Class[]
819 819
 	 * @throws \EE_Error
820 820
 	 */
821
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
822
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
821
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
822
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
823 823
 			? $this->get_model()->get_primary_key_field()->get_name()
824 824
 			: $field_to_order_by;
825
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
826
-		if ( empty( $field ) || empty( $current_value ) ) {
825
+		$current_value = ! empty($field) ? $this->get($field) : null;
826
+		if (empty($field) || empty($current_value)) {
827 827
 			return array();
828 828
 		}
829
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
829
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
830 830
 	}
831 831
 
832 832
 
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
 	 * @return array|EE_Base_Class[]
844 844
 	 * @throws \EE_Error
845 845
 	 */
846
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
847
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
846
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
847
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
848 848
 			? $this->get_model()->get_primary_key_field()->get_name()
849 849
 			: $field_to_order_by;
850
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
851
-		if ( empty( $field ) || empty( $current_value ) ) {
850
+		$current_value = ! empty($field) ? $this->get($field) : null;
851
+		if (empty($field) || empty($current_value)) {
852 852
 			return array();
853 853
 		}
854
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
854
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
855 855
 	}
856 856
 
857 857
 
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
 	 * @return array|EE_Base_Class
868 868
 	 * @throws \EE_Error
869 869
 	 */
870
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
871
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
870
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
871
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
872 872
 			? $this->get_model()->get_primary_key_field()->get_name()
873 873
 			: $field_to_order_by;
874
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
875
-		if ( empty( $field ) || empty( $current_value ) ) {
874
+		$current_value = ! empty($field) ? $this->get($field) : null;
875
+		if (empty($field) || empty($current_value)) {
876 876
 			return array();
877 877
 		}
878
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
878
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
879 879
 	}
880 880
 
881 881
 
@@ -891,15 +891,15 @@  discard block
 block discarded – undo
891 891
 	 * @return array|EE_Base_Class
892 892
 	 * @throws \EE_Error
893 893
 	 */
894
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
895
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
894
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
895
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
896 896
 			? $this->get_model()->get_primary_key_field()->get_name()
897 897
 			: $field_to_order_by;
898
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
899
-		if ( empty( $field ) || empty( $current_value ) ) {
898
+		$current_value = ! empty($field) ? $this->get($field) : null;
899
+		if (empty($field) || empty($current_value)) {
900 900
 			return array();
901 901
 		}
902
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
902
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
903 903
 	}
904 904
 
905 905
 
@@ -912,25 +912,25 @@  discard block
 block discarded – undo
912 912
 	 * @param mixed  $field_value_from_db
913 913
 	 * @throws \EE_Error
914 914
 	 */
915
-	public function set_from_db($field_name,$field_value_from_db){
915
+	public function set_from_db($field_name, $field_value_from_db) {
916 916
 		$field_obj = $this->get_model()->field_settings_for($field_name);
917
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
917
+		if ($field_obj instanceof EE_Model_Field_Base) {
918 918
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
919 919
 			//eg, a CPT model object could have an entry in the posts table, but no
920 920
 			//entry in the meta table. Meaning that all its columns in the meta table
921 921
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
922
-			if($field_value_from_db === NULL ){
923
-				if( $field_obj->is_nullable()){
922
+			if ($field_value_from_db === NULL) {
923
+				if ($field_obj->is_nullable()) {
924 924
 					//if the field allows nulls, then let it be null
925 925
 					$field_value = NULL;
926
-				}else{
926
+				} else {
927 927
 					$field_value = $field_obj->get_default_value();
928 928
 				}
929
-			}else{
930
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
929
+			} else {
930
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
931 931
 			}
932 932
 			$this->_fields[$field_name] = $field_value;
933
-			$this->_clear_cached_property( $field_name );
933
+			$this->_clear_cached_property($field_name);
934 934
 		}
935 935
 	}
936 936
 
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @return mixed
947 947
 	 * @throws \EE_Error
948 948
 	 */
949
-	public function get($field_name, $extra_cache_ref = NULL ){
950
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
949
+	public function get($field_name, $extra_cache_ref = NULL) {
950
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
951 951
 	}
952 952
 
953 953
 
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	 *                                         just null is returned (because that indicates that likely
981 981
 	 *                                         this field is nullable).
982 982
 	 */
983
-	public function get_DateTime_object( $field_name ) {
984
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
983
+	public function get_DateTime_object($field_name) {
984
+		$field_settings = $this->get_model()->field_settings_for($field_name);
985 985
 
986
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
986
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
987 987
 			EE_Error::add_error(
988 988
 				sprintf(
989 989
 					__(
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 * @return void
1016 1016
 	 * @throws \EE_Error
1017 1017
 	 */
1018
-	public function e($field_name, $extra_cache_ref = NULL){
1018
+	public function e($field_name, $extra_cache_ref = NULL) {
1019 1019
 		echo $this->get_pretty($field_name, $extra_cache_ref);
1020 1020
 	}
1021 1021
 
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @return void
1030 1030
 	 * @throws \EE_Error
1031 1031
 	 */
1032
-	public function f($field_name){
1033
-		$this->e($field_name,'form_input');
1032
+	public function f($field_name) {
1033
+		$this->e($field_name, 'form_input');
1034 1034
 	}
1035 1035
 
1036 1036
 
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	 * @return mixed
1044 1044
 	 * @throws \EE_Error
1045 1045
 	 */
1046
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
1047
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
1046
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
1047
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
1048 1048
 	}
1049 1049
 
1050 1050
 
@@ -1062,36 +1062,36 @@  discard block
 block discarded – undo
1062 1062
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
1063 1063
 	 * @throws \EE_Error
1064 1064
 	 */
1065
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
1065
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
1066 1066
 
1067
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
1067
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
1068 1068
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
1069 1069
 
1070 1070
 		//validate field for datetime and returns field settings if valid.
1071
-		$field = $this->_get_dtt_field_settings( $field_name );
1071
+		$field = $this->_get_dtt_field_settings($field_name);
1072 1072
 
1073 1073
 		//clear cached property if either formats are not null.
1074
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
1075
-			$this->_clear_cached_property( $field_name );
1074
+		if ($dt_frmt !== null || $tm_frmt !== null) {
1075
+			$this->_clear_cached_property($field_name);
1076 1076
 			//reset format properties because they are used in get()
1077 1077
 			$this->_dt_frmt = $in_dt_frmt;
1078 1078
 			$this->_tm_frmt = $in_tm_frmt;
1079 1079
 		}
1080
-		if ( $echo ) {
1081
-			$field->set_pretty_date_format( $in_dt_frmt );
1080
+		if ($echo) {
1081
+			$field->set_pretty_date_format($in_dt_frmt);
1082 1082
 		} else {
1083
-			$field->set_date_format( $in_dt_frmt );
1083
+			$field->set_date_format($in_dt_frmt);
1084 1084
 		}
1085
-		if ( $echo ) {
1086
-			$field->set_pretty_time_format( $in_tm_frmt );
1085
+		if ($echo) {
1086
+			$field->set_pretty_time_format($in_tm_frmt);
1087 1087
 		} else {
1088
-			$field->set_time_format( $in_tm_frmt );
1088
+			$field->set_time_format($in_tm_frmt);
1089 1089
 		}
1090 1090
 		//set timezone in field object
1091
-		$field->set_timezone( $this->_timezone );
1091
+		$field->set_timezone($this->_timezone);
1092 1092
 
1093 1093
 		//set the output returned
1094
-		switch ( $date_or_time ) {
1094
+		switch ($date_or_time) {
1095 1095
 
1096 1096
 			case 'D' :
1097 1097
 				$field->set_date_time_output('date');
@@ -1106,11 +1106,11 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 
1108 1108
 
1109
-		if ( $echo ) {
1110
-			$this->e( $field_name, $date_or_time );
1109
+		if ($echo) {
1110
+			$this->e($field_name, $date_or_time);
1111 1111
 			return '';
1112 1112
 		 }
1113
-		return $this->get( $field_name, $date_or_time );
1113
+		return $this->get($field_name, $date_or_time);
1114 1114
 	}
1115 1115
 
1116 1116
 
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 	 * @return string            datetime value formatted
1124 1124
 	 * @throws \EE_Error
1125 1125
 	 */
1126
-	public function get_date( $field_name, $format = NULL ) {
1127
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
1126
+	public function get_date($field_name, $format = NULL) {
1127
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1134,8 +1134,8 @@  discard block
 block discarded – undo
1134 1134
 	 * @param null $format
1135 1135
 	 * @throws \EE_Error
1136 1136
 	 */
1137
-	public function e_date( $field_name, $format = NULL ) {
1138
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
1137
+	public function e_date($field_name, $format = NULL) {
1138
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
1139 1139
 	}
1140 1140
 
1141 1141
 
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 	 * @return string             datetime value formatted
1149 1149
 	 * @throws \EE_Error
1150 1150
 	 */
1151
-	public function get_time( $field_name, $format = NULL ) {
1152
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
1151
+	public function get_time($field_name, $format = NULL) {
1152
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
1153 1153
 	}
1154 1154
 
1155 1155
 
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 	 * @param null $format
1160 1160
 	 * @throws \EE_Error
1161 1161
 	 */
1162
-	public function e_time( $field_name, $format = NULL ) {
1163
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
1162
+	public function e_time($field_name, $format = NULL) {
1163
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
1164 1164
 	}
1165 1165
 
1166 1166
 
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 	 * @return string             datetime value formatted
1175 1175
 	 * @throws \EE_Error
1176 1176
 	 */
1177
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1178
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1177
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1178
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1179 1179
 	}
1180 1180
 
1181 1181
 
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 	 * @param null $tm_frmt
1187 1187
 	 * @throws \EE_Error
1188 1188
 	 */
1189
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1190
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1189
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1190
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1191 1191
 	}
1192 1192
 
1193 1193
 
@@ -1201,11 +1201,11 @@  discard block
 block discarded – undo
1201 1201
 	 * @throws \EE_Error
1202 1202
 	 *                           field name.
1203 1203
 	 */
1204
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1205
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1204
+	public function get_i18n_datetime($field_name, $format = NULL) {
1205
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1206 1206
 		return date_i18n(
1207 1207
 			$format,
1208
-			EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone )
1208
+			EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone)
1209 1209
 		);
1210 1210
 	}
1211 1211
 
@@ -1218,14 +1218,14 @@  discard block
 block discarded – undo
1218 1218
 	 * @throws EE_Error
1219 1219
 	 * @return EE_Datetime_Field
1220 1220
 	 */
1221
-	protected function _get_dtt_field_settings( $field_name ) {
1221
+	protected function _get_dtt_field_settings($field_name) {
1222 1222
 		$field = $this->get_model()->field_settings_for($field_name);
1223 1223
 
1224 1224
 		//check if field is dtt
1225
-		if ( $field instanceof EE_Datetime_Field ) {
1225
+		if ($field instanceof EE_Datetime_Field) {
1226 1226
 			return $field;
1227 1227
 		} else {
1228
-			throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) );
1228
+			throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this))));
1229 1229
 		}
1230 1230
 	}
1231 1231
 
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	 * @param string          $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1247 1247
 	 * @throws \EE_Error
1248 1248
 	 */
1249
-	protected function _set_time_for( $time, $fieldname ) {
1250
-		$this->_set_date_time( 'T', $time, $fieldname );
1249
+	protected function _set_time_for($time, $fieldname) {
1250
+		$this->_set_date_time('T', $time, $fieldname);
1251 1251
 	}
1252 1252
 
1253 1253
 
@@ -1260,8 +1260,8 @@  discard block
 block discarded – undo
1260 1260
 	 * @param string          $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1261 1261
 	 * @throws \EE_Error
1262 1262
 	 */
1263
-	protected function _set_date_for( $date, $fieldname ) {
1264
-		$this->_set_date_time( 'D', $date, $fieldname );
1263
+	protected function _set_date_for($date, $fieldname) {
1264
+		$this->_set_date_time('D', $date, $fieldname);
1265 1265
 	}
1266 1266
 
1267 1267
 
@@ -1275,26 +1275,26 @@  discard block
 block discarded – undo
1275 1275
 	 * @param string          $fieldname      the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1276 1276
 	 * @throws \EE_Error
1277 1277
 	 */
1278
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1279
-		$field = $this->_get_dtt_field_settings( $fieldname );
1280
-		$field->set_timezone( $this->_timezone );
1281
-		$field->set_date_format( $this->_dt_frmt );
1282
-		$field->set_time_format( $this->_tm_frmt );
1283
-		switch ( $what ) {
1278
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1279
+		$field = $this->_get_dtt_field_settings($fieldname);
1280
+		$field->set_timezone($this->_timezone);
1281
+		$field->set_date_format($this->_dt_frmt);
1282
+		$field->set_time_format($this->_tm_frmt);
1283
+		switch ($what) {
1284 1284
 			case 'T' :
1285
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time(
1285
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time(
1286 1286
 					$datetime_value,
1287
-					$this->_fields[ $fieldname ]
1287
+					$this->_fields[$fieldname]
1288 1288
 				);
1289 1289
 				break;
1290 1290
 			case 'D' :
1291
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date(
1291
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date(
1292 1292
 					$datetime_value,
1293
-					$this->_fields[ $fieldname ]
1293
+					$this->_fields[$fieldname]
1294 1294
 				);
1295 1295
 				break;
1296 1296
 			case 'B' :
1297
-				$this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value );
1297
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1298 1298
 				break;
1299 1299
 		}
1300 1300
 		$this->_clear_cached_property($fieldname);
@@ -1316,17 +1316,17 @@  discard block
 block discarded – undo
1316 1316
 	 * @throws EE_Error
1317 1317
 	 * @return string timestamp
1318 1318
 	 */
1319
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1319
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1320 1320
 		$timezone = EEH_DTT_Helper::get_timezone();
1321
-		if ( $timezone === $this->_timezone ) {
1321
+		if ($timezone === $this->_timezone) {
1322 1322
 			return '';
1323 1323
 		}
1324 1324
 		$original_timezone = $this->_timezone;
1325
-		$this->set_timezone( $timezone );
1325
+		$this->set_timezone($timezone);
1326 1326
 
1327 1327
 		$fn = (array) $field_name;
1328
-		$args = array_merge( $fn, (array) $args );
1329
-		if ( ! method_exists( $this, $callback ) ) {
1328
+		$args = array_merge($fn, (array) $args);
1329
+		if ( ! method_exists($this, $callback)) {
1330 1330
 			throw new EE_Error(
1331 1331
 				sprintf(
1332 1332
 					__(
@@ -1338,9 +1338,9 @@  discard block
 block discarded – undo
1338 1338
 			);
1339 1339
 		}
1340 1340
 		$args = (array) $args;
1341
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1341
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1342 1342
 
1343
-		$this->set_timezone( $original_timezone );
1343
+		$this->set_timezone($original_timezone);
1344 1344
 		return $return;
1345 1345
 	}
1346 1346
 
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 	 * @return boolean | int
1355 1355
 	 * @throws \EE_Error
1356 1356
 	 */
1357
-	public function delete(){
1357
+	public function delete() {
1358 1358
 		/**
1359 1359
 		 * Called just before the `EE_Base_Class::_delete` method call.
1360 1360
 		 * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 		 *
1364 1364
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1365 1365
 		 */
1366
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1366
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1367 1367
 		$result = $this->_delete();
1368 1368
 		/**
1369 1369
 		 * Called just after the `EE_Base_Class::_delete` method call.
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1374 1374
 		 * @param boolean $result
1375 1375
 		 */
1376
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1376
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1377 1377
 		return $result;
1378 1378
 	}
1379 1379
 
@@ -1399,22 +1399,22 @@  discard block
 block discarded – undo
1399 1399
 	 * @return bool | int
1400 1400
 	 * @throws \EE_Error
1401 1401
 	 */
1402
-	public function delete_permanently(){
1402
+	public function delete_permanently() {
1403 1403
 		/**
1404 1404
 		 * Called just before HARD deleting a model object
1405 1405
 		 *
1406 1406
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1407 1407
 		 */
1408
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this );
1409
-		$model=$this->get_model();
1410
-		$result=$model->delete_permanently_by_ID($this->ID());
1408
+		do_action('AHEE__EE_Base_Class__delete_permanently__before', $this);
1409
+		$model = $this->get_model();
1410
+		$result = $model->delete_permanently_by_ID($this->ID());
1411 1411
 		$this->refresh_cache_of_related_objects();
1412 1412
 		/**
1413 1413
 		 * Called just after HARD deleting a model object
1414 1414
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1415 1415
 		 * @param boolean $result
1416 1416
 		 */
1417
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result );
1417
+		do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result);
1418 1418
 		return $result;
1419 1419
 	}
1420 1420
 
@@ -1427,18 +1427,18 @@  discard block
 block discarded – undo
1427 1427
 	 * @throws \EE_Error
1428 1428
 	 */
1429 1429
         public function refresh_cache_of_related_objects() {
1430
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1431
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1432
-                    $related_objects = $this->_model_relations[ $relation_name ];
1433
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1430
+            foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1431
+                if ( ! empty($this->_model_relations[$relation_name])) {
1432
+                    $related_objects = $this->_model_relations[$relation_name];
1433
+                    if ($relation_obj instanceof EE_Belongs_To_Relation) {
1434 1434
                         //this relation only stores a single model object, not an array
1435 1435
                         //but let's make it consistent
1436
-                        $related_objects = array( $related_objects );
1436
+                        $related_objects = array($related_objects);
1437 1437
                     }
1438
-                    foreach( $related_objects as $related_object ) {
1438
+                    foreach ($related_objects as $related_object) {
1439 1439
                         //only refresh their cache if they're in memory
1440
-                        if( $related_object instanceof EE_Base_Class ) {
1441
-							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1440
+                        if ($related_object instanceof EE_Base_Class) {
1441
+							$related_object->clear_cache($this->get_model()->get_this_model_name(), $this);
1442 1442
                         }
1443 1443
                     }
1444 1444
                 }
@@ -1458,17 +1458,17 @@  discard block
 block discarded – undo
1458 1458
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object
1459 1459
 	 * isn't allowed to persist (as determined by EE_Base_Class::allow_persist())
1460 1460
 	 */
1461
-	public function save($set_cols_n_values=array()) {
1461
+	public function save($set_cols_n_values = array()) {
1462 1462
 		/**
1463 1463
 		 * Filters the fields we're about to save on the model object
1464 1464
 		 *
1465 1465
 		 * @param array $set_cols_n_values
1466 1466
 		 * @param EE_Base_Class $model_object
1467 1467
 		 */
1468
-		$set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1468
+		$set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1469 1469
 		//set attributes as provided in $set_cols_n_values
1470
-		foreach($set_cols_n_values as $column=>$value){
1471
-			$this->set($column,$value);
1470
+		foreach ($set_cols_n_values as $column=>$value) {
1471
+			$this->set($column, $value);
1472 1472
 		}
1473 1473
 		/**
1474 1474
 		 * Saving a model object.
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
 		 * Before we perform a save, this action is fired.
1477 1477
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1478 1478
 		 */
1479
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1480
-		if( ! $this->allow_persist() ) {
1479
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1480
+		if ( ! $this->allow_persist()) {
1481 1481
 			return 0;
1482 1482
 		}
1483 1483
 		//now get current attribute values
@@ -1487,61 +1487,61 @@  discard block
 block discarded – undo
1487 1487
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1488 1488
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1489 1489
 		//does this model have an autoincrement PK?
1490
-		if($this->get_model()->has_primary_key_field()){
1491
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1490
+		if ($this->get_model()->has_primary_key_field()) {
1491
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1492 1492
 				//ok check if it's set, if so: update; if not, insert
1493
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1494
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1493
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1494
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1495 1495
 				} else {
1496
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1497
-					$results = $this->get_model()->insert( $save_cols_n_values );
1498
-					if($results){
1496
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1497
+					$results = $this->get_model()->insert($save_cols_n_values);
1498
+					if ($results) {
1499 1499
 						//if successful, set the primary key
1500 1500
 						//but don't use the normal SET method, because it will check if
1501 1501
 						//an item with the same ID exists in the mapper & db, then
1502 1502
 						//will find it in the db (because we just added it) and THAT object
1503 1503
 						//will get added to the mapper before we can add this one!
1504 1504
 						//but if we just avoid using the SET method, all that headache can be avoided
1505
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1505
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1506 1506
 						$this->_fields[$pk_field_name] = $results;
1507 1507
 						$this->_clear_cached_property($pk_field_name);
1508
-						$this->get_model()->add_to_entity_map( $this );
1508
+						$this->get_model()->add_to_entity_map($this);
1509 1509
 						$this->_update_cached_related_model_objs_fks();
1510 1510
 					}
1511 1511
 				}
1512
-			}else{//PK is NOT auto-increment
1512
+			} else {//PK is NOT auto-increment
1513 1513
 				//so check if one like it already exists in the db
1514
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1515
-					if( WP_DEBUG && ! $this->in_entity_map() ){
1514
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1515
+					if (WP_DEBUG && ! $this->in_entity_map()) {
1516 1516
 						throw new EE_Error(
1517 1517
 							sprintf(
1518
-								__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ),
1518
+								__('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'),
1519 1519
 								get_class($this),
1520
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1521
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1520
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1521
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1522 1522
 								'<br />'
1523 1523
 							)
1524 1524
 						);
1525 1525
 					}
1526 1526
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1527
-				}else{
1527
+				} else {
1528 1528
 					$results = $this->get_model()->insert($save_cols_n_values);
1529 1529
 					$this->_update_cached_related_model_objs_fks();
1530 1530
 				}
1531 1531
 			}
1532
-		}else{//there is NO primary key
1532
+		} else {//there is NO primary key
1533 1533
 			$already_in_db = false;
1534
-			foreach($this->get_model()->unique_indexes() as $index){
1534
+			foreach ($this->get_model()->unique_indexes() as $index) {
1535 1535
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1536
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1536
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1537 1537
 					$already_in_db = true;
1538 1538
 				}
1539 1539
 			}
1540
-			if( $already_in_db ){
1541
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1542
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1543
-			}else{
1544
-				$results = $this->get_model()->insert( $save_cols_n_values );
1540
+			if ($already_in_db) {
1541
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1542
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1543
+			} else {
1544
+				$results = $this->get_model()->insert($save_cols_n_values);
1545 1545
 			}
1546 1546
 		}
1547 1547
 		//restore the old assumption about values being prepared by the model object
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1555 1555
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1556 1556
 		 */
1557
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1557
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1558 1558
 		return $results;
1559 1559
 	}
1560 1560
 
@@ -1569,15 +1569,15 @@  discard block
 block discarded – undo
1569 1569
 	 * @return void
1570 1570
 	 * @throws \EE_Error
1571 1571
 	 */
1572
-	protected function _update_cached_related_model_objs_fks(){
1573
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1574
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1575
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1572
+	protected function _update_cached_related_model_objs_fks() {
1573
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1574
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1575
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1576 1576
 					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to(
1577 1577
 						$this->get_model()->get_this_model_name()
1578 1578
 					);
1579
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1580
-					if( $related_model_obj_in_cache->ID() ){
1579
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1580
+					if ($related_model_obj_in_cache->ID()) {
1581 1581
 						$related_model_obj_in_cache->save();
1582 1582
 					}
1583 1583
 				}
@@ -1598,21 +1598,21 @@  discard block
 block discarded – undo
1598 1598
 	 * @return int ID of new model object on save; 0 on failure+
1599 1599
 	 * @throws \EE_Error
1600 1600
 	 */
1601
-	public function save_new_cached_related_model_objs(){
1601
+	public function save_new_cached_related_model_objs() {
1602 1602
 		//make sure this has been saved
1603
-		if( ! $this->ID()){
1603
+		if ( ! $this->ID()) {
1604 1604
 			$id = $this->save();
1605
-		}else{
1605
+		} else {
1606 1606
 			$id = $this->ID();
1607 1607
 		}
1608 1608
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1609
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1609
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1610 1610
 
1611 1611
 
1612
-			if($this->_model_relations[$relationName]){
1612
+			if ($this->_model_relations[$relationName]) {
1613 1613
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1614 1614
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1615
-				if($relationObj instanceof EE_Belongs_To_Relation){
1615
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1616 1616
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1617 1617
 					//but ONLY if it DOES NOT exist in the DB
1618 1618
 					/* @var $related_model_obj EE_Base_Class */
@@ -1621,8 +1621,8 @@  discard block
 block discarded – undo
1621 1621
 						$this->_add_relation_to($related_model_obj, $relationName);
1622 1622
 						$related_model_obj->save_new_cached_related_model_objs();
1623 1623
 //					}
1624
-				}else{
1625
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1624
+				} else {
1625
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1626 1626
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1627 1627
 						//but ONLY if it DOES NOT exist in the DB
1628 1628
 //						if( ! $related_model_obj->ID()){
@@ -1643,8 +1643,8 @@  discard block
 block discarded – undo
1643 1643
 	 * @return \EEM_Base | \EEM_CPT_Base
1644 1644
 	 */
1645 1645
 	public function get_model() {
1646
-		$modelName = self::_get_model_classname( get_class($this) );
1647
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1646
+		$modelName = self::_get_model_classname(get_class($this));
1647
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1648 1648
 	}
1649 1649
 
1650 1650
 
@@ -1655,10 +1655,10 @@  discard block
 block discarded – undo
1655 1655
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1656 1656
 	 * @throws \EE_Error
1657 1657
 	 */
1658
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1658
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1659 1659
 		//TODO: will not work for Term_Relationships because they have no PK!
1660
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1661
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1660
+		$primary_id_ref = self::_get_primary_key_name($classname);
1661
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1662 1662
 			$id = $props_n_values[$primary_id_ref];
1663 1663
 			return self::_get_model($classname)->get_from_entity_map($id);
1664 1664
 		}
@@ -1679,37 +1679,37 @@  discard block
 block discarded – undo
1679 1679
 	 * @return mixed (EE_Base_Class|bool)
1680 1680
 	 * @throws \EE_Error
1681 1681
 	 */
1682
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) {
1682
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) {
1683 1683
 		$existing = null;
1684
-		if ( self::_get_model( $classname )->has_primary_key_field() ) {
1685
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1686
-			if ( array_key_exists( $primary_id_ref, $props_n_values )
1687
-			     && ! empty( $props_n_values[ $primary_id_ref ] )
1684
+		if (self::_get_model($classname)->has_primary_key_field()) {
1685
+			$primary_id_ref = self::_get_primary_key_name($classname);
1686
+			if (array_key_exists($primary_id_ref, $props_n_values)
1687
+			     && ! empty($props_n_values[$primary_id_ref])
1688 1688
 			) {
1689
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1690
-					$props_n_values[ $primary_id_ref ]
1689
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1690
+					$props_n_values[$primary_id_ref]
1691 1691
 				);
1692 1692
 			}
1693
-		} elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) {
1693
+		} elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1694 1694
 			//no primary key on this model, but there's still a matching item in the DB
1695
-			$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1696
-				self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values )
1695
+			$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1696
+				self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)
1697 1697
 			);
1698 1698
 		}
1699
-		if ( $existing ) {
1699
+		if ($existing) {
1700 1700
 
1701 1701
 			//set date formats if present before setting values
1702
-			if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
1703
-				$existing->set_date_format( $date_formats[0] );
1704
-				$existing->set_time_format( $date_formats[1] );
1702
+			if ( ! empty($date_formats) && is_array($date_formats)) {
1703
+				$existing->set_date_format($date_formats[0]);
1704
+				$existing->set_time_format($date_formats[1]);
1705 1705
 			} else {
1706 1706
 				//set default formats for date and time
1707
-				$existing->set_date_format( get_option( 'date_format' ) );
1708
-				$existing->set_time_format( get_option( 'time_format' ) );
1707
+				$existing->set_date_format(get_option('date_format'));
1708
+				$existing->set_time_format(get_option('time_format'));
1709 1709
 			}
1710 1710
 
1711
-			foreach ( $props_n_values as $property => $field_value ) {
1712
-				$existing->set( $property, $field_value );
1711
+			foreach ($props_n_values as $property => $field_value) {
1712
+				$existing->set($property, $field_value);
1713 1713
 			}
1714 1714
 			return $existing;
1715 1715
 		} else {
@@ -1727,9 +1727,9 @@  discard block
 block discarded – undo
1727 1727
 	 * @throws EE_Error
1728 1728
 	 * @return EEM_Base
1729 1729
 	 */
1730
-	protected static function  _get_model( $classname, $timezone = NULL ){
1730
+	protected static function  _get_model($classname, $timezone = NULL) {
1731 1731
 		//find model for this class
1732
-		if( ! $classname ){
1732
+		if ( ! $classname) {
1733 1733
 			throw new EE_Error(
1734 1734
 				sprintf(
1735 1735
 					__(
@@ -1740,8 +1740,8 @@  discard block
 block discarded – undo
1740 1740
 				)
1741 1741
 			);
1742 1742
 		}
1743
-		$modelName=self::_get_model_classname($classname);
1744
-		return self::_get_model_instance_with_name($modelName, $timezone );
1743
+		$modelName = self::_get_model_classname($classname);
1744
+		return self::_get_model_instance_with_name($modelName, $timezone);
1745 1745
 	}
1746 1746
 
1747 1747
 
@@ -1752,10 +1752,10 @@  discard block
 block discarded – undo
1752 1752
 	 * @param null   $timezone
1753 1753
 	 * @return EEM_Base
1754 1754
 	 */
1755
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1756
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1757
-		$model = EE_Registry::instance()->load_model( $model_classname );
1758
-		$model->set_timezone( $timezone );
1755
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1756
+		$model_classname = str_replace('EEM_', '', $model_classname);
1757
+		$model = EE_Registry::instance()->load_model($model_classname);
1758
+		$model->set_timezone($timezone);
1759 1759
 		return $model;
1760 1760
 	}
1761 1761
 
@@ -1767,10 +1767,10 @@  discard block
 block discarded – undo
1767 1767
 	 * @param null $model_name
1768 1768
 	 * @return string like EEM_Attendee
1769 1769
 	 */
1770
-	private static function _get_model_classname( $model_name = null){
1771
-		if(strpos($model_name,"EE_")===0){
1772
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1773
-		}else{
1770
+	private static function _get_model_classname($model_name = null) {
1771
+		if (strpos($model_name, "EE_") === 0) {
1772
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1773
+		} else {
1774 1774
 			$model_classname = "EEM_".$model_name;
1775 1775
 		}
1776 1776
 		return $model_classname;
@@ -1784,16 +1784,16 @@  discard block
 block discarded – undo
1784 1784
 	 * @throws EE_Error
1785 1785
 	 * @return string
1786 1786
 	 */
1787
-	protected static function _get_primary_key_name( $classname = NULL ){
1788
-		if( ! $classname){
1787
+	protected static function _get_primary_key_name($classname = NULL) {
1788
+		if ( ! $classname) {
1789 1789
 			throw new EE_Error(
1790 1790
 				sprintf(
1791
-					__( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ),
1791
+					__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),
1792 1792
 					$classname
1793 1793
 				)
1794 1794
 			);
1795 1795
 		}
1796
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1796
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1797 1797
 	}
1798 1798
 
1799 1799
 
@@ -1807,12 +1807,12 @@  discard block
 block discarded – undo
1807 1807
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1808 1808
 	 * @throws \EE_Error
1809 1809
 	 */
1810
-	public function ID(){
1810
+	public function ID() {
1811 1811
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1812
-		if( $this->get_model()->has_primary_key_field() ) {
1813
-			return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ];
1814
-		}else{
1815
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1812
+		if ($this->get_model()->has_primary_key_field()) {
1813
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1814
+		} else {
1815
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1816 1816
 		}
1817 1817
 	}
1818 1818
 
@@ -1830,38 +1830,38 @@  discard block
 block discarded – undo
1830 1830
 	 * @throws EE_Error
1831 1831
 	 * @return EE_Base_Class the object the relation was added to
1832 1832
 	 */
1833
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){
1833
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) {
1834 1834
 		//if this thing exists in the DB, save the relation to the DB
1835
-		if( $this->ID() ){
1836
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1835
+		if ($this->ID()) {
1836
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values);
1837 1837
 			//clear cache so future get_many_related and get_first_related() return new results.
1838
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1839
-                        if( $otherObject instanceof EE_Base_Class ) {
1840
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1838
+			$this->clear_cache($relationName, $otherObject, TRUE);
1839
+                        if ($otherObject instanceof EE_Base_Class) {
1840
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1841 1841
                         }
1842 1842
 		} else {
1843 1843
 			//this thing doesn't exist in the DB,  so just cache it
1844
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1845
-				throw new EE_Error( sprintf(
1846
-					__( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ),
1844
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1845
+				throw new EE_Error(sprintf(
1846
+					__('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'),
1847 1847
 					$otherObjectModelObjectOrID,
1848
-					get_class( $this )
1848
+					get_class($this)
1849 1849
 				));
1850 1850
 			} else {
1851 1851
 				$otherObject = $otherObjectModelObjectOrID;
1852 1852
 			}
1853
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1853
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1854 1854
 		}
1855
-                if( $otherObject instanceof EE_Base_Class ) {
1855
+                if ($otherObject instanceof EE_Base_Class) {
1856 1856
                     //fix the reciprocal relation too
1857
-                    if( $otherObject->ID() ) {
1857
+                    if ($otherObject->ID()) {
1858 1858
                             //its saved so assumed relations exist in the DB, so we can just
1859 1859
                             //clear the cache so future queries use the updated info in the DB
1860
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1860
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true);
1861 1861
                     } else {
1862 1862
 
1863 1863
                             //it's not saved, so it caches relations like this
1864
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1864
+                            $otherObject->cache($this->get_model()->get_this_model_name(), $this);
1865 1865
                     }
1866 1866
                 }
1867 1867
 		return $otherObject;
@@ -1885,17 +1885,17 @@  discard block
 block discarded – undo
1885 1885
 	 * @return EE_Base_Class the relation was removed from
1886 1886
 	 * @throws \EE_Error
1887 1887
 	 */
1888
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1889
-		if ( $this->ID() ) {
1888
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1889
+		if ($this->ID()) {
1890 1890
 			//if this exists in the DB, save the relation change to the DB too
1891
-			$otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1892
-			$this->clear_cache( $relationName, $otherObject );
1891
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1892
+			$this->clear_cache($relationName, $otherObject);
1893 1893
 		} else {
1894 1894
 			//this doesn't exist in the DB, just remove it from the cache
1895
-			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1895
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1896 1896
 		}
1897
-                if( $otherObject instanceof EE_Base_Class ) {
1898
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1897
+                if ($otherObject instanceof EE_Base_Class) {
1898
+                    $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1899 1899
                 }
1900 1900
 		return $otherObject;
1901 1901
 	}
@@ -1910,18 +1910,18 @@  discard block
 block discarded – undo
1910 1910
 	 * @return EE_Base_Class
1911 1911
 	 * @throws \EE_Error
1912 1912
 	 */
1913
-	public function _remove_relations($relationName,$where_query_params = array()){
1914
-		if ( $this->ID() ) {
1913
+	public function _remove_relations($relationName, $where_query_params = array()) {
1914
+		if ($this->ID()) {
1915 1915
 			//if this exists in the DB, save the relation change to the DB too
1916
-			$otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params );
1917
-			$this->clear_cache( $relationName, null, true );
1916
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1917
+			$this->clear_cache($relationName, null, true);
1918 1918
 		} else {
1919 1919
 			//this doesn't exist in the DB, just remove it from the cache
1920
-			$otherObjects = $this->clear_cache( $relationName, null, true );
1920
+			$otherObjects = $this->clear_cache($relationName, null, true);
1921 1921
 		}
1922
-                if( is_array( $otherObjects ) ) {
1923
-                    foreach ( $otherObjects as $otherObject ) {
1924
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1922
+                if (is_array($otherObjects)) {
1923
+                    foreach ($otherObjects as $otherObject) {
1924
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1925 1925
                     }
1926 1926
                 }
1927 1927
 		return $otherObjects;
@@ -1941,27 +1941,27 @@  discard block
 block discarded – undo
1941 1941
 	 * @throws \EE_Error
1942 1942
 	 *                             or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs
1943 1943
 	 */
1944
-	public function get_many_related($relationName,$query_params = array()){
1945
-		if($this->ID()){
1944
+	public function get_many_related($relationName, $query_params = array()) {
1945
+		if ($this->ID()) {
1946 1946
 			//this exists in the DB, so get the related things from either the cache or the DB
1947 1947
 			//if there are query parameters, forget about caching the related model objects.
1948
-			if( $query_params ){
1948
+			if ($query_params) {
1949 1949
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1950
-			}else{
1950
+			} else {
1951 1951
 				//did we already cache the result of this query?
1952 1952
 				$cached_results = $this->get_all_from_cache($relationName);
1953
-				if ( ! $cached_results ){
1953
+				if ( ! $cached_results) {
1954 1954
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1955 1955
 					//if no query parameters were passed, then we got all the related model objects
1956 1956
 					//for that relation. We can cache them then.
1957
-					foreach($related_model_objects as $related_model_object){
1957
+					foreach ($related_model_objects as $related_model_object) {
1958 1958
 						$this->cache($relationName, $related_model_object);
1959 1959
 					}
1960
-				}else{
1960
+				} else {
1961 1961
 					$related_model_objects = $cached_results;
1962 1962
 				}
1963 1963
 			}
1964
-		}else{
1964
+		} else {
1965 1965
 			//this doesn't exist in the DB, so just get the related things from the cache
1966 1966
 			$related_model_objects = $this->get_all_from_cache($relationName);
1967 1967
 		}
@@ -1979,8 +1979,8 @@  discard block
 block discarded – undo
1979 1979
 	 * @param bool   	$distinct       if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1980 1980
 	 * @return int
1981 1981
 	 */
1982
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1983
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1982
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1983
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1984 1984
 	}
1985 1985
 
1986 1986
 
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1995 1995
 	 * @return int
1996 1996
 	 */
1997
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
1997
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
1998 1998
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
1999 1999
 	}
2000 2000
 
@@ -2008,33 +2008,33 @@  discard block
 block discarded – undo
2008 2008
 	 * @return EE_Base_Class (not an array, a single object)
2009 2009
 	 * @throws \EE_Error
2010 2010
 	 */
2011
-	public function get_first_related($relationName,$query_params = array()){
2012
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
2011
+	public function get_first_related($relationName, $query_params = array()) {
2012
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
2013 2013
 
2014 2014
 			//if they've provided some query parameters, don't bother trying to cache the result
2015 2015
 			//also make sure we're not caching the result of get_first_related
2016 2016
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
2017
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2018
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2019
-			}else{
2017
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2018
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2019
+			} else {
2020 2020
 				//first, check if we've already cached the result of this query
2021 2021
 				$cached_result = $this->get_one_from_cache($relationName);
2022
-				if ( ! $cached_result ){
2022
+				if ( ! $cached_result) {
2023 2023
 
2024 2024
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2025
-					$this->cache($relationName,$related_model_object);
2026
-				}else{
2025
+					$this->cache($relationName, $related_model_object);
2026
+				} else {
2027 2027
 					$related_model_object = $cached_result;
2028 2028
 				}
2029 2029
 			}
2030
-		}else{
2030
+		} else {
2031 2031
 			$related_model_object = null;
2032 2032
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
2033
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2034
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2033
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2034
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2035 2035
 			}
2036 2036
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
2037
-			if( ! $related_model_object){
2037
+			if ( ! $related_model_object) {
2038 2038
 				$related_model_object = $this->get_one_from_cache($relationName);
2039 2039
 			}
2040 2040
 
@@ -2056,12 +2056,12 @@  discard block
 block discarded – undo
2056 2056
 	 * @return int how many deleted
2057 2057
 	 * @throws \EE_Error
2058 2058
 	 */
2059
-	public function delete_related($relationName,$query_params = array()){
2060
-		if($this->ID()){
2061
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
2062
-		}else{
2059
+	public function delete_related($relationName, $query_params = array()) {
2060
+		if ($this->ID()) {
2061
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
2062
+		} else {
2063 2063
 			$count = count($this->get_all_from_cache($relationName));
2064
-			$this->clear_cache($relationName,NULL,TRUE);
2064
+			$this->clear_cache($relationName, NULL, TRUE);
2065 2065
 		}
2066 2066
 		return $count;
2067 2067
 	}
@@ -2080,13 +2080,13 @@  discard block
 block discarded – undo
2080 2080
 	 * @return int how many deleted (including those soft deleted)
2081 2081
 	 * @throws \EE_Error
2082 2082
 	 */
2083
-	public function delete_related_permanently($relationName,$query_params = array()){
2084
-		if($this->ID()){
2085
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2086
-		}else{
2083
+	public function delete_related_permanently($relationName, $query_params = array()) {
2084
+		if ($this->ID()) {
2085
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2086
+		} else {
2087 2087
 			$count = count($this->get_all_from_cache($relationName));
2088 2088
 		}
2089
-		$this->clear_cache($relationName,NULL,TRUE);
2089
+		$this->clear_cache($relationName, NULL, TRUE);
2090 2090
 		return $count;
2091 2091
 	}
2092 2092
 
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 	 * @param  string $field_name property to check
2103 2103
 	 * @return bool            				  TRUE if existing,FALSE if not.
2104 2104
 	 */
2105
-	public function is_set( $field_name ) {
2105
+	public function is_set($field_name) {
2106 2106
 		return isset($this->_fields[$field_name]);
2107 2107
 	}
2108 2108
 
@@ -2114,11 +2114,11 @@  discard block
 block discarded – undo
2114 2114
 	 * @throws EE_Error
2115 2115
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
2116 2116
 	 */
2117
-	protected function _property_exists( $properties ) {
2117
+	protected function _property_exists($properties) {
2118 2118
 
2119
-		foreach ( (array) $properties as $property_name ) {
2119
+		foreach ((array) $properties as $property_name) {
2120 2120
 			//first make sure this property exists
2121
-			if ( ! $this->_fields[ $property_name ] ) {
2121
+			if ( ! $this->_fields[$property_name]) {
2122 2122
 				throw new EE_Error(
2123 2123
 					sprintf(
2124 2124
 						__(
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 		$fields = $this->get_model()->field_settings(FALSE);
2147 2147
 		$properties = array();
2148 2148
 		//remove prepended underscore
2149
-		foreach ( $fields as $field_name => $settings ) {
2149
+		foreach ($fields as $field_name => $settings) {
2150 2150
 			$properties[$field_name] = $this->get($field_name);
2151 2151
 		}
2152 2152
 		return $properties;
@@ -2176,10 +2176,10 @@  discard block
 block discarded – undo
2176 2176
 	 * @throws EE_Error
2177 2177
 	 * @return mixed whatever the plugin which calls add_filter decides
2178 2178
 	 */
2179
-	public function __call($methodName,$args){
2180
-		$className=get_class($this);
2181
-		$tagName="FHEE__{$className}__{$methodName}";
2182
-		if ( ! has_filter( $tagName ) ) {
2179
+	public function __call($methodName, $args) {
2180
+		$className = get_class($this);
2181
+		$tagName = "FHEE__{$className}__{$methodName}";
2182
+		if ( ! has_filter($tagName)) {
2183 2183
 			throw new EE_Error(
2184 2184
 				sprintf(
2185 2185
 					__(
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 				)
2193 2193
 			);
2194 2194
 		}
2195
-		return apply_filters($tagName,null,$this,$args);
2195
+		return apply_filters($tagName, null, $this, $args);
2196 2196
 	}
2197 2197
 
2198 2198
 
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
 	 * @throws \EE_Error
2209 2209
 	 * NOTE: if the values haven't changed, returns 0
2210 2210
 	 */
2211
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
2211
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
2212 2212
 		$query_params = array(
2213 2213
 			array(
2214 2214
 				'EXM_key'  => $meta_key,
@@ -2216,17 +2216,17 @@  discard block
 block discarded – undo
2216 2216
 				'EXM_type' => $this->get_model()->get_this_model_name()
2217 2217
 			)
2218 2218
 		);
2219
-		if ( $previous_value !== null ) {
2219
+		if ($previous_value !== null) {
2220 2220
 			$query_params[0]['EXM_value'] = $meta_value;
2221 2221
 		}
2222
-		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params );
2223
-		if ( ! $existing_rows_like_that ) {
2224
-			return $this->add_extra_meta( $meta_key, $meta_value );
2222
+		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2223
+		if ( ! $existing_rows_like_that) {
2224
+			return $this->add_extra_meta($meta_key, $meta_value);
2225 2225
 		} else {
2226
-			foreach ( $existing_rows_like_that as $existing_row ) {
2227
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2226
+			foreach ($existing_rows_like_that as $existing_row) {
2227
+				$existing_row->save(array('EXM_value' => $meta_value));
2228 2228
 			}
2229
-			return count( $existing_rows_like_that );
2229
+			return count($existing_rows_like_that);
2230 2230
 		}
2231 2231
 	}
2232 2232
 
@@ -2243,8 +2243,8 @@  discard block
 block discarded – undo
2243 2243
 	 * @return boolean
2244 2244
 	 * @throws \EE_Error
2245 2245
 	 */
2246
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
2247
-		if ( $unique ) {
2246
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
2247
+		if ($unique) {
2248 2248
 			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(
2249 2249
 				array(
2250 2250
 					array(
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 					)
2255 2255
 				)
2256 2256
 			);
2257
-			if ( $existing_extra_meta ) {
2257
+			if ($existing_extra_meta) {
2258 2258
 				return false;
2259 2259
 			}
2260 2260
 		}
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 	 * @return int number of extra meta rows deleted
2282 2282
 	 * @throws \EE_Error
2283 2283
 	 */
2284
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
2284
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
2285 2285
 		$query_params = array(
2286 2286
 			array(
2287 2287
 				'EXM_key'  => $meta_key,
@@ -2289,10 +2289,10 @@  discard block
 block discarded – undo
2289 2289
 				'EXM_type' => $this->get_model()->get_this_model_name()
2290 2290
 			)
2291 2291
 		);
2292
-		if ( $meta_value !== null ) {
2292
+		if ($meta_value !== null) {
2293 2293
 			$query_params[0]['EXM_value'] = $meta_value;
2294 2294
 		}
2295
-		return EEM_Extra_Meta::instance()->delete( $query_params );
2295
+		return EEM_Extra_Meta::instance()->delete($query_params);
2296 2296
 	}
2297 2297
 
2298 2298
 
@@ -2308,25 +2308,25 @@  discard block
 block discarded – undo
2308 2308
 	 * @return mixed single value if $single; array if ! $single
2309 2309
 	 * @throws \EE_Error
2310 2310
 	 */
2311
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
2312
-		if($single){
2313
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2314
-			if ( $result instanceof EE_Extra_Meta ){
2311
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
2312
+		if ($single) {
2313
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2314
+			if ($result instanceof EE_Extra_Meta) {
2315 2315
 				return $result->value();
2316
-			}else{
2316
+			} else {
2317 2317
 				return $default;
2318 2318
 			}
2319
-		}else{
2320
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2321
-			if($results){
2319
+		} else {
2320
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2321
+			if ($results) {
2322 2322
 				$values = array();
2323
-				foreach($results as $result){
2324
-					if ( $result instanceof EE_Extra_Meta ){
2323
+				foreach ($results as $result) {
2324
+					if ($result instanceof EE_Extra_Meta) {
2325 2325
 						$values[$result->ID()] = $result->value();
2326 2326
 					}
2327 2327
 				}
2328 2328
 				return $values;
2329
-			}else{
2329
+			} else {
2330 2330
 				return $default;
2331 2331
 			}
2332 2332
 		}
@@ -2348,20 +2348,20 @@  discard block
 block discarded – undo
2348 2348
 	 * @return array
2349 2349
 	 * @throws \EE_Error
2350 2350
 	 */
2351
-	public function all_extra_meta_array($one_of_each_key = true){
2351
+	public function all_extra_meta_array($one_of_each_key = true) {
2352 2352
 		$return_array = array();
2353
-		if($one_of_each_key){
2353
+		if ($one_of_each_key) {
2354 2354
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
2355
-			foreach($extra_meta_objs as $extra_meta_obj){
2356
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2355
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2356
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2357 2357
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2358 2358
 				}
2359 2359
 			}
2360
-		}else{
2360
+		} else {
2361 2361
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2362
-			foreach($extra_meta_objs as $extra_meta_obj){
2363
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2364
-					if( ! isset($return_array[$extra_meta_obj->key()])){
2362
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2363
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2364
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
2365 2365
 						$return_array[$extra_meta_obj->key()] = array();
2366 2366
 					}
2367 2367
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -2379,19 +2379,19 @@  discard block
 block discarded – undo
2379 2379
 	 * @return string
2380 2380
 	 * @throws \EE_Error
2381 2381
 	 */
2382
-	public function name(){
2382
+	public function name() {
2383 2383
 		//find a field that's not a text field
2384 2384
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2385
-		if($field_we_can_use){
2385
+		if ($field_we_can_use) {
2386 2386
 			return $this->get($field_we_can_use->get_name());
2387
-		}else{
2387
+		} else {
2388 2388
 			$first_few_properties = $this->model_field_array();
2389
-			$first_few_properties = array_slice($first_few_properties,0,3);
2389
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2390 2390
 			$name_parts = array();
2391
-			foreach( $first_few_properties as $name=> $value ){
2391
+			foreach ($first_few_properties as $name=> $value) {
2392 2392
 				$name_parts[] = "$name:$value";
2393 2393
 			}
2394
-			return implode(",",$name_parts);
2394
+			return implode(",", $name_parts);
2395 2395
 		}
2396 2396
 	}
2397 2397
 
@@ -2404,11 +2404,11 @@  discard block
 block discarded – undo
2404 2404
 	 * @return boolean
2405 2405
 	 * @throws \EE_Error
2406 2406
 	 */
2407
-	public function in_entity_map(){
2408
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2407
+	public function in_entity_map() {
2408
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2409 2409
 			//well, if we looked, did we find it in the entity map?
2410 2410
 			return TRUE;
2411
-		}else{
2411
+		} else {
2412 2412
 			return FALSE;
2413 2413
 		}
2414 2414
 	}
@@ -2419,21 +2419,21 @@  discard block
 block discarded – undo
2419 2419
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2420 2420
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2421 2421
 	 */
2422
-	public function refresh_from_db(){
2423
-		if( $this->ID() && $this->in_entity_map() ){
2424
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2425
-		}else{
2422
+	public function refresh_from_db() {
2423
+		if ($this->ID() && $this->in_entity_map()) {
2424
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2425
+		} else {
2426 2426
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2427 2427
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2428 2428
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2429 2429
 			//absolutely nothing in it for this ID
2430
-			if( WP_DEBUG ) {
2430
+			if (WP_DEBUG) {
2431 2431
 				throw new EE_Error(
2432 2432
 					sprintf(
2433
-						__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ),
2433
+						__('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'),
2434 2434
 						$this->ID(),
2435
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2436
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2435
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2436
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2437 2437
 					)
2438 2438
 				);
2439 2439
 			}
@@ -2447,11 +2447,11 @@  discard block
 block discarded – undo
2447 2447
 	 * (probably a bad assumption they have made, oh well)
2448 2448
 	 * @return string
2449 2449
 	 */
2450
-	public function __toString(){
2450
+	public function __toString() {
2451 2451
 		try {
2452
-			return sprintf( '%s (%s)', $this->name(), $this->ID() );
2453
-		} catch ( Exception $e ) {
2454
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
2452
+			return sprintf('%s (%s)', $this->name(), $this->ID());
2453
+		} catch (Exception $e) {
2454
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
2455 2455
 			return '';
2456 2456
 		}
2457 2457
 	}
@@ -2487,16 +2487,16 @@  discard block
 block discarded – undo
2487 2487
 	 * @throws \EE_Error
2488 2488
 	 */
2489 2489
 	public function __sleep() {
2490
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
2491
-			if( $relation_obj instanceof EE_Belongs_To_Relation ) {
2492
-				$classname = 'EE_' . $this->get_model()->get_this_model_name();
2493
-				if( $this->get_one_from_cache( $relation_name ) instanceof $classname &&
2494
-						$this->get_one_from_cache( $relation_name )->ID() ) {
2495
-					$this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() );
2490
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
2491
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2492
+				$classname = 'EE_'.$this->get_model()->get_this_model_name();
2493
+				if ($this->get_one_from_cache($relation_name) instanceof $classname &&
2494
+						$this->get_one_from_cache($relation_name)->ID()) {
2495
+					$this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID());
2496 2496
 				}
2497 2497
 			}
2498 2498
 		}
2499
-		return array_keys( get_object_vars( $this ) );
2499
+		return array_keys(get_object_vars($this));
2500 2500
 	}
2501 2501
 
2502 2502
 
Please login to merge, or discard this patch.
Doc Comments   +12 added lines, -11 removed lines patch added patch discarded remove patch
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	 *
863 863
 	 * @param null  $field_to_order_by  What field is being used as the reference point.
864 864
 	 * @param array $query_params       Any additional conditions on the query.
865
-	 * @param null  $columns_to_select  If left null, then an array of EE_Base_Class objects is returned, otherwise
865
+	 * @param string  $columns_to_select  If left null, then an array of EE_Base_Class objects is returned, otherwise
866 866
 	 *                                  you can indicate just the columns you want returned
867 867
 	 * @return array|EE_Base_Class
868 868
 	 * @throws \EE_Error
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 	 *
887 887
 	 * @param null  $field_to_order_by  What field is being used as the reference point.
888 888
 	 * @param array $query_params       Any additional conditions on the query.
889
-	 * @param null  $columns_to_select  If left null, then an EE_Base_Class object is returned, otherwise
889
+	 * @param string  $columns_to_select  If left null, then an EE_Base_Class object is returned, otherwise
890 890
 	 *                                  you can indicate just the column you want returned
891 891
 	 * @return array|EE_Base_Class
892 892
 	 * @throws \EE_Error
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 	 * This method simply returns the RAW unprocessed value for the given property in this class
956 956
 	 *
957 957
 	 * @param  string $field_name A valid fieldname
958
-	 * @return mixed              Whatever the raw value stored on the property is.
958
+	 * @return integer|null              Whatever the raw value stored on the property is.
959 959
 	 * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist.
960 960
 	 */
961 961
 	public function get_raw($field_name) {
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
 	 *
1056 1056
 	 * @access   protected
1057 1057
 	 * @param  string  $field_name   Field on the instantiated EE_Base_Class child object
1058
-	 * @param null     $dt_frmt      valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format)
1059
-	 * @param null     $tm_frmt      Same as above except this is for time format
1058
+	 * @param string|null     $dt_frmt      valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format)
1059
+	 * @param null|string     $tm_frmt      Same as above except this is for time format
1060 1060
 	 * @param string   $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time.
1061 1061
 	 * @param  boolean $echo         Whether the dtt is echoing using pretty echoing or just returned using vanilla get
1062 1062
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 	 * sets the time on a datetime property
1243 1243
 	 *
1244 1244
 	 * @access protected
1245
-	 * @param string|Datetime $time      a valid time string for php datetime functions (or DateTime object)
1245
+	 * @param string $time      a valid time string for php datetime functions (or DateTime object)
1246 1246
 	 * @param string          $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1247 1247
 	 * @throws \EE_Error
1248 1248
 	 */
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 	 * sets the date on a datetime property
1257 1257
 	 *
1258 1258
 	 * @access protected
1259
-	 * @param string|DateTime $date      a valid date string for php datetime functions ( or DateTime object)
1259
+	 * @param string $date      a valid date string for php datetime functions ( or DateTime object)
1260 1260
 	 * @param string          $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1261 1261
 	 * @throws \EE_Error
1262 1262
 	 */
@@ -1313,6 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 	 * @param mixed (array|string) $args       This is the arguments that will be passed to the callback.
1314 1314
 	 * @param string               $prepend    You can include something to prepend on the timestamp
1315 1315
 	 * @param string               $append     You can include something to append on the timestamp
1316
+	 * @param string $args
1316 1317
 	 * @throws EE_Error
1317 1318
 	 * @return string timestamp
1318 1319
 	 */
@@ -1351,7 +1352,7 @@  discard block
 block discarded – undo
1351 1352
 	 * This calls the `EE_Base_Class::_delete` method.  Child classes wishing to change default behaviour should override
1352 1353
 	 * `EE_Base_Class::_delete` NOT this class.
1353 1354
 	 *
1354
-	 * @return boolean | int
1355
+	 * @return integer | int
1355 1356
 	 * @throws \EE_Error
1356 1357
 	 */
1357 1358
 	public function delete(){
@@ -1384,7 +1385,7 @@  discard block
 block discarded – undo
1384 1385
 	 * This method is called by the public `EE_Base_Class::delete` method.  Any child classes desiring to override default
1385 1386
 	 * functionality for "delete" (which is to call `permanently_delete`) should override this method NOT `EE_Base_Class::delete`
1386 1387
 	 *
1387
-	 * @return bool|int
1388
+	 * @return boolean
1388 1389
 	 * @throws \EE_Error
1389 1390
 	 */
1390 1391
 	protected function _delete() {
@@ -1673,7 +1674,7 @@  discard block
 block discarded – undo
1673 1674
 	 *
1674 1675
 	 * @param  array  $props_n_values   incoming array of properties and their values
1675 1676
 	 * @param  string $classname        the classname of the child class
1676
-	 * @param null    $timezone
1677
+	 * @param string|null    $timezone
1677 1678
 	 * @param array   $date_formats     incoming date_formats in an array where the first value is the
1678 1679
 	 *                                  date_format and the second value is the time format
1679 1680
 	 * @return mixed (EE_Base_Class|bool)
@@ -1749,7 +1750,7 @@  discard block
 block discarded – undo
1749 1750
 	/**
1750 1751
 	 * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee)
1751 1752
 	 * @param string $model_classname
1752
-	 * @param null   $timezone
1753
+	 * @param string|null   $timezone
1753 1754
 	 * @return EEM_Base
1754 1755
 	 */
1755 1756
 	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -519,17 +519,17 @@
 block discarded – undo
519 519
 
520 520
 		//might paypal have changed the taxes?
521 521
 		if( $this->_paypal_taxes && $payment_was_itemized ) {
522
-            // note that we're doing this BEFORE adding shipping;
522
+			// note that we're doing this BEFORE adding shipping;
523 523
 			// we actually want PayPal's shipping to remain non-taxable
524
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
525
-            $this->_line_item->set_total_tax_to(
526
-	            $transaction_total_line_item,
527
-                (float)$update_info['tax'],
528
-                __( 'Taxes', 'event_espresso' ),
529
-                __( 'Calculated by Paypal', 'event_espresso' ),
530
-                'paypal_tax'
531
-            );
532
-            $grand_total_needs_resaving = TRUE;
524
+			$this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
525
+			$this->_line_item->set_total_tax_to(
526
+				$transaction_total_line_item,
527
+				(float)$update_info['tax'],
528
+				__( 'Taxes', 'event_espresso' ),
529
+				__( 'Calculated by Paypal', 'event_espresso' ),
530
+				'paypal_tax'
531
+			);
532
+			$grand_total_needs_resaving = TRUE;
533 533
 		}
534 534
 
535 535
 		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return EEG_Paypal_Standard
69 69
 	 */
70 70
 	public function __construct() {
71
-		$this->set_uses_separate_IPN_request( true ) ;
71
+		$this->set_uses_separate_IPN_request(true);
72 72
 		parent::__construct();
73 73
 	}
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
79 79
 	 * @param array $settings_array
80 80
 	 */
81
-	public function set_settings($settings_array){
81
+	public function set_settings($settings_array) {
82 82
 		parent::set_settings($settings_array);
83 83
 		$this->_gateway_url = $this->_debug_mode
84 84
 			? 'https://www.sandbox.paypal.com/cgi-bin/webscr'
@@ -114,42 +114,42 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$total_discounts_to_cart_total = $transaction->paid();
116 116
 		//only itemize the order if we're paying for the rest of the order's amount
117
-		if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) {
118
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
117
+		if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
118
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
119 119
 			//this payment is for the remaining transaction amount,
120 120
 			//keep track of exactly how much the itemized order amount equals
121 121
 			$itemized_sum = 0;
122 122
 			$shipping_previously_added = 0;
123 123
 			//so let's show all the line items
124
-			foreach($total_line_item->get_items() as $line_item){
125
-				if ( $line_item instanceof EE_Line_Item ) {
124
+			foreach ($total_line_item->get_items() as $line_item) {
125
+				if ($line_item instanceof EE_Line_Item) {
126 126
 					//it's some kind of discount
127
-					if( $line_item->total() < 0 ) {
128
-						$total_discounts_to_cart_total += abs( $line_item->total() );
127
+					if ($line_item->total() < 0) {
128
+						$total_discounts_to_cart_total += abs($line_item->total());
129 129
 						$itemized_sum += $line_item->total();
130 130
 						continue;
131 131
 					}
132 132
 					//dont include shipping again.
133
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
133
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
134 134
 						$shipping_previously_added = $line_item->total();
135 135
 						continue;
136 136
 					}
137
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
138
-						sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ),
137
+					$redirect_args['item_name_'.$item_num] = substr(
138
+						sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()),
139 139
 						0, 127
140 140
 					);
141
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
142
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
141
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
142
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
143 143
 					//if we're not letting PayPal calculate shipping, tell them its 0
144
-					if ( ! $this->_paypal_shipping ) {
145
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
146
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
144
+					if ( ! $this->_paypal_shipping) {
145
+						$redirect_args['shipping_'.$item_num] = '0';
146
+						$redirect_args['shipping2_'.$item_num] = '0';
147 147
 					}
148 148
 					$item_num++;
149 149
 					$itemized_sum += $line_item->total();
150 150
 				}
151 151
 			}
152
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
152
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
153 153
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
154 154
 			//and the itemized sum is LESS than the transaction total
155 155
 			//add another line item
@@ -159,47 +159,47 @@  discard block
 block discarded – undo
159 159
 				$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
160 160
 				2
161 161
 			);
162
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
162
+			if ($itemized_sum_diff_from_txn_total < 0) {
163 163
 				//itemized sum is too big
164
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
165
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
166
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
167
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
168
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
169
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
164
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
165
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
166
+				$redirect_args['item_name_'.$item_num] = substr(
167
+						__('Other charges', 'event_espresso'), 0, 127 );
168
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
169
+				$redirect_args['quantity_'.$item_num] = 1;
170 170
 				$item_num++;
171 171
 			}
172
-			if( $total_discounts_to_cart_total > 0 ) {
173
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
172
+			if ($total_discounts_to_cart_total > 0) {
173
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
174 174
 			}
175 175
 			//add our taxes to the order if we're NOT using PayPal's
176
-			if( ! $this->_paypal_taxes ){
176
+			if ( ! $this->_paypal_taxes) {
177 177
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
178 178
 			}
179 179
 		} else {
180
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
180
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
181 181
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
182
-			$redirect_args['item_name_' . $item_num] = substr(
183
-				sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ),
182
+			$redirect_args['item_name_'.$item_num] = substr(
183
+				sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()),
184 184
 				0, 127
185 185
 			);
186
-			$redirect_args['amount_' . $item_num] = $payment->amount();
187
-			$redirect_args['shipping_' . $item_num ] = '0';
188
-			$redirect_args['shipping2_' . $item_num ] = '0';
186
+			$redirect_args['amount_'.$item_num] = $payment->amount();
187
+			$redirect_args['shipping_'.$item_num] = '0';
188
+			$redirect_args['shipping2_'.$item_num] = '0';
189 189
 			$redirect_args['tax_cart'] = '0';
190 190
 			$item_num++;
191 191
 		}
192 192
 
193
-		if($this->_debug_mode){
194
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
195
-			$redirect_args['amount_' . $item_num] = 0;
193
+		if ($this->_debug_mode) {
194
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
195
+			$redirect_args['amount_'.$item_num] = 0;
196 196
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
197
-			$redirect_args['os0_' . $item_num] = $notify_url;
197
+			$redirect_args['os0_'.$item_num] = $notify_url;
198 198
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
199
-			$redirect_args['os1_' . $item_num] = $return_url;
199
+			$redirect_args['os1_'.$item_num] = $return_url;
200 200
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
201
-			$redirect_args['shipping_' . $item_num ] = '0';
202
-			$redirect_args['shipping2_' . $item_num ] = '0';
201
+			$redirect_args['shipping_'.$item_num] = '0';
202
+			$redirect_args['shipping2_'.$item_num] = '0';
203 203
 		}
204 204
 
205 205
 		$redirect_args['business'] = $this->_paypal_id;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 		$redirect_args['cmd'] = '_cart';
210 210
 		$redirect_args['upload'] = 1;
211 211
 		$redirect_args['currency_code'] = $payment->currency_code();
212
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
213
-		if($this->_image_url){
212
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
213
+		if ($this->_image_url) {
214 214
 			$redirect_args['image_url'] = $this->_image_url;
215 215
 		}
216 216
 		$redirect_args['no_shipping'] = $this->_shipping_details;
217
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
217
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
218 218
 
219
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
219
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
220 220
 
221 221
 		$payment->set_redirect_url($this->_gateway_url);
222 222
 		$payment->set_redirect_args($redirect_args);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$this->log(
225 225
 			array(
226 226
 				'message'     => sprintf(
227
-					__( 'PayPal payment request initiated.', 'event_espresso' )
227
+					__('PayPal payment request initiated.', 'event_espresso')
228 228
 				),
229 229
 				'transaction' => $transaction->model_field_array(),
230 230
 			),
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 	 * @return \EEI_Payment updated
245 245
 	 * @throws \EE_Error
246 246
 	 */
247
-	public function handle_payment_update( $update_info, $transaction ){
247
+	public function handle_payment_update($update_info, $transaction) {
248 248
 		// verify there's payment data that's been sent
249
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
249
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
250 250
 			// log the results
251 251
 			$this->log(
252 252
 				array(
253 253
 					'message' => sprintf(
254
-						__( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' )
254
+						__('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso')
255 255
 					),
256 256
 					'update_info' => $update_info,
257 257
 				),
@@ -259,50 +259,50 @@  discard block
 block discarded – undo
259 259
 			);
260 260
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
261 261
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
262
-			if ( isset( $update_info[ 'tx' ] ) ) {
262
+			if (isset($update_info['tx'])) {
263 263
 				return $transaction->last_payment();
264 264
 			} else {
265 265
 				return null;
266 266
 			}
267 267
 		}
268
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
269
-		if ( ! $payment instanceof EEI_Payment ) {
268
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
269
+		if ( ! $payment instanceof EEI_Payment) {
270 270
 			$payment = $transaction->last_payment();
271 271
 		}
272 272
 		// ok, then validate the IPN. Even if we've already processed this payment,
273 273
 		// let PayPal know we don't want to hear from them anymore!
274
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
274
+		if ( ! $this->validate_ipn($update_info, $payment)) {
275 275
 			return $payment;
276 276
 		}
277 277
 		//ok, well let's process this payment then!
278
-		switch ( $update_info[ 'payment_status' ] ) {
278
+		switch ($update_info['payment_status']) {
279 279
 
280 280
 			case 'Completed' :
281 281
 				$status = $this->_pay_model->approved_status();
282
-				$gateway_response = __( 'The payment is approved.', 'event_espresso' );
282
+				$gateway_response = __('The payment is approved.', 'event_espresso');
283 283
 				break;
284 284
 
285 285
 			case 'Pending' :
286 286
 				$status = $this->_pay_model->pending_status();
287
-				$gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
287
+				$gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
288 288
 				break;
289 289
 
290 290
 			case 'Denied' :
291 291
 				$status = $this->_pay_model->declined_status();
292
-				$gateway_response = __( 'The payment has been declined.', 'event_espresso' );
292
+				$gateway_response = __('The payment has been declined.', 'event_espresso');
293 293
 				break;
294 294
 
295 295
 			case 'Expired' :
296 296
 			case 'Failed' :
297 297
 				$status = $this->_pay_model->failed_status();
298
-				$gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' );
298
+				$gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso');
299 299
 				break;
300 300
 
301 301
 			case 'Refunded' :
302 302
 			case 'Partially_Refunded' :
303 303
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
304 304
 				$status = $this->_pay_model->approved_status();
305
-				$gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
305
+				$gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
306 306
 				break;
307 307
 
308 308
 			case 'Voided' :
@@ -310,28 +310,28 @@  discard block
 block discarded – undo
310 310
 			case 'Canceled_Reversal' :
311 311
 			default :
312 312
 				$status = $this->_pay_model->cancelled_status();
313
-				$gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
313
+				$gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
314 314
 				break;
315 315
 
316 316
 		}
317 317
 
318 318
 		//check if we've already processed this payment
319
-		if ( $payment instanceof EEI_Payment ) {
319
+		if ($payment instanceof EEI_Payment) {
320 320
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
321
-			if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) {
321
+			if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) {
322 322
 				// DUPLICATED IPN! dont bother updating transaction foo!;
323 323
 				$message_log = sprintf(
324
-					__( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ),
324
+					__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'),
325 325
 					$payment->ID()
326 326
 				);
327 327
 			} else {
328 328
 				// new payment yippee !!!
329
-				$payment->set_status( $status );
330
-				$payment->set_amount( (float)$update_info[ 'mc_gross' ] );
331
-				$payment->set_gateway_response( $gateway_response );
332
-				$payment->set_details( $update_info );
333
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
334
-				$message_log = __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' );
329
+				$payment->set_status($status);
330
+				$payment->set_amount((float) $update_info['mc_gross']);
331
+				$payment->set_gateway_response($gateway_response);
332
+				$payment->set_details($update_info);
333
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
334
+				$message_log = __('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso');
335 335
 			}
336 336
 			$this->log(
337 337
 				array(
@@ -343,16 +343,16 @@  discard block
 block discarded – undo
343 343
 				$payment
344 344
 			);
345 345
 		}
346
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
346
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
347 347
 		// kill request here if this is a refund
348 348
 		if (
349 349
 			(
350
-				$update_info[ 'payment_status' ] === 'Refunded'
351
-				|| $update_info[ 'payment_status' ] === 'Partially_Refunded'
350
+				$update_info['payment_status'] === 'Refunded'
351
+				|| $update_info['payment_status'] === 'Partially_Refunded'
352 352
 			)
353
-			&& apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
353
+			&& apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)
354 354
 		) {
355
-			status_header( 200 );
355
+			status_header(200);
356 356
 			exit();
357 357
 		}
358 358
 		return $payment;
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
 	 * @return boolean
370 370
 	 * @throws \EE_Error
371 371
 	 */
372
-	public function validate_ipn( $update_info, $payment ) {
372
+	public function validate_ipn($update_info, $payment) {
373 373
 		//allow us to skip validating IPNs with PayPal (useful for testing)
374
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
374
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
375 375
 			return true;
376 376
 		}
377 377
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -379,22 +379,22 @@  discard block
 block discarded – undo
379 379
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
380 380
 		// Instead, read raw POST data from the input stream.
381 381
 		// @see https://gist.github.com/xcommerce-gists/3440401
382
-		$raw_post_data = file_get_contents( 'php://input' );
383
-		$raw_post_array = explode( '&', $raw_post_data );
382
+		$raw_post_data = file_get_contents('php://input');
383
+		$raw_post_array = explode('&', $raw_post_data);
384 384
 		$update_info = array();
385
-		foreach ( $raw_post_array as $keyval ) {
386
-			$keyval = explode( '=', $keyval );
387
-			if ( count( $keyval ) === 2 ) {
388
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
385
+		foreach ($raw_post_array as $keyval) {
386
+			$keyval = explode('=', $keyval);
387
+			if (count($keyval) === 2) {
388
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
389 389
 			}
390 390
 		}
391 391
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
392 392
 		$req = 'cmd=_notify-validate';
393
-		$uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1
393
+		$uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1
394 394
 			? true
395 395
 			: false;
396
-		foreach ( $update_info as $key => $value ) {
397
-			$value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value );
396
+		foreach ($update_info as $key => $value) {
397
+			$value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value);
398 398
 			$req .= "&$key=$value";
399 399
 		}
400 400
 		// HTTP POST the complete, unaltered IPN back to PayPal
@@ -403,38 +403,38 @@  discard block
 block discarded – undo
403 403
 			array(
404 404
 				'body' 				=> $req,
405 405
 				'sslverify' 		=> false,
406
-				'timeout' 		=> 60 ,
406
+				'timeout' 		=> 60,
407 407
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
408 408
 				// plz see: https://github.com/websharks/s2member/issues/610
409
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
409
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
410 410
 				'httpversion' => '1.1'
411 411
 			)
412 412
 		);
413 413
 		// then check the response
414 414
 		if (
415
-			array_key_exists( 'body', $response )
416
-			&& ! is_wp_error( $response )
417
-			&& strcmp( $response[ 'body' ], "VERIFIED" ) === 0
415
+			array_key_exists('body', $response)
416
+			&& ! is_wp_error($response)
417
+			&& strcmp($response['body'], "VERIFIED") === 0
418 418
 		) {
419 419
 			return true;
420 420
 		}
421 421
 		// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
422 422
 		// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
423
-		if( $response instanceof WP_Error ) {
423
+		if ($response instanceof WP_Error) {
424 424
 			$error_msg = sprintf(
425
-				__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ),
425
+				__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
426 426
 				$response->get_error_code(),
427 427
 				$response->get_error_message(),
428
-				print_r( $response->get_error_data(), true )
428
+				print_r($response->get_error_data(), true)
429 429
 			);
430
-		} elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) {
431
-			$error_msg = $response[ 'body' ];
430
+		} elseif (is_array($response) && isset($response['body'])) {
431
+			$error_msg = $response['body'];
432 432
 		} else {
433
-			$error_msg = print_r( $response, true );
433
+			$error_msg = print_r($response, true);
434 434
 		}
435
-		$payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) );
436
-		$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
437
-		$payment->set_status( EEM_Payment::status_id_failed );
435
+		$payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg));
436
+		$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
437
+		$payment->set_status(EEM_Payment::status_id_failed);
438 438
 		// log the results
439 439
 		$this->log(
440 440
 			array(
@@ -455,9 +455,9 @@  discard block
 block discarded – undo
455 455
 	 */
456 456
 	protected function _process_response_url() {
457 457
 		EE_Registry::instance()->load_helper('URL');
458
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
458
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
459 459
 			$url = is_ssl() ? 'https://' : 'http://';
460
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
460
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
461 461
 			$url .= EEH_URL::filter_input_server_url();
462 462
 		} else {
463 463
 			$url = 'unknown';
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
 	 * @param EEI_Payment $payment
475 475
 	 * @throws \EE_Error
476 476
 	 */
477
-	public function update_txn_based_on_payment( $payment ) {
477
+	public function update_txn_based_on_payment($payment) {
478 478
 		$update_info = $payment->details();
479 479
 		/** @var EE_Transaction $transaction */
480 480
 		$transaction = $payment->transaction();
481
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
482
-		if( ! $transaction ){
481
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
482
+		if ( ! $transaction) {
483 483
 			$this->log(
484 484
 				__(
485 485
 					'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly',
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
 			);
490 490
 			return;
491 491
 		}
492
-		if(
493
-			! is_array( $update_info )
494
-			|| ! isset( $update_info[ 'mc_shipping' ] )
495
-			|| ! isset( $update_info[ 'tax' ] )
492
+		if (
493
+			! is_array($update_info)
494
+			|| ! isset($update_info['mc_shipping'])
495
+			|| ! isset($update_info['tax'])
496 496
 		) {
497 497
 			$this->log(
498 498
 				array(
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 			);
508 508
 			return;
509 509
 		}
510
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
510
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
511 511
 			$this->log(
512 512
 				array(
513 513
 					'message' => __(
@@ -526,44 +526,44 @@  discard block
 block discarded – undo
526 526
 		$transaction_total_line_item = $transaction->total_line_item();
527 527
 
528 528
 		//might paypal have changed the taxes?
529
-		if( $this->_paypal_taxes && $payment_was_itemized ) {
529
+		if ($this->_paypal_taxes && $payment_was_itemized) {
530 530
             // note that we're doing this BEFORE adding shipping;
531 531
 			// we actually want PayPal's shipping to remain non-taxable
532
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
532
+            $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping');
533 533
             $this->_line_item->set_total_tax_to(
534 534
 	            $transaction_total_line_item,
535
-                (float)$update_info['tax'],
536
-                __( 'Taxes', 'event_espresso' ),
537
-                __( 'Calculated by Paypal', 'event_espresso' ),
535
+                (float) $update_info['tax'],
536
+                __('Taxes', 'event_espresso'),
537
+                __('Calculated by Paypal', 'event_espresso'),
538 538
                 'paypal_tax'
539 539
             );
540 540
             $grand_total_needs_resaving = TRUE;
541 541
 		}
542 542
 
543
-		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
543
+		$shipping_amount = (float) $update_info['mc_shipping'];
544 544
 		//might paypal have added shipping?
545
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
545
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
546 546
 			$this->_line_item->add_unrelated_item(
547 547
 				$transaction_total_line_item,
548
-				sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
548
+				sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
549 549
 				$shipping_amount,
550 550
 				__('Shipping charges calculated by Paypal', 'event_espresso'),
551 551
 				1,
552 552
 				false,
553
-				'paypal_shipping_' . $transaction->ID()
553
+				'paypal_shipping_'.$transaction->ID()
554 554
 			);
555 555
 			$grand_total_needs_resaving = true;
556 556
 		}
557 557
 
558
-		if( $grand_total_needs_resaving ){
559
-			$transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() );
558
+		if ($grand_total_needs_resaving) {
559
+			$transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID());
560 560
 			/** @var EE_Registration_Processor $registration_processor */
561
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
562
-			$registration_processor->update_registration_final_prices( $transaction );
561
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
562
+			$registration_processor->update_registration_final_prices($transaction);
563 563
 		}
564 564
 		$this->log(
565 565
 			array(
566
-				'message'                     => __( 'Updated transaction related to payment', 'event_espresso' ),
566
+				'message'                     => __('Updated transaction related to payment', 'event_espresso'),
567 567
 				'url'                         => $this->_process_response_url(),
568 568
 				'transaction (updated)'       => $transaction->model_field_array(),
569 569
 				'payment (updated)'           => $payment->model_field_array(),
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_PMT_Paypal_Standard.pm.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @since 				$VID:$
11 11
  *
12 12
  */
13
-class EE_PMT_Paypal_Standard extends EE_PMT_Base{
13
+class EE_PMT_Paypal_Standard extends EE_PMT_Base {
14 14
 
15 15
 	const shipping_info_none = 1;
16 16
 	const shipping_info_optional = 0;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @param \EE_Transaction $transaction
47 47
 	 * @return NULL
48 48
 	 */
49
-	public function generate_new_billing_form( EE_Transaction $transaction = NULL ) {
49
+	public function generate_new_billing_form(EE_Transaction $transaction = NULL) {
50 50
 		return NULL;
51 51
 	}
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 * @throws \EE_Error
60 60
 	 */
61 61
 	public function generate_new_settings_form() {
62
-		require_once( $this->file_folder() . 'EE_Paypal_Standard_Form.form.php' );
63
-		$form =  new EE_Paypal_Standard_Form( $this );
64
-		$form->get_input( 'PMD_debug_mode' )->set_html_label_text(
65
-			sprintf( __( "Use PayPal Sandbox %s", 'event_espresso' ), $this->get_help_tab_link() )
62
+		require_once($this->file_folder().'EE_Paypal_Standard_Form.form.php');
63
+		$form = new EE_Paypal_Standard_Form($this);
64
+		$form->get_input('PMD_debug_mode')->set_html_label_text(
65
+			sprintf(__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
66 66
 		);
67
-		$form->get_input( 'shipping_details' )->set_html_label_text(
68
-			sprintf( __( "Shipping Address Options %s", "event_espresso" ), $this->get_help_tab_link() )
67
+		$form->get_input('shipping_details')->set_html_label_text(
68
+			sprintf(__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link())
69 69
 		);
70 70
 		return $form;
71 71
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @see EE_PMT_Base::help_tabs_config()
78 78
 	 * @return array
79 79
 	 */
80
-	public function help_tabs_config(){
80
+	public function help_tabs_config() {
81 81
 		return array(
82 82
 			$this->get_help_tab_name() => array(
83 83
 				'title'=>  __("PayPal Standard Settings", 'event_espresso'),
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @return EE_Payment
100 100
 	 * @throws \EE_Error
101 101
 	 */
102
-	public function finalize_payment_for($transaction){
102
+	public function finalize_payment_for($transaction) {
103 103
 		// PayPal standard actually sends the IPN info along with the user when they return to our site
104 104
 		// so in case the IPN is arriving later, let's try to process an IPN!
105
-		if( $_SERVER['REQUEST_METHOD'] === 'POST' ){
106
-			return $this->handle_ipn($_POST, $transaction );
107
-		}else{
108
-			return parent::finalize_payment_for( $transaction );
105
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
106
+			return $this->handle_ipn($_POST, $transaction);
107
+		} else {
108
+			return parent::finalize_payment_for($transaction);
109 109
 		}
110 110
 	}
111 111
 
Please login to merge, or discard this patch.
core/db_models/relations/EE_Model_Relation_Base.php 4 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,8 +151,8 @@
 block discarded – undo
151 151
 		}
152 152
 		$query_params = $this->_disable_default_where_conditions_on_query_param($query_params);
153 153
 		$query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name()
154
-		                                   . "."
155
-		                                   . $this->get_this_model()->get_primary_key_field()->get_name();
154
+										   . "."
155
+										   . $this->get_this_model()->get_primary_key_field()->get_name();
156 156
 		$model_object_id = $this->_get_model_object_id( $model_object_or_id );
157 157
 		$query_params[0][$query_param_where_this_model_pk] = $model_object_id;
158 158
 		return $this->get_other_model()->get_all($query_params);
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @subpackage    core
14 14
  * @author        Michael Nelson
15 15
  */
16
-abstract class EE_Model_Relation_Base{
16
+abstract class EE_Model_Relation_Base {
17 17
 	/**
18 18
 	 * The model name of which this relation is a component (ie, the model that called new EE_Model_Relation_Base)
19 19
 	 * @var string eg Event, Question_Group, Registration
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 * @param boolean $block_deletes if there are related models across this relation, block (prevent and add an error) the deletion of this model
49 49
 	 * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default
50 50
 	 */
51
-	public function __construct($block_deletes, $blocking_delete_error_message){
51
+	public function __construct($block_deletes, $blocking_delete_error_message) {
52 52
 		$this->_blocking_delete = $block_deletes;
53
-		$this->_blocking_delete_error_message=$blocking_delete_error_message;
53
+		$this->_blocking_delete_error_message = $blocking_delete_error_message;
54 54
 	}
55 55
 
56 56
 
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 * @param $other_model_name
61 61
 	 * @throws EE_Error
62 62
 	 */
63
-	public function _construct_finalize_set_models($this_model_name, $other_model_name){
63
+	public function _construct_finalize_set_models($this_model_name, $other_model_name) {
64 64
 		$this->_this_model_name = $this_model_name;
65 65
 		$this->_other_model_name = $other_model_name;
66
-		if(is_string($this->_blocking_delete)){
66
+		if (is_string($this->_blocking_delete)) {
67 67
 			throw new EE_Error(sprintf(__("When instantiating the relation of type %s from %s to %s, the \$block_deletes argument should be a boolean, not a string (%s)", "event_espresso"),
68
-						get_class($this),$this_model_name,$other_model_name,$this->_blocking_delete));
68
+						get_class($this), $this_model_name, $other_model_name, $this->_blocking_delete));
69 69
 		}
70 70
 	}
71 71
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * Gets the model where this relation is defined.
76 76
 	 * @return EEM_Base
77 77
 	 */
78
-	public function get_this_model(){
78
+	public function get_this_model() {
79 79
 		return $this->_get_model($this->_this_model_name);
80 80
 	}
81 81
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * this relation object was defined on get_this_model(), get_other_model() is the other one)
87 87
 	 * @return EEM_Base
88 88
 	 */
89
-	public function get_other_model(){
89
+	public function get_other_model() {
90 90
 		return $this->_get_model($this->_other_model_name);
91 91
 	}
92 92
 
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @param string $model_name like Event, Question_Group, etc. omit the EEM_
98 98
 	 * @return EEM_Base
99 99
 	 */
100
-	protected function _get_model($model_name){
101
-		$modelInstance = EE_Registry::instance()->load_model( $model_name );
102
-		$modelInstance->set_timezone( $this->_timezone );
100
+	protected function _get_model($model_name) {
101
+		$modelInstance = EE_Registry::instance()->load_model($model_name);
102
+		$modelInstance->set_timezone($this->_timezone);
103 103
 		return $modelInstance;
104 104
 	}
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * entirely possible that relations may be called from a model and we need to make sure those relations have their timezone set correctly.
110 110
 	 * @param string $timezone timezone to set.
111 111
 	 */
112
-	public function set_timezone( $timezone ) {
113
-		if($timezone !== NULL){
112
+	public function set_timezone($timezone) {
113
+		if ($timezone !== NULL) {
114 114
 			$this->_timezone = $timezone;
115 115
 		}
116 116
 	}
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @param string $extra_join_sql
127 127
 	 * @return string
128 128
 	 */
129
-	protected function _left_join($other_table,$other_table_alias,$other_table_column,$this_table_alias,$this_table_join_column, $extra_join_sql = ''){
130
-		return " LEFT JOIN ".$other_table." AS ".$other_table_alias. " ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column. ($extra_join_sql ? " AND $extra_join_sql" : '');
129
+	protected function _left_join($other_table, $other_table_alias, $other_table_column, $this_table_alias, $this_table_join_column, $extra_join_sql = '') {
130
+		return " LEFT JOIN ".$other_table." AS ".$other_table_alias." ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column.($extra_join_sql ? " AND $extra_join_sql" : '');
131 131
 	}
132 132
 
133 133
 
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 * @return EE_Base_Class[]
146 146
 	 * @throws \EE_Error
147 147
 	 */
148
-	public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ){
149
-		if( $values_already_prepared_by_model_object !== false ) {
150
-			EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' );
148
+	public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) {
149
+		if ($values_already_prepared_by_model_object !== false) {
150
+			EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1');
151 151
 		}
152 152
 		$query_params = $this->_disable_default_where_conditions_on_query_param($query_params);
153 153
 		$query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name()
154 154
 		                                   . "."
155 155
 		                                   . $this->get_this_model()->get_primary_key_field()->get_name();
156
-		$model_object_id = $this->_get_model_object_id( $model_object_or_id );
156
+		$model_object_id = $this->_get_model_object_id($model_object_or_id);
157 157
 		$query_params[0][$query_param_where_this_model_pk] = $model_object_id;
158 158
 		return $this->get_other_model()->get_all($query_params);
159 159
 	}
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 * @param string $query_params
166 166
 	 * @return array
167 167
 	 */
168
-	protected function _disable_default_where_conditions_on_query_param($query_params){
169
-		if( ! isset($query_params['default_where_conditions'])){
170
-			$query_params['default_where_conditions']='none';
168
+	protected function _disable_default_where_conditions_on_query_param($query_params) {
169
+		if ( ! isset($query_params['default_where_conditions'])) {
170
+			$query_params['default_where_conditions'] = 'none';
171 171
 		}
172 172
 		return $query_params;
173 173
 	}
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 * @return int of how many related models got deleted
186 186
 	 * @throws \EE_Error
187 187
 	 */
188
-	public function delete_all_related($model_object_or_id,$query_params = array()){
188
+	public function delete_all_related($model_object_or_id, $query_params = array()) {
189 189
 		//for each thing we would delete,
190
-		$related_model_objects = $this->get_all_related($model_object_or_id,$query_params);
190
+		$related_model_objects = $this->get_all_related($model_object_or_id, $query_params);
191 191
 		//determine if it's blocked by anything else before it can be deleted
192 192
 		$deleted_count = 0;
193
-		foreach($related_model_objects as $related_model_object){
193
+		foreach ($related_model_objects as $related_model_object) {
194 194
 			$delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id);
195 195
 			/* @var $model_object_or_id EE_Base_Class */
196
-			if( ! $delete_is_blocked ){
196
+			if ( ! $delete_is_blocked) {
197 197
 				$this->remove_relation_to($model_object_or_id, $related_model_object);
198 198
 				$related_model_object->delete();
199 199
 				$deleted_count++;
@@ -215,27 +215,27 @@  discard block
 block discarded – undo
215 215
 	 * @return int of how many related models got deleted
216 216
 	 * @throws \EE_Error
217 217
 	 */
218
-	public function delete_related_permanently($model_object_or_id,$query_params = array()){
218
+	public function delete_related_permanently($model_object_or_id, $query_params = array()) {
219 219
 		//for each thing we would delete,
220
-		$related_model_objects = $this->get_all_related($model_object_or_id,$query_params);
220
+		$related_model_objects = $this->get_all_related($model_object_or_id, $query_params);
221 221
 		//determine if it's blocked by anything else before it can be deleted
222 222
 		$deleted_count = 0;
223
-		foreach($related_model_objects as $related_model_object){
223
+		foreach ($related_model_objects as $related_model_object) {
224 224
 			$delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id);
225 225
 			/* @var $model_object_or_id EE_Base_Class */
226
-			if( $related_model_object instanceof EE_Soft_Delete_Base_Class ){
226
+			if ($related_model_object instanceof EE_Soft_Delete_Base_Class) {
227 227
 				$this->remove_relation_to($model_object_or_id, $related_model_object);
228 228
 				$deleted_count++;
229
-				if( ! $delete_is_blocked ){
229
+				if ( ! $delete_is_blocked) {
230 230
 					$related_model_object->delete_permanently();
231
-				}else{
231
+				} else {
232 232
 					//delete is blocked
233 233
 					//brent and darren, in this case, wanted to just soft delete it then
234 234
 					$related_model_object->delete();
235 235
 				}
236
-			}else{
236
+			} else {
237 237
 				//its not a soft-deletable thing anyways. do the normal logic.
238
-				if( ! $delete_is_blocked ){
238
+				if ( ! $delete_is_blocked) {
239 239
 					$this->remove_relation_to($model_object_or_id, $related_model_object);
240 240
 					$related_model_object->delete();
241 241
 					$deleted_count++;
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	protected function _get_model_object_id($model_object_or_id) {
257 257
 		$model_object_id = $model_object_or_id;
258
-		if($model_object_or_id instanceof EE_Base_Class){
258
+		if ($model_object_or_id instanceof EE_Base_Class) {
259 259
 			$model_object_id = $model_object_or_id->ID();
260 260
 		}
261
-		if( ! $model_object_id){
262
-			throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"),$this->get_other_model()->get_this_model_name(),$this->get_this_model()->get_this_model_name()));
261
+		if ( ! $model_object_id) {
262
+			throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"), $this->get_other_model()->get_this_model_name(), $this->get_this_model()->get_this_model_name()));
263 263
 		}
264 264
 		return $model_object_id;
265 265
 	}
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 	 * @return EE_Base_Class[]
314 314
 	 * @throws \EE_Error
315 315
 	 */
316
-	public function remove_relations($this_obj_or_id,$where_query_param = array()){
317
-		$related_things = $this->get_all_related($this_obj_or_id,array($where_query_param));
316
+	public function remove_relations($this_obj_or_id, $where_query_param = array()) {
317
+		$related_things = $this->get_all_related($this_obj_or_id, array($where_query_param));
318 318
 		$objs_removed = array();
319
-		foreach($related_things as $related_thing){
319
+		foreach ($related_things as $related_thing) {
320 320
 			$objs_removed[] = $this->remove_relation_to($this_obj_or_id, $related_thing);
321 321
 		}
322 322
 		return $objs_removed;
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 * related objects exist, returns false.
330 330
 	 * @return boolean
331 331
 	 */
332
-	public function block_delete_if_related_models_exist(){
332
+	public function block_delete_if_related_models_exist() {
333 333
 		return $this->_blocking_delete;
334 334
 	}
335 335
 
@@ -338,13 +338,13 @@  discard block
 block discarded – undo
338 338
 	 * Gets the error message to show
339 339
 	 * @return string
340 340
 	 */
341
-	public function get_deletion_error_message(){
342
-		if($this->_blocking_delete_error_message){
341
+	public function get_deletion_error_message() {
342
+		if ($this->_blocking_delete_error_message) {
343 343
 			return $this->_blocking_delete_error_message;
344
-		}else{
344
+		} else {
345 345
 //			return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2));
346 346
 			return sprintf(
347
-				__( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"),
347
+				__('This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"),
348 348
 				$this->get_this_model()->item_name(1),
349 349
 				$this->get_other_model()->item_name(1),
350 350
 				$this->get_other_model()->item_name(2)
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
 				$deleted_count++;
229 229
 				if( ! $delete_is_blocked ){
230 230
 					$related_model_object->delete_permanently();
231
-				}else{
231
+				} else{
232 232
 					//delete is blocked
233 233
 					//brent and darren, in this case, wanted to just soft delete it then
234 234
 					$related_model_object->delete();
235 235
 				}
236
-			}else{
236
+			} else{
237 237
 				//its not a soft-deletable thing anyways. do the normal logic.
238 238
 				if( ! $delete_is_blocked ){
239 239
 					$this->remove_relation_to($model_object_or_id, $related_model_object);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	public function get_deletion_error_message(){
342 342
 		if($this->_blocking_delete_error_message){
343 343
 			return $this->_blocking_delete_error_message;
344
-		}else{
344
+		} else{
345 345
 //			return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2));
346 346
 			return sprintf(
347 347
 				__( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"),
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
 	/**
121 121
 	 * @param        $other_table
122
-	 * @param        $other_table_alias
122
+	 * @param        string $other_table_alias
123 123
 	 * @param        $other_table_column
124
-	 * @param        $this_table_alias
124
+	 * @param        string $this_table_alias
125 125
 	 * @param        $this_table_join_column
126 126
 	 * @param string $extra_join_sql
127 127
 	 * @return string
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	/**
164 164
 	 * Alters the $query_params to disable default where conditions, unless otherwise specified
165 165
 	 * @param string $query_params
166
-	 * @return array
166
+	 * @return string
167 167
 	 */
168 168
 	protected function _disable_default_where_conditions_on_query_param($query_params){
169 169
 		if( ! isset($query_params['default_where_conditions'])){
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * Note: If the related model is extends EEM_Soft_Delete_Base, then the related
181 181
 	 * model objects will only be soft-deleted.
182 182
 	 *
183
-	 * @param EE_Base_Class|int|string $model_object_or_id
183
+	 * @param EE_Base_Class|null $model_object_or_id
184 184
 	 * @param array                    $query_params
185 185
 	 * @return int of how many related models got deleted
186 186
 	 * @throws \EE_Error
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * Note: If the related model is extends EEM_Soft_Delete_Base, then the related
211 211
 	 * model objects will only be soft-deleted.
212 212
 	 *
213
-	 * @param EE_Base_Class|int|string $model_object_or_id
213
+	 * @param EE_Base_Class|null $model_object_or_id
214 214
 	 * @param array                    $query_params
215 215
 	 * @return int of how many related models got deleted
216 216
 	 * @throws \EE_Error
Please login to merge, or discard this patch.
core/db_models/relations/EE_HABTM_Relation.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
3
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
4 4
 
5 5
 
6 6
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @subpackage    core
12 12
  * @author        Michael Nelson
13 13
  */
14
-class EE_HABTM_Relation extends EE_Model_Relation_Base{
14
+class EE_HABTM_Relation extends EE_Model_Relation_Base {
15 15
 	/**
16 16
 	 * Model which defines the relation between two other models. Eg, the EE_Event_Question_Group model,
17 17
 	 * which joins EE_Event and EE_Question_Group
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param boolean $block_deletes                 for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model
33 33
 	 * @param string  $blocking_delete_error_message a customized error message on blocking deletes instead of the default
34 34
 	 */
35
-	public function __construct($joining_model_name,$block_deletes = true, $blocking_delete_error_message =''){
35
+	public function __construct($joining_model_name, $block_deletes = true, $blocking_delete_error_message = '') {
36 36
 		$this->_joining_model_name = $joining_model_name;
37 37
 		parent::__construct($block_deletes, $blocking_delete_error_message);
38 38
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * Gets the joining model's object
41 41
 	 * @return EEM_Base
42 42
 	 */
43
-	public function get_join_model(){
43
+	public function get_join_model() {
44 44
 		return $this->_get_model($this->_joining_model_name);
45 45
 	}
46 46
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 	 * @return string of SQL
54 54
 	 * @throws \EE_Error
55 55
 	 */
56
-	public function get_join_to_intermediate_model_statement($model_relation_chain){
56
+	public function get_join_to_intermediate_model_statement($model_relation_chain) {
57 57
 		//create sql like
58 58
 		//LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this
59 59
 		//LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk
60 60
 		//remember the model relation chain to the JOIN model, because we'll
61 61
 		//need it for get_join_statement()
62 62
 		$this->_model_relation_chain_to_join_model = $model_relation_chain;
63
-		$this_table_pk_field = $this->get_this_model()->get_primary_key_field();//get_foreign_key_to($this->get_other_model()->get_this_model_name());
63
+		$this_table_pk_field = $this->get_this_model()->get_primary_key_field(); //get_foreign_key_to($this->get_other_model()->get_this_model_name());
64 64
 		$join_table_fk_field_to_this_table = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
65
-		$this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
65
+		$this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias();
66 66
 
67
-		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
67
+		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias();
68 68
 		$join_table = $this->get_join_model()->get_table_for_alias($join_table_alias);
69 69
 		//phew! ok, we have all the info we need, now we can create the SQL join string
70
-		$SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(), $this_table_alias, $this_table_pk_field->get_table_column()) . $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
70
+		$SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(), $this_table_alias, $this_table_pk_field->get_table_column()).$this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
71 71
 
72 72
 		return $SQL;
73 73
 	}
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 	 * @return string of SQL
85 85
 	 * @throws \EE_Error
86 86
 	 */
87
-	public function get_join_statement($model_relation_chain){
88
-		if( $this->_model_relation_chain_to_join_model === NULL ){
89
-			throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' )));
87
+	public function get_join_statement($model_relation_chain) {
88
+		if ($this->_model_relation_chain_to_join_model === NULL) {
89
+			throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso')));
90 90
 		}
91 91
 		$join_table_fk_field_to_this_table = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
92
-		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
92
+		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias();
93 93
 		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
94 94
 		$join_table_fk_field_to_other_table = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
95
-		$other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
95
+		$other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias();
96 96
 		$other_table = $this->get_other_model()->get_table_for_alias($other_table_alias);
97 97
 
98
-		$SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $join_table_alias, $join_table_fk_field_to_other_table->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
98
+		$SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $join_table_alias, $join_table_fk_field_to_other_table->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
99 99
 		return $SQL;
100 100
 	}
101 101
 
@@ -112,37 +112,37 @@  discard block
 block discarded – undo
112 112
 	 * @return EE_Base_Class
113 113
 	 * @throws \EE_Error
114 114
 	 */
115
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
115
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
116 116
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
117 117
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
118 118
 		//check if such a relationship already exists
119 119
 		 $join_model_fk_to_this_model = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
120 120
 		 $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
121 121
 
122
-		 $cols_n_values =  array(
122
+		 $cols_n_values = array(
123 123
 				 $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(),
124 124
 				 $join_model_fk_to_other_model->get_name() => $other_model_obj->ID());
125 125
 
126 126
 		 //if $where_query exists lets add them to the query_params.
127
-		 if ( !empty( $extra_join_model_fields_n_values ) ) {
127
+		 if ( ! empty($extra_join_model_fields_n_values)) {
128 128
 		 	//make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
129 129
 		 	//make sure we strip THIS models name from the query param
130 130
 			 $parsed_query = array();
131
-		 	foreach ( $extra_join_model_fields_n_values as $query_param => $val ) {
132
-				$query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param);
131
+		 	foreach ($extra_join_model_fields_n_values as $query_param => $val) {
132
+				$query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param);
133 133
 				$parsed_query[$query_param] = $val;
134 134
 			}
135
-		 	$cols_n_values = array_merge( $cols_n_values, $parsed_query );
135
+		 	$cols_n_values = array_merge($cols_n_values, $parsed_query);
136 136
 		 }
137 137
 
138
-		 $query_params = array( $cols_n_values );
138
+		 $query_params = array($cols_n_values);
139 139
 
140 140
 
141 141
 		 $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params);
142 142
 		//if there is already an entry in the join table, indicating a relationship, we're done
143 143
 		 //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to
144 144
 		 //the other tables, use the joining model directly!
145
-		 if( ! $existing_entry_in_join_table ){
145
+		 if ( ! $existing_entry_in_join_table) {
146 146
 			$this->get_join_model()->insert($cols_n_values);
147 147
 		}
148 148
 		return $other_model_obj;
@@ -160,30 +160,30 @@  discard block
 block discarded – undo
160 160
 	 * @return EE_Base_Class
161 161
 	 * @throws \EE_Error
162 162
 	 */
163
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){
163
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
164 164
 		  $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
165 165
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
166 166
 		//check if such a relationship already exists
167 167
 		 $join_model_fk_to_this_model = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
168 168
 		 $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
169 169
 
170
-		 $cols_n_values =  array(
170
+		 $cols_n_values = array(
171 171
 				 $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(),
172 172
 				 $join_model_fk_to_other_model->get_name() => $other_model_obj->ID());
173 173
 
174 174
 		//if $where_query exists lets add them to the query_params.
175
-		 if ( !empty( $where_query ) ) {
175
+		 if ( ! empty($where_query)) {
176 176
 		 	//make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
177 177
 		 	//make sure we strip THIS models name from the query param
178 178
 			 $parsed_query = array();
179
-		 	foreach ( $where_query as $query_param => $val ) {
180
-				$query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param);
179
+		 	foreach ($where_query as $query_param => $val) {
180
+				$query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param);
181 181
 				$parsed_query[$query_param] = $val;
182 182
 			}
183
-		 	$cols_n_values = array_merge( $cols_n_values, $parsed_query );
183
+		 	$cols_n_values = array_merge($cols_n_values, $parsed_query);
184 184
 		 }
185 185
 
186
-		 $this->get_join_model()->delete( array($cols_n_values) );
186
+		 $this->get_join_model()->delete(array($cols_n_values));
187 187
 		return $other_model_obj;
188 188
 	 }
189 189
 }
Please login to merge, or discard this patch.