Passed
Branch master (51607c)
by Paul
05:13
created
plugin/Commands/TogglePinned.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 	public $id;
8 8
 	public $pinned;
9 9
 
10
-	public function __construct( $input )
10
+	public function __construct($input)
11 11
 	{
12 12
 		$this->id = $input['id'];
13
-		$this->pinned = isset( $input['pinned'] )
14
-			? wp_validate_boolean( $input['pinned'] )
13
+		$this->pinned = isset($input['pinned'])
14
+			? wp_validate_boolean($input['pinned'])
15 15
 			: null;
16 16
 	}
17 17
 }
Please login to merge, or discard this patch.
plugin/Commands/ChangeStatus.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
 	public $id;
8 8
 	public $status;
9 9
 
10
-	public function __construct( $input )
10
+	public function __construct($input)
11 11
 	{
12 12
 		$this->id = $input['post_id'];
13 13
 		$this->status = $input['status'] == 'approve'
Please login to merge, or discard this patch.
plugin/Commands/RegisterTaxonomy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 {
7 7
 	public $args;
8 8
 
9
-	public function __construct( $input )
9
+	public function __construct($input)
10 10
 	{
11 11
 		$this->args = $input;
12 12
 	}
Please login to merge, or discard this patch.
plugin/Commands/RegisterPointers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 {
7 7
 	public $pointers;
8 8
 
9
-	public function __construct( $input )
9
+	public function __construct($input)
10 10
 	{
11 11
 		$this->pointers = $input;
12 12
 	}
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 * @param mixed $data
68 68
 	 * @return array
69 69
 	 */
70
-	public function validate( $data, array $rules = [] )
70
+	public function validate($data, array $rules = [])
71 71
 	{
72
-		$this->normalizeData( $data );
73
-		$this->setRules( $rules );
74
-		foreach( $this->rules as $attribute => $rules ) {
75
-			foreach( $rules as $rule ) {
76
-				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
72
+		$this->normalizeData($data);
73
+		$this->setRules($rules);
74
+		foreach ($this->rules as $attribute => $rules) {
75
+			foreach ($rules as $rule) {
76
+				$this->validateAttribute($attribute, $rule);
77
+				if ($this->shouldStopValidating($attribute))break;
78 78
 			}
79 79
 		}
80 80
 		return $this->errors;
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 	 * @return void
88 88
 	 * @throws BadMethodCallException
89 89
 	 */
90
-	public function validateAttribute( $attribute, $rule )
90
+	public function validateAttribute($attribute, $rule)
91 91
 	{
92
-		list( $rule, $parameters ) = $this->parseRule( $rule );
93
-		if( $rule == '' )return;
94
-		$value = $this->getValue( $attribute );
95
-		$this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules );
96
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
97
-			throw new BadMethodCallException( "Method [$method] does not exist." );
92
+		list($rule, $parameters) = $this->parseRule($rule);
93
+		if ($rule == '')return;
94
+		$value = $this->getValue($attribute);
95
+		$this->validateRequired($attribute, $value) || in_array($rule, $this->implicitRules);
96
+		if (!method_exists($this, $method = 'validate'.$rule)) {
97
+			throw new BadMethodCallException("Method [$method] does not exist.");
98 98
 		}
99
-		if( !$this->$method( $attribute, $value, $parameters )) {
100
-			$this->addFailure( $attribute, $rule, $parameters );
99
+		if (!$this->$method($attribute, $value, $parameters)) {
100
+			$this->addFailure($attribute, $rule, $parameters);
101 101
 		}
102 102
 	}
103 103
 
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 	 * @param string $rule
108 108
 	 * @return void
109 109
 	 */
110
-	protected function addError( $attribute, $rule, array $parameters )
110
+	protected function addError($attribute, $rule, array $parameters)
111 111
 	{
112
-		$message = $this->getMessage( $attribute, $rule, $parameters );
112
+		$message = $this->getMessage($attribute, $rule, $parameters);
113 113
 		$this->errors[$attribute]['errors'][] = $message;
114
-		if( !isset( $this->errors[$attribute]['value'] )) {
115
-			$this->errors[$attribute]['value'] = $this->getValue( $attribute );
114
+		if (!isset($this->errors[$attribute]['value'])) {
115
+			$this->errors[$attribute]['value'] = $this->getValue($attribute);
116 116
 		}
117 117
 	}
118 118
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @param string $rule
123 123
 	 * @return void
124 124
 	 */
125
-	protected function addFailure( $attribute, $rule, array $parameters )
125
+	protected function addFailure($attribute, $rule, array $parameters)
126 126
 	{
127
-		$this->addError( $attribute, $rule, $parameters );
127
+		$this->addError($attribute, $rule, $parameters);
128 128
 		$this->failedRules[$attribute][$rule] = $parameters;
129 129
 	}
130 130
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 * @param string $attribute
134 134
 	 * @return string
135 135
 	 */
136
-	protected function getAttributeType( $attribute )
136
+	protected function getAttributeType($attribute)
137 137
 	{
138
-		return $this->hasRule( $attribute, $this->numericRules )
138
+		return $this->hasRule($attribute, $this->numericRules)
139 139
 			? 'numeric'
140 140
 			: 'string';
141 141
 	}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 * @param string $rule
147 147
 	 * @return string|null
148 148
 	 */
149
-	protected function getMessage( $attribute, $rule, array $parameters )
149
+	protected function getMessage($attribute, $rule, array $parameters)
150 150
 	{
151
-		if( in_array( $rule, $this->sizeRules )) {
152
-			return $this->getSizeMessage( $attribute, $rule, $parameters );
151
+		if (in_array($rule, $this->sizeRules)) {
152
+			return $this->getSizeMessage($attribute, $rule, $parameters);
153 153
 		}
154
-		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
155
-		return $this->translator( $lowerRule, $rule, $attribute, $parameters );
154
+		$lowerRule = glsr(Helper::class)->snakeCase($rule);
155
+		return $this->translator($lowerRule, $rule, $attribute, $parameters);
156 156
 	}
157 157
 
158 158
 	/**
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 	 * @param string|array $rules
162 162
 	 * @return array|null
163 163
 	 */
164
-	protected function getRule( $attribute, $rules )
164
+	protected function getRule($attribute, $rules)
165 165
 	{
166
-		if( !array_key_exists( $attribute, $this->rules ))return;
167
-		$rules = (array) $rules;
168
-		foreach( $this->rules[$attribute] as $rule ) {
169
-			list( $rule, $parameters ) = $this->parseRule( $rule );
170
-			if( in_array( $rule, $rules )) {
166
+		if (!array_key_exists($attribute, $this->rules))return;
167
+		$rules = (array)$rules;
168
+		foreach ($this->rules[$attribute] as $rule) {
169
+			list($rule, $parameters) = $this->parseRule($rule);
170
+			if (in_array($rule, $rules)) {
171 171
 				return [$rule, $parameters];
172 172
 			}
173 173
 		}
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 	 * @param mixed $value
180 180
 	 * @return mixed
181 181
 	 */
182
-	protected function getSize( $attribute, $value )
182
+	protected function getSize($attribute, $value)
183 183
 	{
184
-		$hasNumeric = $this->hasRule( $attribute, $this->numericRules );
185
-		if( is_numeric( $value ) && $hasNumeric ) {
184
+		$hasNumeric = $this->hasRule($attribute, $this->numericRules);
185
+		if (is_numeric($value) && $hasNumeric) {
186 186
 			return $value;
187 187
 		}
188
-		elseif( is_array( $value )) {
189
-			return count( $value );
188
+		elseif (is_array($value)) {
189
+			return count($value);
190 190
 		}
191
-		return mb_strlen( $value );
191
+		return mb_strlen($value);
192 192
 	}
193 193
 
194 194
 	/**
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 	 * @param string $rule
198 198
 	 * @return string|null
199 199
 	 */
200
-	protected function getSizeMessage( $attribute, $rule, array $parameters )
200
+	protected function getSizeMessage($attribute, $rule, array $parameters)
201 201
 	{
202
-		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
203
-		$type = $this->getAttributeType( $attribute );
202
+		$lowerRule = glsr(Helper::class)->snakeCase($rule);
203
+		$type = $this->getAttributeType($attribute);
204 204
 		$lowerRule .= '.'.$type;
205
-		return $this->translator( $lowerRule, $rule, $attribute, $parameters );
205
+		return $this->translator($lowerRule, $rule, $attribute, $parameters);
206 206
 	}
207 207
 
208 208
 	/**
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 * @param string $attribute
211 211
 	 * @return mixed
212 212
 	 */
213
-	protected function getValue( $attribute )
213
+	protected function getValue($attribute)
214 214
 	{
215
-		if( isset( $this->data[$attribute] )) {
215
+		if (isset($this->data[$attribute])) {
216 216
 			return $this->data[$attribute];
217 217
 		}
218 218
 	}
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	 * @param string|array $rules
224 224
 	 * @return bool
225 225
 	 */
226
-	protected function hasRule( $attribute, $rules )
226
+	protected function hasRule($attribute, $rules)
227 227
 	{
228
-		return !is_null( $this->getRule( $attribute, $rules ));
228
+		return !is_null($this->getRule($attribute, $rules));
229 229
 	}
230 230
 
231 231
 	/**
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	 * @param mixed $data
234 234
 	 * @return $this
235 235
 	 */
236
-	protected function normalizeData( $data )
236
+	protected function normalizeData($data)
237 237
 	{
238
-		$this->data = is_object( $data )
239
-			? get_object_vars( $data )
238
+		$this->data = is_object($data)
239
+			? get_object_vars($data)
240 240
 			: $data;
241 241
 		return $this;
242 242
 	}
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 	 * @param string $parameter
248 248
 	 * @return array
249 249
 	 */
250
-	protected function parseParameters( $rule, $parameter )
250
+	protected function parseParameters($rule, $parameter)
251 251
 	{
252
-		if( strtolower( $rule ) == 'regex' ) {
252
+		if (strtolower($rule) == 'regex') {
253 253
 			return [$parameter];
254 254
 		}
255
-		return str_getcsv( $parameter );
255
+		return str_getcsv($parameter);
256 256
 	}
257 257
 
258 258
 	/**
@@ -260,17 +260,17 @@  discard block
 block discarded – undo
260 260
 	 * @param string $rule
261 261
 	 * @return array
262 262
 	 */
263
-	protected function parseRule( $rule )
263
+	protected function parseRule($rule)
264 264
 	{
265 265
 		$parameters = [];
266 266
 		// example: {rule}:{parameters}
267
-		if( strpos( $rule, ':' ) !== false ) {
268
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
267
+		if (strpos($rule, ':') !== false) {
268
+			list($rule, $parameter) = explode(':', $rule, 2);
269 269
 			// example: {parameter1,parameter2,...}
270
-			$parameters = $this->parseParameters( $rule, $parameter );
270
+			$parameters = $this->parseParameters($rule, $parameter);
271 271
 		}
272
-		$rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule )));
273
-		$rule = str_replace( ' ', '', $rule );
272
+		$rule = ucwords(str_replace(['-', '_'], ' ', trim($rule)));
273
+		$rule = str_replace(' ', '', $rule);
274 274
 		return [$rule, $parameters];
275 275
 	}
276 276
 
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	 * Set the validation rules.
279 279
 	 * @return $this
280 280
 	 */
281
-	protected function setRules( array $rules )
281
+	protected function setRules(array $rules)
282 282
 	{
283
-		foreach( $rules as $key => $rule ) {
284
-			$rules[$key] = is_string( $rule )
285
-				? explode( '|', $rule )
283
+		foreach ($rules as $key => $rule) {
284
+			$rules[$key] = is_string($rule)
285
+				? explode('|', $rule)
286 286
 				: $rule;
287 287
 		}
288 288
 		$this->rules = $rules;
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 * @param string $attribute
295 295
 	 * @return bool
296 296
 	 */
297
-	protected function shouldStopValidating( $attribute )
297
+	protected function shouldStopValidating($attribute)
298 298
 	{
299
-		return $this->hasRule( $attribute, $this->implicitRules )
300
-			&& isset( $this->failedRules[$attribute] )
301
-			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
299
+		return $this->hasRule($attribute, $this->implicitRules)
300
+			&& isset($this->failedRules[$attribute])
301
+			&& array_intersect(array_keys($this->failedRules[$attribute]), $this->implicitRules);
302 302
 	}
303 303
 
304 304
 	/**
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 	 * @param string $attribute
309 309
 	 * @return string|null
310 310
 	 */
311
-	protected function translator( $key, $rule, $attribute, array $parameters )
311
+	protected function translator($key, $rule, $attribute, array $parameters)
312 312
 	{
313
-		$strings = glsr( Strings::class )->validation();
314
-		$message = isset( $strings[$key] )
313
+		$strings = glsr(Strings::class)->validation();
314
+		$message = isset($strings[$key])
315 315
 			? $strings[$key]
316 316
 			: false;
317
-		if( !$message )return;
318
-		$message = str_replace( ':attribute', $attribute, $message );
319
-		if( method_exists( $this, $replacer = 'replace'.$rule )) {
320
-			$message = $this->$replacer( $message, $parameters );
317
+		if (!$message)return;
318
+		$message = str_replace(':attribute', $attribute, $message);
319
+		if (method_exists($this, $replacer = 'replace'.$rule)) {
320
+			$message = $this->$replacer($message, $parameters);
321 321
 		}
322 322
 		return $message;
323 323
 	}
Please login to merge, or discard this patch.
plugin/Modules/Html/Template.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
 	 * @param string $templatePath
11 11
 	 * @return void|string
12 12
 	 */
13
-	public function build( $templatePath, array $args = [] )
13
+	public function build($templatePath, array $args = [])
14 14
 	{
15
-		$args = $this->normalize( $args );
16
-		$file = glsr()->path( 'views/'.$templatePath.'.php' );
17
-		if( !file_exists( $file )) {
18
-			glsr_log()->error( 'Template missing: '.$file );
15
+		$args = $this->normalize($args);
16
+		$file = glsr()->path('views/'.$templatePath.'.php');
17
+		if (!file_exists($file)) {
18
+			glsr_log()->error('Template missing: '.$file);
19 19
 			return;
20 20
 		}
21 21
 		ob_start();
22
-		$render = glsr( Html::class )->render( $args['globals'] );
22
+		$render = glsr(Html::class)->render($args['globals']);
23 23
 		include $file;
24 24
 		$template = ob_get_clean();
25
-		return $this->interpolate( $template, $args['context'] );
25
+		return $this->interpolate($template, $args['context']);
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,35 +30,35 @@  discard block
 block discarded – undo
30 30
 	 * @param string $template
31 31
 	 * @return string
32 32
 	 */
33
-	public function interpolate( $template, array $context = [] )
33
+	public function interpolate($template, array $context = [])
34 34
 	{
35
-		$context = $this->normalizeContext( $context );
36
-		foreach( $context as $key => $value ) {
35
+		$context = $this->normalizeContext($context);
36
+		foreach ($context as $key => $value) {
37 37
 			$template = strtr(
38 38
 				$template,
39
-				array_fill_keys( ['{'.$key.'}', '{{ '.$key.' }}'], $value )
39
+				array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value)
40 40
 			);
41 41
 		}
42
-		return trim( $template );
42
+		return trim($template);
43 43
 	}
44 44
 
45 45
 	/**
46 46
 	 * @param string $templatePath
47 47
 	 * @return void|string
48 48
 	 */
49
-	public function render( $templatePath, array $args = [] )
49
+	public function render($templatePath, array $args = [])
50 50
 	{
51
-		echo $this->build( $templatePath, $args );
51
+		echo $this->build($templatePath, $args);
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * @return array
56 56
 	 */
57
-	protected function normalize( array $args )
57
+	protected function normalize(array $args)
58 58
 	{
59
-		$args = shortcode_atts( array_fill_keys( ['context', 'globals'], [] ), $args );
60
-		foreach( $args as $key => $value ) {
61
-			if( is_array( $value ))continue;
59
+		$args = shortcode_atts(array_fill_keys(['context', 'globals'], []), $args);
60
+		foreach ($args as $key => $value) {
61
+			if (is_array($value))continue;
62 62
 			$args[$key] = [];
63 63
 		}
64 64
 		return $args;
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	/**
68 68
 	 * @return array
69 69
 	 */
70
-	protected function normalizeContext( array $context )
70
+	protected function normalizeContext(array $context)
71 71
 	{
72
-		$context = array_filter( $context, function( $value ) {
73
-			return !is_array( $value ) && !is_object( $value );
72
+		$context = array_filter($context, function($value) {
73
+			return !is_array($value) && !is_object($value);
74 74
 		});
75
-		return array_map( function( $value ) {
76
-			return esc_attr( (string)$value );
77
-		}, $context );
75
+		return array_map(function($value) {
76
+			return esc_attr((string)$value);
77
+		}, $context);
78 78
 	}
79 79
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Honeypot.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 	 */
12 12
 	public function build()
13 13
 	{
14
-		$this->builder->args = wp_parse_args( $this->builder->args, [
14
+		$this->builder->args = wp_parse_args($this->builder->args, [
15 15
 			'autocomplete' => 'off',
16 16
 			'name' => $this->builder->args['text'],
17 17
 			'style' => 'display:none!important',
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/YesNo.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 	 */
12 12
 	public function build()
13 13
 	{
14
-		$this->builder->args = wp_parse_args( $this->builder->args, [
14
+		$this->builder->args = wp_parse_args($this->builder->args, [
15 15
 			'type' => 'radio',
16 16
 			'options' => [
17
-				'no' => __( 'No', 'site-reviews' ),
18
-				'yes' => __( 'Yes', 'site-reviews' ),
17
+				'no' => __('No', 'site-reviews'),
18
+				'yes' => __('Yes', 'site-reviews'),
19 19
 			],
20 20
 		]);
21 21
 		$this->builder->tag = 'input';
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Field.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 	 */
12 12
 	protected $builder;
13 13
 
14
-	public function __construct( Builder $builder )
14
+	public function __construct(Builder $builder)
15 15
 	{
16 16
 		$this->builder = $builder;
17 17
 	}
Please login to merge, or discard this patch.