Completed
Branch BUG-9811-trim-form-input-value... (96191a)
by
unknown
194:11 queued 179:40
created
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	/**
263 263
 	 * Sets sensitive_data_removal_strategy
264 264
 	 * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
265
-	 * @return boolean
265
+	 * @return boolean|null
266 266
 	 */
267 267
 	public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) {
268 268
 		$this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	/**
357 357
 	 * returns true if input employs any of the validation strategy defined by the supplied array of classnames
358 358
 	 *
359
-	 * @param array $validation_strategy_classnames
359
+	 * @param string[] $validation_strategy_classnames
360 360
 	 * @return bool
361 361
 	 */
362 362
 	public function has_validation_strategy( $validation_strategy_classnames ) {
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	 * Returns whether or not any validation errors occurred
480 480
 	 *
481 481
 	 * @param array $req_data like $_POST
482
-	 * @return boolean whether or not there was an error
482
+	 * @return boolean|null whether or not there was an error
483 483
 	 */
484 484
 	protected function _normalize( $req_data ) {
485 485
 		//any existing validation errors don't apply so clear them
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	 *  @type EE_Validation_Strategy_Base[]  $validation_strategies
144 144
 	 * }
145 145
 	 */
146
-	public function __construct( $input_args = array() ){
147
-		$input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
146
+	public function __construct($input_args = array()) {
147
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
148 148
 		// the following properties must be cast as arrays
149
-		if ( isset( $input_args['validation_strategies'] ) ) {
150
-			foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) {
151
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
152
-					$this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy;
149
+		if (isset($input_args['validation_strategies'])) {
150
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
151
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
152
+					$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
153 153
 				}
154 154
 			}
155
-			unset( $input_args['validation_strategies'] );
155
+			unset($input_args['validation_strategies']);
156 156
 		}
157 157
 		// loop thru incoming options
158
-		foreach( $input_args as $key => $value ) {
158
+		foreach ($input_args as $key => $value) {
159 159
 			// add underscore to $key to match property names
160
-			$_key = '_' . $key;
161
-			if ( property_exists( $this, $_key )) {
160
+			$_key = '_'.$key;
161
+			if (property_exists($this, $_key)) {
162 162
 				$this->{$_key} = $value;
163 163
 			}
164 164
 		}
165 165
 		// ensure that "required" is set correctly
166 166
 		$this->set_required(
167
-			$this->_required, isset( $input_args[ 'required_validation_error_message' ] )
168
-				? $input_args[ 'required_validation_error_message' ]
167
+			$this->_required, isset($input_args['required_validation_error_message'])
168
+				? $input_args['required_validation_error_message']
169 169
 				: null
170 170
 		);
171 171
 
172 172
 		//$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
173 173
 
174 174
 		$this->_display_strategy->_construct_finalize($this);
175
-		foreach( $this->_validation_strategies as $validation_strategy ){
175
+		foreach ($this->_validation_strategies as $validation_strategy) {
176 176
 			$validation_strategy->_construct_finalize($this);
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	protected function _set_default_html_name_if_empty(){
205
-		if( ! $this->_html_name){
204
+	protected function _set_default_html_name_if_empty() {
205
+		if ( ! $this->_html_name) {
206 206
 			$this->_html_name = $this->name();
207
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
208
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
207
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
208
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
209 209
 			}
210 210
 		}
211 211
 	}
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	public function _construct_finalize($parent_form_section, $name) {
221 221
 		parent::_construct_finalize($parent_form_section, $name);
222 222
 		$this->_set_default_html_name_if_empty();
223
-		if( ! $this->_html_label && ! $this->_html_label_text){
224
-			$this->_html_label_text = ucwords( str_replace("_"," ",$name));
223
+		if ( ! $this->_html_label && ! $this->_html_label_text) {
224
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
225 225
 		}
226
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
226
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
227 227
 	}
228 228
 
229 229
 	 /**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	  * @return EE_Display_Strategy_Base
232 232
 	  * @throws EE_Error
233 233
 	  */
234
-	protected function _get_display_strategy(){
235
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
234
+	protected function _get_display_strategy() {
235
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
236 236
 			throw new EE_Error(
237 237
 				sprintf(
238 238
 					__(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else {
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Sets the display strategy.
252 252
 	 * @param EE_Display_Strategy_Base $strategy
253 253
 	 */
254
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
254
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
255 255
 		$this->_display_strategy = $strategy;
256 256
 	}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Sets the sanitization strategy
260 260
 	 * @param EE_Normalization_Strategy_Base $strategy
261 261
 	 */
262
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
262
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
263 263
 		$this->_normalization_strategy = $strategy;
264 264
 	}
265 265
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 	 * Gets the display strategy for this input
286 286
 	 * @return EE_Display_Strategy_Base
287 287
 	 */
288
-	public function get_display_strategy(){
288
+	public function get_display_strategy() {
289 289
 		return $this->_display_strategy;
290 290
 	}
291 291
 	/**
292 292
 	 * Overwrites the display strategy
293 293
 	 * @param EE_Display_Strategy_Base $display_strategy
294 294
 	 */
295
-	public function set_display_strategy($display_strategy){
295
+	public function set_display_strategy($display_strategy) {
296 296
 		$this->_display_strategy = $display_strategy;
297 297
 		$this->_display_strategy->_construct_finalize($this);
298 298
 	}
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 	 * Gets the normalization strategy set on this input
301 301
 	 * @return EE_Normalization_Strategy_Base
302 302
 	 */
303
-	public function get_normalization_strategy(){
303
+	public function get_normalization_strategy() {
304 304
 		return $this->_normalization_strategy;
305 305
 	}
306 306
 	/**
307 307
 	 * Overwrites the normalization strategy
308 308
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
309 309
 	 */
310
-	public function set_normalization_strategy($normalization_strategy){
310
+	public function set_normalization_strategy($normalization_strategy) {
311 311
 		$this->_normalization_strategy = $normalization_strategy;
312 312
 		$this->_normalization_strategy->_construct_finalize($this);
313 313
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
317 317
 	 * @return EE_Validation_Strategy_Base[]
318 318
 	 */
319
-	public function get_validation_strategies(){
319
+	public function get_validation_strategies() {
320 320
 		return $this->_validation_strategies;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Validation_Strategy_Base $validation_strategy
328 328
 	 * @return void
329 329
 	 */
330
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
331
-		$validation_strategy->_construct_finalize( $this );
330
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
331
+		$validation_strategy->_construct_finalize($this);
332 332
 		$this->_validation_strategies[] = $validation_strategy;
333 333
 	}
334 334
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_Validation_Strategy_Base $validation_strategy
340 340
 	 * @return void
341 341
 	 */
342
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
343
-		$this->_add_validation_strategy( $validation_strategy );
342
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
343
+		$this->_add_validation_strategy($validation_strategy);
344 344
 	}
345 345
 
346 346
 
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param string $validation_strategy_classname
352 352
 	 */
353
-	public function remove_validation_strategy( $validation_strategy_classname ) {
354
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
355
-			if(
353
+	public function remove_validation_strategy($validation_strategy_classname) {
354
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
355
+			if (
356 356
 				$validation_strategy instanceof $validation_strategy_classname
357
-				|| is_subclass_of( $validation_strategy, $validation_strategy_classname )
357
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
358 358
 			) {
359
-				unset( $this->_validation_strategies[ $key ] );
359
+				unset($this->_validation_strategies[$key]);
360 360
 			}
361 361
 		}
362 362
 	}
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	 * @param array $validation_strategy_classnames
370 370
 	 * @return bool
371 371
 	 */
372
-	public function has_validation_strategy( $validation_strategy_classnames ) {
373
-		$validation_strategy_classnames = is_array( $validation_strategy_classnames )
372
+	public function has_validation_strategy($validation_strategy_classnames) {
373
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
374 374
 			? $validation_strategy_classnames
375
-			: array( $validation_strategy_classnames );
376
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
377
-			if( in_array( $key, $validation_strategy_classnames ) ) {
375
+			: array($validation_strategy_classnames);
376
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
377
+			if (in_array($key, $validation_strategy_classnames)) {
378 378
 				return true;
379 379
 			}
380 380
 		}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Gets the HTML
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_html(){
390
+	public function get_html() {
391 391
 		return $this->_parent_section->get_html_for_input($this);
392 392
 	}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 * @return string
402 402
 	 * @throws \EE_Error
403 403
 	 */
404
-	public function get_html_for_input(){
404
+	public function get_html_for_input() {
405 405
 		return  $this->_get_display_strategy()->display();
406 406
 	}
407 407
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @return string
412 412
 	 */
413 413
 	public function html_other_attributes() {
414
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
414
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
415 415
 	}
416 416
 
417 417
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * @param string $html_other_attributes
421 421
 	 */
422
-	public function set_html_other_attributes( $html_other_attributes ) {
422
+	public function set_html_other_attributes($html_other_attributes) {
423 423
 		$this->_html_other_attributes = $html_other_attributes;
424 424
 	}
425 425
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * according to the form section's layout strategy
429 429
 	 * @return string
430 430
 	 */
431
-	public function get_html_for_label(){
431
+	public function get_html_for_label() {
432 432
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
433 433
 	}
434 434
 	/**
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * according to the form section's layout strategy
437 437
 	 * @return string
438 438
 	 */
439
-	public function get_html_for_errors(){
439
+	public function get_html_for_errors() {
440 440
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
441 441
 	}
442 442
 	/**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * according to the form section's layout strategy
445 445
 	 * @return string
446 446
 	 */
447
-	public function get_html_for_help(){
447
+	public function get_html_for_help() {
448 448
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
449 449
 	}
450 450
 	/**
@@ -453,18 +453,18 @@  discard block
 block discarded – undo
453 453
 	 * @return boolean
454 454
 	 */
455 455
 	protected function _validate() {
456
-		foreach($this->_validation_strategies as $validation_strategy){
457
-			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
458
-				try{
456
+		foreach ($this->_validation_strategies as $validation_strategy) {
457
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
458
+				try {
459 459
 					$validation_strategy->validate($this->normalized_value());
460
-				}catch(EE_Validation_Error $e){
460
+				} catch (EE_Validation_Error $e) {
461 461
 					$this->add_validation_error($e);
462 462
 				}
463 463
 			}
464 464
 		}
465
-		if( $this->get_validation_errors()){
465
+		if ($this->get_validation_errors()) {
466 466
 			return false;
467
-		}else{
467
+		} else {
468 468
 			return true;
469 469
 		}
470 470
 	}
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 * @param string $value
479 479
 	 * @return null|string
480 480
 	 */
481
-	private function _sanitize( $value ) {
482
-		return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null;
481
+	private function _sanitize($value) {
482
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
483 483
 	}
484 484
 
485 485
 
@@ -493,24 +493,24 @@  discard block
 block discarded – undo
493 493
 	 * @return boolean whether or not there was an error
494 494
 	 * @throws \EE_Error
495 495
 	 */
496
-	protected function _normalize( $req_data ) {
496
+	protected function _normalize($req_data) {
497 497
 		//any existing validation errors don't apply so clear them
498 498
 		$this->_validation_errors = array();
499 499
 		try {
500
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
500
+			$raw_input = $this->find_form_data_for_this_section($req_data);
501 501
 			//super simple sanitization for now
502
-			if ( is_array( $raw_input )) {
502
+			if (is_array($raw_input)) {
503 503
 				$this->_raw_value = array();
504
-				foreach( $raw_input as $key => $value ) {
505
-					$this->_raw_value[ $key ] = $this->_sanitize( $value );
504
+				foreach ($raw_input as $key => $value) {
505
+					$this->_raw_value[$key] = $this->_sanitize($value);
506 506
 				}
507 507
 			} else {
508
-				$this->_raw_value = $this->_sanitize( $raw_input );
508
+				$this->_raw_value = $this->_sanitize($raw_input);
509 509
 			}
510 510
 			//we want ot mostly leave the input alone in case we need to re-display it to the user
511
-			$this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() );
512
-		} catch ( EE_Validation_Error $e ) {
513
-			$this->add_validation_error( $e );
511
+			$this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value());
512
+		} catch (EE_Validation_Error $e) {
513
+			$this->add_validation_error($e);
514 514
 		}
515 515
 	}
516 516
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	/**
520 520
 	 * @return string
521 521
 	 */
522
-	public function html_name(){
522
+	public function html_name() {
523 523
 		return $this->_html_name;
524 524
 	}
525 525
 
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	/**
529 529
 	 * @return string
530 530
 	 */
531
-	public function html_label_id(){
532
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
531
+	public function html_label_id() {
532
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
533 533
 	}
534 534
 
535 535
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	/**
538 538
 	 * @return string
539 539
 	 */
540
-	public function html_label_class(){
540
+	public function html_label_class() {
541 541
 		return $this->_html_label_class;
542 542
 	}
543 543
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	/**
547 547
 	 * @return string
548 548
 	 */
549
-	public function html_label_style(){
549
+	public function html_label_style() {
550 550
 		return $this->_html_label_style;
551 551
 	}
552 552
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 	/**
556 556
 	 * @return string
557 557
 	 */
558
-	public function html_label_text(){
558
+	public function html_label_text() {
559 559
 		return $this->_html_label_text;
560 560
 	}
561 561
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	/**
565 565
 	 * @return string
566 566
 	 */
567
-	public function html_help_text(){
567
+	public function html_help_text() {
568 568
 		return $this->_html_help_text;
569 569
 	}
570 570
 
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	/**
574 574
 	 * @return string
575 575
 	 */
576
-	public function html_help_class(){
576
+	public function html_help_class() {
577 577
 		return $this->_html_help_class;
578 578
 	}
579 579
 
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	/**
583 583
 	 * @return string
584 584
 	 */
585
-	public function html_help_style(){
585
+	public function html_help_style() {
586 586
 		return $this->_html_style;
587 587
 	}
588 588
 	/**
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	 * in which case, we would have stored the malicious content to our database.
596 596
 	 * @return string
597 597
 	 */
598
-	public function raw_value(){
598
+	public function raw_value() {
599 599
 		return $this->_raw_value;
600 600
 	}
601 601
 	/**
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 	 * it escapes all html entities
604 604
 	 * @return string
605 605
 	 */
606
-	public function raw_value_in_form(){
607
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
606
+	public function raw_value_in_form() {
607
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
608 608
 	}
609 609
 	/**
610 610
 	 * returns the value after it's been sanitized, and then converted into it's proper type
611 611
 	 * in PHP. Eg, a string, an int, an array,
612 612
 	 * @return mixed
613 613
 	 */
614
-	public function normalized_value(){
614
+	public function normalized_value() {
615 615
 		return $this->_normalized_value;
616 616
 	}
617 617
 
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 * the best thing to display
622 622
 	 * @return string
623 623
 	 */
624
-	public function pretty_value(){
624
+	public function pretty_value() {
625 625
 		return $this->_normalized_value;
626 626
 	}
627 627
 	/**
@@ -640,19 +640,19 @@  discard block
 block discarded – undo
640 640
 		  }</code>
641 641
 	 * @return array
642 642
 	 */
643
-	public function get_jquery_validation_rules(){
643
+	public function get_jquery_validation_rules() {
644 644
 		$jquery_validation_js = array();
645 645
 		$jquery_validation_rules = array();
646
-		foreach($this->get_validation_strategies() as $validation_strategy){
646
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
647 647
 			$jquery_validation_rules = array_replace_recursive(
648 648
 				$jquery_validation_rules,
649 649
 				$validation_strategy->get_jquery_validation_rule_array()
650 650
 			);
651 651
 		}
652 652
 
653
-		if(! empty($jquery_validation_rules)){
654
-			foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) {
655
-				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
653
+		if ( ! empty($jquery_validation_rules)) {
654
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
655
+				$jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
656 656
 			}
657 657
 		}
658 658
 		return $jquery_validation_js;
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
 	 * @param mixed $value
665 665
 	 * @return void
666 666
 	 */
667
-	public function set_default($value){
667
+	public function set_default($value) {
668 668
 		$this->_normalized_value = $value;
669
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
669
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
670 670
 	}
671 671
 
672 672
 	/**
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 	 * @param string $label
675 675
 	 * @return void
676 676
 	 */
677
-	public function set_html_label_text($label){
677
+	public function set_html_label_text($label) {
678 678
 		$this->_html_label_text = $label;
679 679
 	}
680 680
 
@@ -688,13 +688,13 @@  discard block
 block discarded – undo
688 688
 	 * @param boolean $required boolean
689 689
 	 * @param null    $required_text
690 690
 	 */
691
-	public function set_required($required = true, $required_text = NULL ){
692
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN  );
691
+	public function set_required($required = true, $required_text = NULL) {
692
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
693 693
 		//whether $required is a string or a boolean, we want to add a required validation strategy
694
-		if ( $required ) {
695
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
694
+		if ($required) {
695
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
696 696
 		} else {
697
-			unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] );
697
+			unset($this->_validation_strategies['EE_Required_Validation_Strategy']);
698 698
 		}
699 699
 		$this->_required = $required;
700 700
 	}
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 * Returns whether or not this field is required
703 703
 	 * @return boolean
704 704
 	 */
705
-	public function required(){
705
+	public function required() {
706 706
 		return $this->_required;
707 707
 	}
708 708
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	/**
712 712
 	 * @param string $required_css_class
713 713
 	 */
714
-	public function set_required_css_class( $required_css_class ) {
714
+	public function set_required_css_class($required_css_class) {
715 715
 		$this->_required_css_class = $required_css_class;
716 716
 	}
717 717
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 * Sets the help text, in case
731 731
 	 * @param string $text
732 732
 	 */
733
-	public function set_html_help_text($text){
733
+	public function set_html_help_text($text) {
734 734
 		$this->_html_help_text = $text;
735 735
 	}
736 736
 	/**
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	public function clean_sensitive_data() {
743 743
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
744 744
 		//if we need more logic than this we'll make a strategy for it
745
-		if( $this->_sensitive_data_removal_strategy &&
746
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
745
+		if ($this->_sensitive_data_removal_strategy &&
746
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
747 747
 			$this->_raw_value = NULL;
748 748
 		}
749 749
 		//and clean the normalized value according to the appropriate strategy
@@ -759,10 +759,10 @@  discard block
 block discarded – undo
759 759
 	 * @param string $button_size
760 760
 	 * @param string $other_attributes
761 761
 	 */
762
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
762
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
763 763
 		$button_css_attributes = 'button';
764 764
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
765
-		switch ( $button_size ) {
765
+		switch ($button_size) {
766 766
 			case 'xs' :
767 767
 			case 'extra-small' :
768 768
 				$button_css_attributes .= ' button-xs';
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
 			default :
784 784
 				$button_css_attributes .= '';
785 785
 		}
786
-		$this->_button_css_attributes .= ! empty( $other_attributes )
787
-			? $button_css_attributes . ' ' . $other_attributes
786
+		$this->_button_css_attributes .= ! empty($other_attributes)
787
+			? $button_css_attributes.' '.$other_attributes
788 788
 			: $button_css_attributes;
789 789
 	}
790 790
 
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	 * @return string
795 795
 	 */
796 796
 	public function button_css_attributes() {
797
-		if ( empty( $this->_button_css_attributes )) {
797
+		if (empty($this->_button_css_attributes)) {
798 798
 			$this->set_button_css_attributes();
799 799
 		}
800 800
 		return $this->_button_css_attributes;
@@ -816,26 +816,26 @@  discard block
 block discarded – undo
816 816
 	 * @return mixed whatever the raw value of this form section is in the request data
817 817
 	 * @throws \EE_Error
818 818
 	 */
819
-	public function find_form_data_for_this_section( $req_data ){
819
+	public function find_form_data_for_this_section($req_data) {
820 820
 		// break up the html name by "[]"
821
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
822
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
821
+		if (strpos($this->html_name(), '[') !== FALSE) {
822
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
823 823
 		} else {
824 824
 			$before_any_brackets = $this->html_name();
825 825
 		}
826 826
 		// grab all of the segments
827
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
828
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
829
-			$name_parts = $matches[ 1 ];
827
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
828
+		if (isset($matches[1]) && is_array($matches[1])) {
829
+			$name_parts = $matches[1];
830 830
 			array_unshift($name_parts, $before_any_brackets);
831
-		}else{
832
-			$name_parts = array( $before_any_brackets );
831
+		} else {
832
+			$name_parts = array($before_any_brackets);
833 833
 		}
834 834
 		// now get the value for the input
835 835
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
836 836
 		// check if this thing's name is at the TOP level of the request data
837
-		if( $value === null && isset( $req_data[ $this->name() ] ) ){
838
-			$value = $req_data[ $this->name() ];
837
+		if ($value === null && isset($req_data[$this->name()])) {
838
+			$value = $req_data[$this->name()];
839 839
 		}
840 840
 		return $value;
841 841
 	}
@@ -848,18 +848,18 @@  discard block
 block discarded – undo
848 848
 	 * @param array $req_data
849 849
 	 * @return array | NULL
850 850
 	 */
851
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
852
-		$first_part_to_consider = array_shift( $html_name_parts );
853
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
854
-			if( empty($html_name_parts ) ){
855
-				return $req_data[ $first_part_to_consider ];
856
-			}else{
851
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
852
+		$first_part_to_consider = array_shift($html_name_parts);
853
+		if (isset($req_data[$first_part_to_consider])) {
854
+			if (empty($html_name_parts)) {
855
+				return $req_data[$first_part_to_consider];
856
+			} else {
857 857
 				return $this->_find_form_data_for_this_section_using_name_parts(
858 858
 					$html_name_parts,
859
-					$req_data[ $first_part_to_consider ]
859
+					$req_data[$first_part_to_consider]
860 860
 				);
861 861
 			}
862
-		}else{
862
+		} else {
863 863
 			return NULL;
864 864
 		}
865 865
 	}
@@ -873,14 +873,14 @@  discard block
 block discarded – undo
873 873
 	 * @return boolean
874 874
 	 * @throws \EE_Error
875 875
 	 */
876
-	public function form_data_present_in($req_data = NULL){
877
-		if( $req_data === NULL ){
876
+	public function form_data_present_in($req_data = NULL) {
877
+		if ($req_data === NULL) {
878 878
 			$req_data = $_POST;
879 879
 		}
880
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
881
-		if( $checked_value !== null ){
880
+		$checked_value = $this->find_form_data_for_this_section($req_data);
881
+		if ($checked_value !== null) {
882 882
 			return TRUE;
883
-		}else{
883
+		} else {
884 884
 			return FALSE;
885 885
 		}
886 886
 	}
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 * @param array $form_other_js_data
892 892
 	 * @return array
893 893
 	 */
894
-	public function get_other_js_data( $form_other_js_data = array() ) {
895
-		$form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data );
894
+	public function get_other_js_data($form_other_js_data = array()) {
895
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
896 896
 		return $form_other_js_data;
897 897
 	}
898 898
 
@@ -905,10 +905,10 @@  discard block
 block discarded – undo
905 905
 	 * @param array $form_other_js_data
906 906
 	 * @return array
907 907
 	 */
908
-	public function get_other_js_data_from_strategies( $form_other_js_data = array() ) {
909
-		$form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data );
910
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
911
-			$form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data );
908
+	public function get_other_js_data_from_strategies($form_other_js_data = array()) {
909
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
910
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
911
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
912 912
 		}
913 913
 		return $form_other_js_data;
914 914
 	}
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
918 918
 	 * @return void
919 919
 	 */
920
-	public function enqueue_js(){
920
+	public function enqueue_js() {
921 921
 		//ask our display strategy and validation strategies if they have js to enqueue
922 922
 		$this->enqueue_js_from_strategies();
923 923
 	}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 */
929 929
 	public function enqueue_js_from_strategies() {
930 930
 		$this->get_display_strategy()->enqueue_js();
931
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
931
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
932 932
 			$validation_strategy->enqueue_js();
933 933
 		}
934 934
 	}
Please login to merge, or discard this patch.