Completed
Branch BUG-10209-session-encoding (a58b72)
by
unknown
108:10 queued 97:50
created
core/db_models/fields/EE_Any_Foreign_Model_Name_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
2
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
3 3
 /**
4 4
  * Used by EE_Belongs_To_Any_Relations and EE_Has_Many_Any_Relations to identify the model the foreign key points to.
5 5
  * Note: the array of model names on this field should match the array of model names on the
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
  * 'obj_id'=>new EE_Foreign_Key_Int_Field('obj_id_column',__('Related Object ID'),false,0,array('Registration','Transaction')),
9 9
  * 'obj_type'=>new EE_Any_Foreign_Model_Name_Field('obj_type_column',__('Related Object type'),false,null,array('Registration','Transaction')));
10 10
  */
11
-class EE_Any_Foreign_Model_Name_Field extends EE_Field_With_Model_Name{
12
-	function get_wpdb_data_type(){
11
+class EE_Any_Foreign_Model_Name_Field extends EE_Field_With_Model_Name {
12
+	function get_wpdb_data_type() {
13 13
 		return '%s';
14 14
 	}
15 15
 }
16 16
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Field_Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * special default values for them, or some other column-specific functionality. So we can add them as fields,
8 8
  * but db-only ones
9 9
  */
10
-abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base{
10
+abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base {
11 11
 	/**
12 12
 	 * All these children classes are for the db-only (meaning, we should select them
13 13
 	 * on get_all queries, update, delete, and will still want to set their default value
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Float_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
3
-class EE_DB_Only_Float_Field extends EE_DB_Only_Field_Base{
4
-	function get_wpdb_data_type(){
2
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
3
+class EE_DB_Only_Float_Field extends EE_DB_Only_Field_Base {
4
+	function get_wpdb_data_type() {
5 5
 		return '%f';
6 6
 	}
7 7
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Int_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
4
-class EE_DB_Only_Int_Field extends EE_DB_Only_Field_Base{
5
-	function get_wpdb_data_type(){
3
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
4
+class EE_DB_Only_Int_Field extends EE_DB_Only_Field_Base {
5
+	function get_wpdb_data_type() {
6 6
 		return '%d';
7 7
 	}
8 8
 }
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Text_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
3
-class EE_DB_Only_Text_Field extends EE_DB_Only_Field_Base{
4
-	function get_wpdb_data_type(){
2
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
3
+class EE_DB_Only_Text_Field extends EE_DB_Only_Field_Base {
4
+	function get_wpdb_data_type() {
5 5
 		return '%s';
6 6
 	}
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -459,7 +459,7 @@
 block discarded – undo
459 459
 				//must be explicit because schema could equal true.
460 460
 				if( $schema === 'no_html' ){
461 461
 					$timezone_string = ' (' . $DateTime->format( 'T' )  . ')';
462
-				}else{
462
+				} else{
463 463
 					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>';
464 464
 				}
465 465
 			} else {
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
518 518
 	 * allowed)
519 519
 	 * @param string $datetime_string mysql timestamp in UTC
520
-	 * @return  mixed null | DateTime
520
+	 * @return  null|DbSafeDateTime null | DateTime
521 521
 	 */
522 522
 	public function prepare_for_set_from_db( $datetime_string ) {
523 523
 		//if $datetime_value is empty, and ! $this->_nullable, just use time()
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 *
654 654
 	 * @param \DateTimeZone $DateTimeZone
655 655
 	 * @param int           $time
656
-	 * @return mixed
656
+	 * @return string
657 657
 	 */
658 658
 	public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) {
659 659
 		$time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time();
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\domain\entities\DbSafeDateTime;
2 2
 
3
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * EE_Datetime_Field
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 	 * @param string 	$pretty_date_format
121 121
 	 * @param string 	$pretty_time_format
122 122
 	 */
123
-	public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){
123
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') {
124 124
 
125
-		$this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format');
126
-		$this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format');
127
-		$this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format');
128
-		$this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format');
125
+		$this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format');
126
+		$this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format');
127
+		$this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
128
+		$this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
129 129
 
130
-		parent::__construct( $table_column, $nice_name, $nullable, $default_value );
131
-		$this->set_timezone( $timezone_string );
130
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
131
+		$this->set_timezone($timezone_string);
132 132
 
133 133
 	}
134 134
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return DateTimeZone
148 148
 	 */
149 149
 	public function get_UTC_DateTimeZone() {
150
-		return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' );
150
+		return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC');
151 151
 	}
152 152
 
153 153
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @return DateTimeZone
157 157
 	 */
158 158
 	public function get_blog_DateTimeZone() {
159
-		return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' );
159
+		return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string('');
160 160
 	}
161 161
 
162 162
 
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	 * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp
167 167
 	 * @return DateTime
168 168
 	 */
169
-	public function prepare_for_set( $value_inputted_for_field_on_model_object ) {
170
-		return $this->_get_date_object( $value_inputted_for_field_on_model_object );
169
+	public function prepare_for_set($value_inputted_for_field_on_model_object) {
170
+		return $this->_get_date_object($value_inputted_for_field_on_model_object);
171 171
 	}
172 172
 
173 173
 
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 * @param bool $pretty If we're returning the pretty formats or standard format string.
184 184
 	 * @return string    The final assembled format string.
185 185
 	 */
186
-	protected function _get_date_time_output( $pretty = FALSE ) {
186
+	protected function _get_date_time_output($pretty = FALSE) {
187 187
 
188
-		switch ( $this->_date_time_output ) {
188
+		switch ($this->_date_time_output) {
189 189
 			case 'time' :
190 190
 				return $pretty ? $this->_pretty_time_format : $this->_time_format;
191 191
 				break;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				break;
196 196
 
197 197
 			default :
198
-				return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format;
198
+				return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format;
199 199
 		}
200 200
 	}
201 201
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @param string $what acceptable values are 'time' or 'date'.  Any other value will be set but will always result in both 'date' and 'time' being returned.
210 210
 	 * @return void
211 211
 	 */
212
-	public function set_date_time_output( $what = NULL ) {
212
+	public function set_date_time_output($what = NULL) {
213 213
 		$this->_date_time_output = $what;
214 214
 	}
215 215
 
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
 	 * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
226 226
 	 * @return void
227 227
 	 */
228
-	public function set_timezone( $timezone_string ) {
229
-		if( empty( $timezone_string ) && $this->_timezone_string != NULL ){
228
+	public function set_timezone($timezone_string) {
229
+		if (empty($timezone_string) && $this->_timezone_string != NULL) {
230 230
 			// leave the timezone AS-IS if we already have one and
231 231
 			// the function arg didn't provide one
232 232
 			return;
233 233
 		}
234
-		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string );
235
-		$this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC';
236
-		$this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string );
234
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
235
+		$this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
236
+		$this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
237 237
 	}
238 238
 
239 239
 
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 	 * @param string $timezone_string
246 246
 	 * @return \DateTimeZone
247 247
 	 */
248
-	protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) {
249
-		return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) );
248
+	protected function _create_timezone_object_from_timezone_string($timezone_string = '') {
249
+		return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
250 250
 	}
251 251
 
252 252
 
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 	 * @param bool   $pretty Whether to set pretty format or not.
272 272
 	 * @return void
273 273
 	 */
274
-	public function set_date_format( $format, $pretty = false ) {
275
-		if ( $pretty ) {
274
+	public function set_date_format($format, $pretty = false) {
275
+		if ($pretty) {
276 276
 			$this->_pretty_date_format = $format;
277 277
 		} else {
278 278
 			$this->_date_format = $format;
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * @param bool   $pretty Whether to get pretty format or not.
288 288
 	 * @return string
289 289
 	 */
290
-	public function get_date_format( $pretty = false ) {
290
+	public function get_date_format($pretty = false) {
291 291
 		return $pretty ? $this->_pretty_date_format : $this->_date_format;
292 292
 	}
293 293
 
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param bool   $pretty Whether to set pretty format or not.
303 303
 	 * @return void
304 304
 	 */
305
-	public function set_time_format( $format, $pretty = false ) {
306
-		if ( $pretty ) {
305
+	public function set_time_format($format, $pretty = false) {
306
+		if ($pretty) {
307 307
 			$this->_pretty_time_format = $format;
308 308
 		} else {
309 309
 			$this->_time_format = $format;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @param bool   $pretty Whether to get pretty format or not.
319 319
 	 * @return string
320 320
 	 */
321
-	public function get_time_format( $pretty = false ) {
321
+	public function get_time_format($pretty = false) {
322 322
 		return $pretty ? $this->_pretty_time_format : $this->_time_format;
323 323
 	}
324 324
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
334 334
 	 * @return void
335 335
 	 */
336
-	public function set_pretty_date_format( $format ) {
336
+	public function set_pretty_date_format($format) {
337 337
 		$this->_pretty_date_format = $format;
338 338
 	}
339 339
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
351 351
 	 * @return void
352 352
 	 */
353
-	public function set_pretty_time_format( $format ) {
353
+	public function set_pretty_time_format($format) {
354 354
 		$this->_pretty_time_format = $format;
355 355
 	}
356 356
 
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 * @param DateTime    $current current DateTime object for the datetime field
363 363
 	 * @return DateTime
364 364
 	 */
365
-	public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){
365
+	public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) {
366 366
 		//if $time_to_set_string is datetime object, then let's use it to set the parse array.  Otherwise parse the string.
367
-		if ( $time_to_set_string instanceof DateTime ) {
367
+		if ($time_to_set_string instanceof DateTime) {
368 368
 			$parsed = array(
369 369
 				'hour' => $time_to_set_string->format('H'),
370 370
 				'minute' => $time_to_set_string->format('i'),
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 				);
373 373
 		} else {
374 374
 			//parse incoming string
375
-			$parsed = date_parse_from_format( $this->_time_format, $time_to_set_string );
375
+			$parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
376 376
 		}
377 377
 
378 378
 		//make sure $current is in the correct timezone.
379
-		$current->setTimezone( $this->_DateTimeZone );
380
-		return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] );
379
+		$current->setTimezone($this->_DateTimeZone);
380
+		return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
381 381
 	}
382 382
 
383 383
 
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 	 * @param DateTime    $current current DateTime object for the datetime field
389 389
 	 * @return DateTime
390 390
 	 */
391
-	public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){
391
+	public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) {
392 392
 		//if $time_to_set_string is datetime object, then let's use it to set the parse array.  Otherwise parse the string.
393
-		if ( $date_to_set_string instanceof DateTime ) {
393
+		if ($date_to_set_string instanceof DateTime) {
394 394
 			$parsed = array(
395 395
 				'year' => $date_to_set_string->format('Y'),
396 396
 				'month' => $date_to_set_string->format('m'),
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 				);
399 399
 		} else {
400 400
 			//parse incoming string
401
-			$parsed = date_parse_from_format( $this->_date_format, $date_to_set_string );
401
+			$parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
402 402
 		}
403 403
 
404 404
 		//make sure $current is in the correct timezone
405
-		$current->setTimezone( $this->_DateTimeZone );
406
-		return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] );
405
+		$current->setTimezone($this->_DateTimeZone);
406
+		return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
407 407
 	}
408 408
 
409 409
 
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  DateTime $DateTime
416 416
 	 * @return string formatted date time for given timezone
417 417
 	 */
418
-	public function prepare_for_get( $DateTime ) {
419
-		return $this->_prepare_for_display( $DateTime  );
418
+	public function prepare_for_get($DateTime) {
419
+		return $this->_prepare_for_display($DateTime);
420 420
 	}
421 421
 
422 422
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param null     $schema
432 432
 	 * @return string
433 433
 	 */
434
-	public function prepare_for_pretty_echoing( $DateTime, $schema = null ) {
435
-		return $this->_prepare_for_display( $DateTime, $schema ? $schema : true );
434
+	public function prepare_for_pretty_echoing($DateTime, $schema = null) {
435
+		return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
436 436
 	}
437 437
 
438 438
 
@@ -446,36 +446,36 @@  discard block
 block discarded – undo
446 446
 	 * @return string
447 447
 	 * @throws \EE_Error
448 448
 	 */
449
-	protected function _prepare_for_display( $DateTime, $schema = false ) {
450
-		if ( ! $DateTime instanceof DateTime  ) {
451
-			if ( $this->_nullable ) {
449
+	protected function _prepare_for_display($DateTime, $schema = false) {
450
+		if ( ! $DateTime instanceof DateTime) {
451
+			if ($this->_nullable) {
452 452
 				return '';
453 453
 			} else {
454
-				if ( WP_DEBUG ) {
455
-					throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) );
454
+				if (WP_DEBUG) {
455
+					throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename));
456 456
 				} else {
457
-					$DateTime = new DateTime( \EE_Datetime_Field::now );
458
-					EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) );
457
+					$DateTime = new DateTime(\EE_Datetime_Field::now);
458
+					EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename));
459 459
 				}
460 460
 			}
461 461
 		}
462
-		$format_string = $this->_get_date_time_output( $schema );
462
+		$format_string = $this->_get_date_time_output($schema);
463 463
 		//make sure datetime_value is in the correct timezone (in case that's been updated).
464
-		$DateTime->setTimezone( $this->_DateTimeZone );
465
-		if ( $schema ) {
466
-			if( $this->_display_timezone() ) {
464
+		$DateTime->setTimezone($this->_DateTimeZone);
465
+		if ($schema) {
466
+			if ($this->_display_timezone()) {
467 467
 				//must be explicit because schema could equal true.
468
-				if( $schema === 'no_html' ){
469
-					$timezone_string = ' (' . $DateTime->format( 'T' )  . ')';
470
-				}else{
471
-					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>';
468
+				if ($schema === 'no_html') {
469
+					$timezone_string = ' ('.$DateTime->format('T').')';
470
+				} else {
471
+					$timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>';
472 472
 				}
473 473
 			} else {
474 474
 				$timezone_string = '';
475 475
 			}
476
-			return $DateTime->format( $format_string ) . $timezone_string;
476
+			return $DateTime->format($format_string).$timezone_string;
477 477
 		} else {
478
-			return $DateTime->format( $format_string );
478
+			return $DateTime->format($format_string);
479 479
 		}
480 480
 	}
481 481
 
@@ -489,24 +489,24 @@  discard block
 block discarded – undo
489 489
 	 * @return string mysql timestamp in UTC
490 490
 	 * @throws \EE_Error
491 491
 	 */
492
-	public function prepare_for_use_in_db( $datetime_value ) {
492
+	public function prepare_for_use_in_db($datetime_value) {
493 493
 		//we allow an empty value or DateTime object, but nothing else.
494
-		if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) {
495
-			throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) );
494
+		if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
495
+			throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso'));
496 496
 		}
497 497
 
498
-		if ( $datetime_value instanceof DateTime ) {
498
+		if ($datetime_value instanceof DateTime) {
499 499
 			if ( ! $datetime_value instanceof DbSafeDateTime) {
500 500
 				$datetime_value = new DbSafeDateTime(
501
-					$datetime_value->format( EE_Datetime_Field::mysql_timestamp_format ),
502
-					new \DateTimeZone( $datetime_value->format( 'e' ) )
501
+					$datetime_value->format(EE_Datetime_Field::mysql_timestamp_format),
502
+					new \DateTimeZone($datetime_value->format('e'))
503 503
 				);
504 504
 			}
505
-			return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format );
505
+			return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format);
506 506
 		}
507 507
 
508 508
 		// if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
509
-		return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null;
509
+		return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
510 510
 	}
511 511
 
512 512
 
@@ -519,14 +519,14 @@  discard block
 block discarded – undo
519 519
 	 * @param string $datetime_string mysql timestamp in UTC
520 520
 	 * @return  mixed null | DateTime
521 521
 	 */
522
-	public function prepare_for_set_from_db( $datetime_string ) {
522
+	public function prepare_for_set_from_db($datetime_string) {
523 523
 		//if $datetime_value is empty, and ! $this->_nullable, just use time()
524
-		if ( empty( $datetime_string) && $this->_nullable ) {
524
+		if (empty($datetime_string) && $this->_nullable) {
525 525
 			return null;
526 526
 		}
527 527
 		// datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
528
-		if ( empty( $datetime_string ) ) {
529
-			$DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->get_UTC_DateTimeZone() );
528
+		if (empty($datetime_string)) {
529
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
530 530
 		} else {
531 531
 			$DateTime = DateTime::createFromFormat(
532 532
 				EE_Datetime_Field::mysql_timestamp_format,
@@ -534,17 +534,17 @@  discard block
 block discarded – undo
534 534
 				$this->get_UTC_DateTimeZone()
535 535
 			);
536 536
 			$DateTime = new DbSafeDateTime(
537
-				$DateTime->format( \EE_Datetime_Field::mysql_timestamp_format ),
537
+				$DateTime->format(\EE_Datetime_Field::mysql_timestamp_format),
538 538
 				$this->get_UTC_DateTimeZone()
539 539
 			);
540 540
 		}
541 541
 
542
-		if ( ! $DateTime instanceof DbSafeDateTime ) {
542
+		if ( ! $DateTime instanceof DbSafeDateTime) {
543 543
 			// if still no datetime object, then let's just use now
544
-			$DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->get_UTC_DateTimeZone() );
544
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
545 545
 		}
546 546
 		// THEN apply the field's set DateTimeZone
547
-		$DateTime->setTimezone( $this->_DateTimeZone );
547
+		$DateTime->setTimezone($this->_DateTimeZone);
548 548
 		return $DateTime;
549 549
 	}
550 550
 
@@ -561,15 +561,15 @@  discard block
 block discarded – undo
561 561
 	protected function _display_timezone() {
562 562
 
563 563
 		// first let's do a comparison of timezone strings.  If they match then we can get out without any further calculations
564
-		$blog_string = get_option( 'timezone_string' );
565
-		if ( $blog_string == $this->_timezone_string ) {
564
+		$blog_string = get_option('timezone_string');
565
+		if ($blog_string == $this->_timezone_string) {
566 566
 			return FALSE;
567 567
 		}
568 568
 		// now we need to calc the offset for the timezone string so we can compare with the blog offset.
569
-		$this_offset = $this->get_timezone_offset( $this->_DateTimeZone );
570
-		$blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() );
569
+		$this_offset = $this->get_timezone_offset($this->_DateTimeZone);
570
+		$blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
571 571
 		// now compare
572
-		if ( $blog_offset === $this_offset ) {
572
+		if ($blog_offset === $this_offset) {
573 573
 			return FALSE;
574 574
 		}
575 575
 		return TRUE;
@@ -587,24 +587,24 @@  discard block
 block discarded – undo
587 587
 	 *
588 588
 	 * @return DateTime
589 589
 	 */
590
-	protected function _get_date_object( $date_string ) {
590
+	protected function _get_date_object($date_string) {
591 591
 		//first if this is an empty date_string and nullable is allowed, just return null.
592
-		if ( $this->_nullable && empty( $date_string ) ) {
592
+		if ($this->_nullable && empty($date_string)) {
593 593
 			return null;
594 594
 		}
595 595
 
596 596
 		// if incoming date
597
-		if ( $date_string instanceof DateTime ) {
598
-			$date_string->setTimezone( $this->_DateTimeZone );
597
+		if ($date_string instanceof DateTime) {
598
+			$date_string->setTimezone($this->_DateTimeZone);
599 599
 			return $date_string;
600 600
 		}
601 601
 		// if empty date_string and made it here.
602 602
 		// Return a datetime object for now in the given timezone.
603
-		if ( empty( $date_string ) ) {
604
-			return new DbSafeDateTime( \EE_Datetime_Field::now, $this->_DateTimeZone );
603
+		if (empty($date_string)) {
604
+			return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
605 605
 		}
606 606
 		// if $date_string is matches something that looks like a Unix timestamp let's just use it.
607
-		if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) {
607
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
608 608
 			try {
609 609
 				/**
610 610
 				 * This is operating under the assumption that the incoming Unix timestamp is
@@ -612,36 +612,36 @@  discard block
 block discarded – undo
612 612
 				 * current_time('timestamp');
613 613
 				 *
614 614
 				 */
615
-				$DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->_DateTimeZone );
616
-				$DateTime->setTimestamp( $date_string );
615
+				$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
616
+				$DateTime->setTimestamp($date_string);
617 617
 				return $DateTime;
618
-			} catch ( Exception $e )  {
618
+			} catch (Exception $e) {
619 619
 			 	// should be rare, but if things got fooled then let's just continue
620 620
 			 }
621 621
 		}
622 622
 		//not a unix timestamp.  So we will use the set format on this object and set timezone to
623 623
 		//create the DateTime object.
624
-		$format = $this->_date_format . ' ' . $this->_time_format;
624
+		$format = $this->_date_format.' '.$this->_time_format;
625 625
 		try {
626
-			$DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone );
627
-			if ( $DateTime instanceof DateTime ) {
626
+			$DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
627
+			if ($DateTime instanceof DateTime) {
628 628
 				$DateTime = new DbSafeDateTime(
629
-					$DateTime->format( \EE_Datetime_Field::mysql_timestamp_format ),
629
+					$DateTime->format(\EE_Datetime_Field::mysql_timestamp_format),
630 630
 					$this->_DateTimeZone
631 631
 				);
632 632
 			}
633
-			if ( ! $DateTime instanceof DbSafeDateTime ) {
633
+			if ( ! $DateTime instanceof DbSafeDateTime) {
634 634
 				throw new EE_Error(
635 635
 					sprintf(
636
-						__( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ),
636
+						__('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
637 637
 						$date_string,
638 638
 						$format
639 639
 					)
640 640
 				);
641 641
 			}
642
-		} catch ( Exception $e ) {
642
+		} catch (Exception $e) {
643 643
 			// if we made it here then likely then something went really wrong.  Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
644
-			$DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->_DateTimeZone );
644
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
645 645
 		}
646 646
 		return $DateTime;
647 647
 	}
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
 	 * @param int           $time
656 656
 	 * @return mixed
657 657
 	 */
658
-	public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) {
659
-		$time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time();
660
-		$transitions = $DateTimeZone->getTransitions( $time );
658
+	public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) {
659
+		$time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
660
+		$transitions = $DateTimeZone->getTransitions($time);
661 661
 		return $transitions[0]['offset'];
662 662
 	}
663 663
 
@@ -669,10 +669,10 @@  discard block
 block discarded – undo
669 669
 	 * @param  string $timezone_string
670 670
 	 * @return string           abbreviation
671 671
 	 */
672
-	public function get_timezone_abbrev( $timezone_string ) {
673
-		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string );
674
-		$dateTime = new DateTime( \EE_Datetime_Field::now, new DateTimeZone( $timezone_string ) );
675
-		return $dateTime->format( 'T' );
672
+	public function get_timezone_abbrev($timezone_string) {
673
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
674
+		$dateTime = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string));
675
+		return $dateTime->format('T');
676 676
 	}
677 677
 
678 678
 	/**
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	 * @return
681 681
 	 */
682 682
 	public function get_default_value() {
683
-		if( $this->_default_value === EE_Datetime_Field::now ) {
683
+		if ($this->_default_value === EE_Datetime_Field::now) {
684 684
 			return time();
685 685
 		} else {
686 686
 			return parent::get_default_value();
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Integer_Field.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once( EE_MODELS . 'fields/EE_Integer_Field.php' );
2
+require_once(EE_MODELS.'fields/EE_Integer_Field.php');
3 3
 /**
4 4
  * Class EE_Enum_Integer_Field
5 5
  *
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author				Mike Nelson
9 9
  *
10 10
  */
11
-class EE_Enum_Integer_Field extends EE_Integer_Field{
11
+class EE_Enum_Integer_Field extends EE_Integer_Field {
12 12
 
13 13
 	var $_allowed_enum_values;
14 14
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param int $default_value
21 21
 	 * @param array $allowed_enum_values  keys are values to be used in the DB, values are how they should be displayed
22 22
 	 */
23
-	function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values){
23
+	function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values) {
24 24
 		$this->_allowed_enum_values = $allowed_enum_values;
25 25
 		parent::__construct($table_column, $nicename, $nullable, $default_value);
26 26
 	}
@@ -32,20 +32,20 @@  discard block
 block discarded – undo
32 32
 	 * @throws EE_Error
33 33
 	 */
34 34
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
35
-		if( $value_inputted_for_field_on_model_object !== NULL && ! array_key_exists( $value_inputted_for_field_on_model_object, $this->_allowed_enum_values )){
36
-			if( defined( 'WP_DEBUG' ) && WP_DEBUG ){
35
+		if ($value_inputted_for_field_on_model_object !== NULL && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)) {
36
+			if (defined('WP_DEBUG') && WP_DEBUG) {
37 37
 				$msg = sprintf(
38
-					__('System is assigning incompatible value "%1$s" to field "%2$s"','event_espresso'),
38
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
39 39
 					$value_inputted_for_field_on_model_object,
40 40
 					$this->_name
41 41
 				);
42 42
 				$msg2 = sprintf(
43
-					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"','event_espresso'),
43
+					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
44 44
 					$this->_name,
45
-					implode( ', ', array_keys( $this->_allowed_enum_values )),
45
+					implode(', ', array_keys($this->_allowed_enum_values)),
46 46
 					$value_inputted_for_field_on_model_object
47 47
 				);
48
-				 EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ );
48
+				 EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
49 49
 			}
50 50
 			return $this->get_default_value();
51 51
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param null         $schema
63 63
 	 * @return string
64 64
 	 */
65
-	function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = NULL ) {
65
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = NULL) {
66 66
 		return $this->_allowed_enum_values[$value_on_field_to_be_outputted];
67 67
 	}
68 68
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Text_Fields is a base class for any fields which are have float value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...)
4 4
  */
5
-class EE_Float_Field extends EE_Model_Field_Base{
6
-	function get_wpdb_data_type(){
5
+class EE_Float_Field extends EE_Model_Field_Base {
6
+	function get_wpdb_data_type() {
7 7
 		return '%f';
8 8
 	}
9 9
 	/**
@@ -17,26 +17,26 @@  discard block
 block discarded – undo
17 17
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
18 18
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
19 19
 		//remove whitespaces and thousands separators
20
-		if(is_string($value_inputted_for_field_on_model_object)){
21
-			$value_inputted_for_field_on_model_object = str_replace(array(" ",EE_Config::instance()->currency->thsnds),"",$value_inputted_for_field_on_model_object);
20
+		if (is_string($value_inputted_for_field_on_model_object)) {
21
+			$value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), "", $value_inputted_for_field_on_model_object);
22 22
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
23 23
 //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
24
-			$value_inputted_for_field_on_model_object = str_replace( EE_Config::instance()->currency->dec_mrk, ".", $value_inputted_for_field_on_model_object) ;
24
+			$value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", $value_inputted_for_field_on_model_object);
25 25
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
26 26
 //double-check there's absolutely nothing left on this string besides numbers
27
-			$value_inputted_for_field_on_model_object = preg_replace( "/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
27
+			$value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
28 28
 		}
29 29
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
30
-		return floatval( $value_inputted_for_field_on_model_object );
30
+		return floatval($value_inputted_for_field_on_model_object);
31 31
 	}
32 32
 	/**
33 33
 	 * Returns the number formatted according to local custom (set by the country of the blog).
34 34
 	 * @param float $value_on_field_to_be_outputted
35 35
 	 * @return string
36 36
 	 */
37
-	function prepare_for_pretty_echoing($value_on_field_to_be_outputted,$schema = null){
37
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
38 38
 		$EE = EE_Registry::instance();
39
-		return number_format( $value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, $EE->CFG->currency->thsnds) ;
39
+		return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, $EE->CFG->currency->thsnds);
40 40
 	}
41 41
 
42 42
 	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
Please login to merge, or discard this patch.
core/db_models/fields/EE_Foreign_Key_Field_Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
  * needed functions from its parent, but because all foreign key fields inherit from
5 5
  * this one, its easy ot check if a field is a foreign key.
6 6
  */
7
-abstract class EE_Foreign_Key_Field_Base extends EE_Field_With_Model_Name{
7
+abstract class EE_Foreign_Key_Field_Base extends EE_Field_With_Model_Name {
8 8
 	//all needed functionality inherited from parent
9 9
 }
Please login to merge, or discard this patch.