Completed
Branch master (5af635)
by Maciej
02:13
created
src/Artisan/FormArtisan.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use WFV\Collection\ErrorCollection;
9 9
 use WFV\Collection\InputCollection;
10 10
 use WFV\Collection\RuleCollection;
11
-
12 11
 use WFV\FormComposite;
13 12
 use WFV\Validators;
14 13
 use WFV\Validator;
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Artisan;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use \Respect\Validation\Validator as RespectValidator;
6 6
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @param array $config
71 71
 	 */
72
-	function __construct( array $config ) {
72
+	function __construct(array $config) {
73 73
 		$this->config = $config;
74 74
 	}
75 75
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 * @param string $action
93 93
 	 * @return WFV\Artisan\FormArtisan
94 94
 	 */
95
-	public function create( $action ) {
96
-		$this->form = new FormComposite( $this, $action );
95
+	public function create($action) {
96
+		$this->form = new FormComposite($this, $action);
97 97
 		return $this;
98 98
 	}
99 99
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return WFV\Artisan\FormArtisan
107 107
 	 */
108 108
 	public function errors() {
109
-		$this->collection['errors'] = new ErrorCollection( $this->labels() );
109
+		$this->collection['errors'] = new ErrorCollection($this->labels());
110 110
 		return $this;
111 111
 	}
112 112
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @return array
121 121
 	 */
122 122
 	protected function labels() {
123
-		return array_map( function( $item ) {
123
+		return array_map(function($item) {
124 124
 			return $item['label'];
125 125
 		}, $this->config);
126 126
 	}
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	 * @param array $data
135 135
 	 * @return WFV\Artisan\FormArtisan
136 136
 	 */
137
-	public function input( array $data = [] ) {
137
+	public function input(array $data = []) {
138 138
 		$input = $data[0];
139 139
 		$trim = $data[1];
140
-		$this->collection['input'] = new InputCollection( $input, $trim );
140
+		$this->collection['input'] = new InputCollection($input, $trim);
141 141
 		return $this;
142 142
 	}
143 143
 
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 	 * @return WFV\Artisan\FormArtisan
151 151
 	 */
152 152
 	public function rules() {
153
-		foreach( $this->config as $field => $options ) {
154
-			$rules[ $field ] = $options['rules'];
153
+		foreach ($this->config as $field => $options) {
154
+			$rules[$field] = $options['rules'];
155 155
 		}
156
-		$this->collection['rules'] = new RuleCollection( $rules );
156
+		$this->collection['rules'] = new RuleCollection($rules);
157 157
 		$this->resolve_strategies();
158 158
 		return $this;
159 159
 	}
@@ -186,25 +186,25 @@  discard block
 block discarded – undo
186 186
 		$optional = false;
187 187
 		$rules = $this->collection['rules']->get_array();
188 188
 
189
-		foreach( $rules as $field => $ruleset ) {
189
+		foreach ($rules as $field => $ruleset) {
190 190
 
191 191
 			$optional = in_array("optional", $ruleset);
192 192
 
193
-			foreach( $ruleset as $rule ) {
193
+			foreach ($ruleset as $rule) {
194 194
 
195
-				if( 'optional' !== $rule ){
195
+				if ('optional' !== $rule) {
196 196
 
197
-					$rule_name = ( is_string( $rule ) ) ? $rule : $rule['rule'];
198
-					$class = str_replace(' ', '', ucwords( str_replace('_', ' ', $rule_name ) ) );
197
+					$rule_name = (is_string($rule)) ? $rule : $rule['rule'];
198
+					$class = str_replace(' ', '', ucwords(str_replace('_', ' ', $rule_name)));
199 199
 					$class = 'WFV\Validators\\'.$class;
200 200
 
201
-					$message = ( isset( $this->config[ $field ]['messages'][ $rule_name ] ) )
202
-						? $this->config[ $field ]['messages'][ $rule_name ]
201
+					$message = (isset($this->config[$field]['messages'][$rule_name]))
202
+						? $this->config[$field]['messages'][$rule_name]
203 203
 						: false;
204 204
 
205
-					$strategies[ $field ][ $rule_name ] = ( is_string( $rule ) )
206
-						? new $class( new RespectValidator(), $field, $optional, $message )
207
-						: new $class( new RespectValidator(), $field, $optional, $message, $rule['params'] );
205
+					$strategies[$field][$rule_name] = (is_string($rule))
206
+						? new $class(new RespectValidator(), $field, $optional, $message)
207
+						: new $class(new RespectValidator(), $field, $optional, $message, $rule['params']);
208 208
 				}
209 209
 			}
210 210
 		}
Please login to merge, or discard this patch.
src/FormComposite.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use WFV\Abstraction\Composable;
6 6
 use WFV\Contract\ArtisanInterface;
7
-use WFV\Contract\ValidateInterface;
8 7
 
9 8
 /**
10 9
  * Form Composition
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Abstraction\Composable;
6 6
 use WFV\Contract\ArtisanInterface;
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	 * @param ArtisanInterface $builder
40 40
 	 * @param string $action
41 41
 	 */
42
-	function __construct( ArtisanInterface $builder, $action ) {
42
+	function __construct(ArtisanInterface $builder, $action) {
43 43
 		$this->alias = $action;
44
-		$this->install( $builder->collection );
44
+		$this->install($builder->collection);
45 45
 		$this->strategies = $builder->strategies;
46 46
 		$this->validator = $builder->validator;
47 47
 	}
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 * @param string $value Value to compare against.
56 56
 	 * @return string|null
57 57
 	 */
58
-	public function checked_if( $field = null, $value = null ) {
59
-		return $this->string_or_null( 'checked', $field, $value );
58
+	public function checked_if($field = null, $value = null) {
59
+		return $this->string_or_null('checked', $field, $value);
60 60
 	}
61 61
 
62 62
 	/**
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	 * @param callable (optional) $callback
71 71
 	 * @return string
72 72
 	 */
73
-	public function display( $field = null, callable $callback = null ) {
74
-		echo $input = $this->utilize('input')->escape( $field );
73
+	public function display($field = null, callable $callback = null) {
74
+		echo $input = $this->utilize('input')->escape($field);
75 75
 		return $input;
76 76
 	}
77 77
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	 * @param string $value Value to compare against.
108 108
 	 * @return string|null
109 109
 	 */
110
-	public function selected_if( $field = null, $value = null ) {
111
-		return $this->string_or_null( 'selected', $field, $value );
110
+	public function selected_if($field = null, $value = null) {
111
+		return $this->string_or_null('selected', $field, $value);
112 112
 	}
113 113
 
114 114
 	/**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function token_fields() {
122 122
 		// TODO - Move markup into something - perhaps a renderable interface?
123
-		$token_name = $this->alias . '_token';
124
-		echo $nonce_field = wp_nonce_field( $this->alias, $token_name, false, false );
125
-		echo $action_field = '<input type="hidden" name="action" value="'. $this->alias .'">';
123
+		$token_name = $this->alias.'_token';
124
+		echo $nonce_field = wp_nonce_field($this->alias, $token_name, false, false);
125
+		echo $action_field = '<input type="hidden" name="action" value="'.$this->alias.'">';
126 126
 	}
127 127
 
128 128
 	/**
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	 * @return bool
135 135
 	 */
136 136
 	public function validate() {
137
-		$input = $this->utilize('input')->get_array( false );
137
+		$input = $this->utilize('input')->get_array(false);
138 138
 		$rules = $this->utilize('rules')->get_array();
139 139
 
140
-		foreach( array_keys($rules) as $field ) {
141
-			if( $this->strategies[ $field ] ) {
142
-				foreach( $this->strategies[ $field ] as $rule ) {
143
-					$value = ( isset( $input[ $field ] ) ) ? $input[ $field ] : null;
144
-					$this->validator->validate( $rule, $value );
140
+		foreach (array_keys($rules) as $field) {
141
+			if ($this->strategies[$field]) {
142
+				foreach ($this->strategies[$field] as $rule) {
143
+					$value = (isset($input[$field])) ? $input[$field] : null;
144
+					$this->validator->validate($rule, $value);
145 145
 				}
146 146
 			}
147 147
 		}
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	protected function is_valid() {
162 162
 
163 163
 		$is_valid = $this->validator->is_valid();
164
-		if( false === $is_valid ) {
165
-			$this->utilize('errors')->set_errors( $this->validator->errors() );
164
+		if (false === $is_valid) {
165
+			$this->utilize('errors')->set_errors($this->validator->errors());
166 166
 		}
167
-		$this->trigger_post_validate_action( $is_valid );
167
+		$this->trigger_post_validate_action($is_valid);
168 168
 		return $is_valid;
169 169
 	}
170 170
 
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 	 * @param string (optional) $value
180 180
 	 * @return string|null
181 181
 	 */
182
-	protected function string_or_null( $response, $field = null, $value = null ) {
183
-		return ( $this->input( $field )->contains( $field, $value ) ) ? $response : null;
182
+	protected function string_or_null($response, $field = null, $value = null) {
183
+		return ($this->input($field)->contains($field, $value)) ? $response : null;
184 184
 	}
185 185
 
186 186
 	/**
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @param bool $is_valid
193 193
 	 */
194
-	protected function trigger_post_validate_action( $is_valid = false ) {
195
-		$action = ( true === $is_valid ) ? $this->alias : $this->alias .'_fail';
196
-		do_action( $action, $this );
194
+	protected function trigger_post_validate_action($is_valid = false) {
195
+		$action = (true === $is_valid) ? $this->alias : $this->alias.'_fail';
196
+		do_action($action, $this);
197 197
 	}
198 198
 }
Please login to merge, or discard this patch.
wfv-validate.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-defined( 'ABSPATH' ) or die();
2
+defined('ABSPATH') or die();
3 3
 /*
4 4
 Plugin Name: WFV - Form Validation
5 5
 Plugin URI:  https://macder.github.io/wfv/
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 License URI: https://github.com/macder/wp-form-validation/blob/master/LICENSE
12 12
 */
13 13
 
14
-define( 'WFV_VALIDATE_VERSION', '0.11.0' );
15
-define( 'WFV_VALIDATE__MINIMUM_WP_VERSION', '3.7' );
16
-define( 'WFV_VALIDATE__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
17
-define( 'WFV_VALIDATE__ACTION_POST', 'validate_form' );
14
+define('WFV_VALIDATE_VERSION', '0.11.0');
15
+define('WFV_VALIDATE__MINIMUM_WP_VERSION', '3.7');
16
+define('WFV_VALIDATE__PLUGIN_DIR', plugin_dir_path(__FILE__));
17
+define('WFV_VALIDATE__ACTION_POST', 'validate_form');
18 18
 
19
-require_once WFV_VALIDATE__PLUGIN_DIR . '/vendor/autoload.php';
19
+require_once WFV_VALIDATE__PLUGIN_DIR.'/vendor/autoload.php';
20 20
 
21 21
 use WFV\Agent\InspectionAgent;
22 22
 use WFV\Artisan\Director;
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
  * @param array $form Form arguments
32 32
  * @param bool $trim Trim whitespace from beginning and end of string
33 33
  */
34
-function wfv_create( $action, array &$form, $trim = true ) {
35
-	$inspect = new InspectionAgent( $action );
36
-	$input = ( true === $inspect->safe_submit() ) ? $_POST : array();
34
+function wfv_create($action, array &$form, $trim = true) {
35
+	$inspect = new InspectionAgent($action);
36
+	$input = (true === $inspect->safe_submit()) ? $_POST : array();
37 37
 
38
-	$builder = new FormArtisan( $form );
39
-	$form = ( new Director( $action ) )
40
-		->with( 'input', [ $input, $trim ] )
41
-		->with( 'rules' )
42
-		->with( 'errors' )
43
-		->with( 'validator' )
44
-		->compose( $builder );
38
+	$builder = new FormArtisan($form);
39
+	$form = (new Director($action))
40
+		->with('input', [$input, $trim])
41
+		->with('rules')
42
+		->with('errors')
43
+		->with('validator')
44
+		->compose($builder);
45 45
 
46
-	if( $input ) {
46
+	if ($input) {
47 47
 		$form->validate();
48 48
 	}
49 49
 }
Please login to merge, or discard this patch.
src/Collection/RuleCollection.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Collection;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Abstraction\Collectable;
6 6
 
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @param array $rules
20 20
 	 */
21
-	public function __construct( array $rules ) {
22
-		$this->data = $this->parse_rules( $rules );
21
+	public function __construct(array $rules) {
22
+		$this->data = $this->parse_rules($rules);
23 23
 	}
24 24
 
25 25
 
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * @param string $rule
43 43
 	 * @return bool
44 44
 	 */
45
-	public function is_custom( $rule ) {
45
+	public function is_custom($rule) {
46 46
 		// WIP - needs adjusting to new rule string format
47
-		if ( false === is_array( $rule ) ){
48
-			return ( false !== strpos( $rule, 'custom:' ) ) ? true : false;
47
+		if (false === is_array($rule)) {
48
+			return (false !== strpos($rule, 'custom:')) ? true : false;
49 49
 		}
50 50
 	}
51 51
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 * @param string $rule
59 59
 	 * @return bool
60 60
 	 */
61
-	protected function extract_name( $rule ) {
62
-		return strstr( $rule, ':', true );
61
+	protected function extract_name($rule) {
62
+		return strstr($rule, ':', true);
63 63
 	}
64 64
 
65 65
 	/**
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param string $rule
72 72
 	 * @return bool
73 73
 	 */
74
-	protected function extract_params( $rule ) {
75
-		return ltrim( strstr($rule, ':'), ':');
74
+	protected function extract_params($rule) {
75
+		return ltrim(strstr($rule, ':'), ':');
76 76
 	}
77 77
 
78 78
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @param string $rule
85 85
 	 * @return bool
86 86
 	 */
87
-	protected function has_parameters( $rule ) {
88
-		return strpos( $rule, ':' );
87
+	protected function has_parameters($rule) {
88
+		return strpos($rule, ':');
89 89
 	}
90 90
 
91 91
 	/**
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	 * @param array $rules
99 99
 	 * @return array
100 100
 	 */
101
-	protected function parse_rules( array $rules ) {
101
+	protected function parse_rules(array $rules) {
102 102
 		// WIP - works, but confusing - simplify or breakdown into small methods
103
-		$this->split_rules( $rules );
104
-		foreach( $rules as $field => $ruleset ) {
105
-			$parsed[ $field ] = array_map( function( $rule ) {
106
-				if ( $this->has_parameters( $rule ) ) {
103
+		$this->split_rules($rules);
104
+		foreach ($rules as $field => $ruleset) {
105
+			$parsed[$field] = array_map(function($rule) {
106
+				if ($this->has_parameters($rule)) {
107 107
 					return array(
108
-						'rule' => $this->extract_name( $rule ),
109
-						'params' => explode( ',', $this->extract_params( $rule ) )
108
+						'rule' => $this->extract_name($rule),
109
+						'params' => explode(',', $this->extract_params($rule))
110 110
 					);
111 111
 				}
112 112
 				return $rule;
113
-			}, $ruleset );
113
+			}, $ruleset);
114 114
 		}
115 115
 		return $parsed;
116 116
 	}
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 	 * @param array $rules
125 125
 	 * @return array
126 126
 	 */
127
-	protected function split_rules( array &$rules ) {
127
+	protected function split_rules(array &$rules) {
128 128
 		// perhaps the $rules array structure should be validated here?...
129
-		$rules = array_map( function( $item ) {
130
-			return explode( '|', $item );
131
-		}, $rules );
129
+		$rules = array_map(function($item) {
130
+			return explode('|', $item);
131
+		}, $rules);
132 132
 	}
133 133
 }
Please login to merge, or discard this patch.
src/Collection/InputCollection.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Collection;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Abstraction\Collectable;
6 6
 
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 * @param array $data
21 21
 	 * @param bool $trim
22 22
 	 */
23
-	function __construct( array $data = array(), $trim ) {
24
-		$data = $this->transform_array_leafs( $data, 'stripslashes' );
25
-		$this->data = ( $trim ) ? $this->transform_array_leafs( $data, 'trim' ) : $data;
23
+	function __construct(array $data = array(), $trim) {
24
+		$data = $this->transform_array_leafs($data, 'stripslashes');
25
+		$this->data = ($trim) ? $this->transform_array_leafs($data, 'trim') : $data;
26 26
 	}
27 27
 
28 28
 	/**
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 * @param bool $tokens With or without token and action attributes.
34 34
 	 * @return array
35 35
 	 */
36
-	public function get_array( $tokens = true ) {
37
-		return ( $tokens ) ? $this->data : $this->neat_array();
36
+	public function get_array($tokens = true) {
37
+		return ($tokens) ? $this->data : $this->neat_array();
38 38
 	}
39 39
 
40 40
 	/**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	protected function neat_array() {
49 49
 		$input = $this->data;
50
-		unset( $input[ $input['action'] .'_token'] );
51
-		unset( $input['action'] );
50
+		unset($input[$input['action'].'_token']);
51
+		unset($input['action']);
52 52
 		return $input;
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
src/Collection/ErrorCollection.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Collection;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Abstraction\Collectable;
6 6
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param array $labels Human friendly labels for the fields
28 28
 	 */
29
-	function __construct( array $labels = [] ) {
29
+	function __construct(array $labels = []) {
30 30
 		$this->labels = $labels;
31 31
 	}
32 32
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 * @param string $field
39 39
 	 * @return string|null
40 40
 	 */
41
-	public function first( $field ) {
42
-		return ( $this->data[ $field ] )
43
-			? array_values( $this->data[ $field ] )[0]
41
+	public function first($field) {
42
+		return ($this->data[$field])
43
+			? array_values($this->data[$field])[0]
44 44
 			: null;
45 45
 	}
46 46
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @param array $errors
54 54
 	 */
55
-	public function set_errors( array $errors = [] ) {
56
-		$this->data = ( $this->is_populated() )
55
+	public function set_errors(array $errors = []) {
56
+		$this->data = ($this->is_populated())
57 57
 			? $this->data
58
-			: $this->with_labels( $errors );
58
+			: $this->with_labels($errors);
59 59
 	}
60 60
 
61 61
 	/**
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	 * @param string $field
69 69
 	 * @return string
70 70
 	 */
71
-	protected function label( $field ) {
72
-		return ( isset( $this->labels[ $field ] ) )
73
-			? $this->labels[ $field ]
71
+	protected function label($field) {
72
+		return (isset($this->labels[$field]))
73
+			? $this->labels[$field]
74 74
 			: $field;
75 75
 	}
76 76
 
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	 * @param array $errors
84 84
 	 * @return array
85 85
 	 */
86
-	protected function with_labels( $errors ) {
87
-		foreach( $errors as $field => $messages ) {
88
-			$label = $this->label( $field );
89
-			$labeled[ $field ] = str_replace( '{label}', $label, $errors[ $field ] );
86
+	protected function with_labels($errors) {
87
+		foreach ($errors as $field => $messages) {
88
+			$label = $this->label($field);
89
+			$labeled[$field] = str_replace('{label}', $label, $errors[$field]);
90 90
 		}
91 91
 		return $labeled;
92 92
 	}
Please login to merge, or discard this patch.
src/Validators/AbstractValidator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use \Respect\Validation\Validator as RespectValidator;
6 6
 use \Respect\Validation\Exceptions\NestedValidationException;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param bool (optional) $optional
68 68
 	 * @param string (optional) $message
69 69
 	 */
70
-	function __construct( RespectValidator $validator, $field, $optional = false, $message = false ) {
70
+	function __construct(RespectValidator $validator, $field, $optional = false, $message = false) {
71 71
 		// WIP - simplify - parameter overload...
72 72
 
73 73
 		$this->optional = $optional;
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 
77 77
 		$args = func_get_args();
78 78
 
79
-		$this->params = ( isset( $args[4] ) ) ? $args[4] : null;
79
+		$this->params = (isset($args[4])) ? $args[4] : null;
80 80
 
81
-		if( $message ) {
82
-			$this->set_message( $message );
81
+		if ($message) {
82
+			$this->set_message($message);
83 83
 		}
84 84
 
85 85
 		$this->set_policy();
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @param string|array $input
127 127
 	 * @return bool
128 128
 	 */
129
-	public function validate( $value ) {
130
-		$is_valid = $this->validator->validate( $value );
129
+	public function validate($value) {
130
+		$is_valid = $this->validator->validate($value);
131 131
 		return $is_valid;
132 132
 	}
133 133
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @param
140 140
 	 */
141
-	protected function set_message( $message ) {
141
+	protected function set_message($message) {
142 142
 		$this->template['message'] = $message;
143 143
 	}
144 144
 }
Please login to merge, or discard this patch.
src/Validators/Required.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
Please login to merge, or discard this patch.
src/Validators/Boolean.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace WFV\Validators;
3
-defined( 'ABSPATH' ) or die();
3
+defined('ABSPATH') or die();
4 4
 
5 5
 use WFV\Validators\AbstractValidator;
6 6
 
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	protected function set_policy() {
34 34
 		$v = $this->validator;
35
-		$v = ( $this->optional )
36
-			? $v->optional( $v->create()->boolVal() )
35
+		$v = ($this->optional)
36
+			? $v->optional($v->create()->boolVal())
37 37
 			: $v->boolVal();
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.