Passed
Push — master ( 4bbf0d...266c96 )
by Paul
03:53
created
plugin/Helper.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	{
17 17
 		$className = $this->camelCase( $name );
18 18
 		$path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
19
-		return !empty( $path )
19
+		return !empty($path)
20 20
 			? __NAMESPACE__.'\\'.$path.'\\'.$className
21 21
 			: $className;
22 22
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function buildMethodName( $name, $prefix = '' )
30 30
 	{
31
-		return lcfirst( $prefix.$this->buildClassName( $name ));
31
+		return lcfirst( $prefix.$this->buildClassName( $name ) );
32 32
 	}
33 33
 
34 34
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function buildPropertyName( $name )
39 39
 	{
40
-		return lcfirst( $this->buildClassName( $name ));
40
+		return lcfirst( $this->buildClassName( $name ) );
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function camelCase( $string )
48 48
 	{
49
-		$string = ucwords( str_replace( ['-', '_'], ' ', trim( $string )));
49
+		$string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
50 50
 		return str_replace( ' ', '', $string );
51 51
 	}
52 52
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function convertPathToId( $path, $prefix = '' )
80 80
 	{
81
-		return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ));
81
+		return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) );
82 82
 	}
83 83
 
84 84
 	/**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		$levels = explode( '.', $path );
91 91
 		return array_reduce( $levels, function( $result, $value ) {
92
-			return $result.= '['.$value.']';
92
+			return $result .= '['.$value.']';
93 93
 		}, $prefix );
94 94
 	}
95 95
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function convertStringToArray( $string, $callback = null )
102 102
 	{
103
-		$array = array_map( 'trim', explode( ',', $string ));
103
+		$array = array_map( 'trim', explode( ',', $string ) );
104 104
 		return $callback
105 105
 			? array_filter( $array, $callback )
106 106
 			: array_filter( $array );
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function dashCase( $string )
114 114
 	{
115
-		return str_replace( '_', '-', $this->snakeCase( $string ));
115
+		return str_replace( '_', '-', $this->snakeCase( $string ) );
116 116
 	}
117 117
 
118 118
 	/**
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function filterInput( $key, array $request = [] )
136 136
 	{
137
-		if( isset( $request[$key] )) {
137
+		if( isset($request[$key]) ) {
138 138
 			return $request[$key];
139 139
 		}
140 140
 		$variable = filter_input( INPUT_POST, $key );
141
-		if( is_null( $variable ) && isset( $_POST[$key] )) {
141
+		if( is_null( $variable ) && isset($_POST[$key]) ) {
142 142
 			$variable = $_POST[$key];
143 143
 		}
144 144
 		return $variable;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	public function filterInputArray( $key )
152 152
 	{
153 153
 		$variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
154
-		if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) {
154
+		if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
155 155
 			$variable = $_POST[$key];
156 156
 		}
157 157
 		return (array)$variable;
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 		$result = [];
168 168
 		foreach( $array as $key => $value ) {
169 169
 			$newKey = ltrim( $prefix.'.'.$key, '.' );
170
-			if( $this->isIndexedFlatArray( $value )) {
170
+			if( $this->isIndexedFlatArray( $value ) ) {
171 171
 				if( $flattenValue ) {
172 172
 					$value = '['.implode( ', ', $value ).']';
173 173
 				}
174 174
 			}
175
-			else if( is_array( $value )) {
176
-				$result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ));
175
+			else if( is_array( $value ) ) {
176
+				$result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) );
177 177
 				continue;
178 178
 			}
179 179
 			$result[$newKey] = $value;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				Whip::IPV4 => $cloudflareIps['v4'],
193 193
 				Whip::IPV6 => $cloudflareIps['v6'],
194 194
 			],
195
-		]))->getValidIpAddress();
195
+		] ))->getValidIpAddress();
196 196
 	}
197 197
 
198 198
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	{
206 206
 		$keys = explode( '.', $path );
207 207
 		foreach( $keys as $key ) {
208
-			if( !isset( $values[$key] )) {
208
+			if( !isset($values[$key]) ) {
209 209
 				return $fallback;
210 210
 			}
211 211
 			$values = $values[$key];
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function isIndexedArray( $array )
221 221
 	{
222
-		if( !is_array( $array )) {
222
+		if( !is_array( $array ) ) {
223 223
 			return false;
224 224
 		}
225 225
 		$current = 0;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function isIndexedFlatArray( $array )
240 240
 	{
241
-		if( !is_array( $array ) || array_filter( $array, 'is_array' )) {
241
+		if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
242 242
 			return false;
243 243
 		}
244 244
 		return $this->isIndexedArray( $array );
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function prefixString( $string, $prefix = '' )
253 253
 	{
254
-		return $prefix.str_replace( $prefix, '', trim( $string ));
254
+		return $prefix.str_replace( $prefix, '', trim( $string ) );
255 255
 	}
256 256
 
257 257
 	/**
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function removePrefix( $prefix, $text ) {
278 278
 		return 0 === strpos( $text, $prefix )
279
-			? substr( $text, strlen( $prefix ))
279
+			? substr( $text, strlen( $prefix ) )
280 280
 			: $text;
281 281
 	}
282 282
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 */
308 308
 	public function snakeCase( $string )
309 309
 	{
310
-		if( !ctype_lower( $string )) {
310
+		if( !ctype_lower( $string ) ) {
311 311
 			$string = preg_replace( '/\s+/u', '', $string );
312 312
 			$string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
313 313
 			$string = function_exists( 'mb_strtolower' )
@@ -324,6 +324,6 @@  discard block
 block discarded – undo
324 324
 	 */
325 325
 	public function startsWith( $needle, $haystack )
326 326
 	{
327
-		return substr( $haystack, 0, strlen( $needle )) === $needle;
327
+		return substr( $haystack, 0, strlen( $needle ) ) === $needle;
328 328
 	}
329 329
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		foreach( $this->rules as $attribute => $rules ) {
75 75
 			foreach( $rules as $rule ) {
76 76
 				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
77
+				if( $this->shouldStopValidating( $attribute ) )break;
78 78
 			}
79 79
 		}
80 80
 		return $this->errors;
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function validateAttribute( $attribute, $rule )
91 91
 	{
92
-		list( $rule, $parameters ) = $this->parseRule( $rule );
92
+		list($rule, $parameters) = $this->parseRule( $rule );
93 93
 		if( $rule == '' )return;
94 94
 		$value = $this->getValue( $attribute );
95
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
95
+		if( !method_exists( $this, $method = 'validate'.$rule ) ) {
96 96
 			throw new BadMethodCallException( "Method [$method] does not exist." );
97 97
 		}
98
-		if( !$this->$method( $value, $attribute, $parameters )) {
98
+		if( !$this->$method( $value, $attribute, $parameters ) ) {
99 99
 			$this->addFailure( $attribute, $rule, $parameters );
100 100
 		}
101 101
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function getMessage( $attribute, $rule, array $parameters )
146 146
 	{
147
-		if( in_array( $rule, $this->sizeRules )) {
147
+		if( in_array( $rule, $this->sizeRules ) ) {
148 148
 			return $this->getSizeMessage( $attribute, $rule, $parameters );
149 149
 		}
150 150
 		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	protected function getRule( $attribute, $rules )
161 161
 	{
162
-		if( !array_key_exists( $attribute, $this->rules ))return;
162
+		if( !array_key_exists( $attribute, $this->rules ) )return;
163 163
 		$rules = (array)$rules;
164 164
 		foreach( $this->rules[$attribute] as $rule ) {
165
-			list( $rule, $parameters ) = $this->parseRule( $rule );
166
-			if( in_array( $rule, $rules )) {
165
+			list($rule, $parameters) = $this->parseRule( $rule );
166
+			if( in_array( $rule, $rules ) ) {
167 167
 				return [$rule, $parameters];
168 168
 			}
169 169
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		if( is_numeric( $value ) && $hasNumeric ) {
182 182
 			return $value;
183 183
 		}
184
-		elseif( is_array( $value )) {
184
+		elseif( is_array( $value ) ) {
185 185
 			return count( $value );
186 186
 		}
187 187
 		return function_exists( 'mb_strlen' )
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	protected function getValue( $attribute )
211 211
 	{
212
-		if( isset( $this->data[$attribute] )) {
212
+		if( isset($this->data[$attribute]) ) {
213 213
 			return $this->data[$attribute];
214 214
 		}
215 215
 	}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	protected function hasRule( $attribute, $rules )
224 224
 	{
225
-		return !is_null( $this->getRule( $attribute, $rules ));
225
+		return !is_null( $this->getRule( $attribute, $rules ) );
226 226
 	}
227 227
 
228 228
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	{
261 261
 		$parameters = [];
262 262
 		if( strpos( $rule, ':' ) !== false ) {
263
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
263
+			list($rule, $parameter) = explode( ':', $rule, 2 );
264 264
 			$parameters = $this->parseParameters( $rule, $parameter );
265 265
 		}
266 266
 		$rule = glsr( Helper::class )->camelCase( $rule );
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	protected function shouldStopValidating( $attribute )
290 290
 	{
291 291
 		return $this->hasRule( $attribute, $this->implicitRules )
292
-			&& isset( $this->failedRules[$attribute] )
292
+			&& isset($this->failedRules[$attribute])
293 293
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
294 294
 	}
295 295
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	protected function translator( $key, array $parameters )
303 303
 	{
304 304
 		$strings = glsr( ValidationStringsDefaults::class )->defaults();
305
-		if( isset( $strings[$key] )) {
305
+		if( isset($strings[$key]) ) {
306 306
 			return $this->replace( $strings[$key], $parameters );
307 307
 		}
308 308
 		return "error";
Please login to merge, or discard this patch.
plugin/Modules/System.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'setting' => 'Plugin Settings',
41 41
 			'reviews' => 'Review Counts',
42 42
 		];
43
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
43
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
44 44
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
45 45
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
46 46
 				return $carry.$this->implode( strtoupper( $details[$key] ), $systemDetails );
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	{
58 58
 		$plugins = get_plugins();
59 59
 		$activePlugins = (array)get_option( 'active_plugins', [] );
60
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
61
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
60
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
61
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
62 62
 	}
63 63
 
64 64
 	/**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	public function getInactivePluginDetails()
93 93
 	{
94 94
 		$activePlugins = (array)get_option( 'active_plugins', [] );
95
-		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
95
+		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
96 96
 	}
97 97
 
98 98
 	/**
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	{
103 103
 		$plugins = array_merge(
104 104
 			get_mu_plugins(),
105
-			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
105
+			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) )
106 106
 		);
107
-		if( empty( $plugins ))return;
107
+		if( empty($plugins) )return;
108 108
 		return $this->normalizePluginList( $plugins );
109 109
 	}
110 110
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function getMultisitePluginDetails()
115 115
 	{
116
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
116
+		if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return;
117 117
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
118 118
 	}
119 119
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 			'Max Input Vars' => ini_get( 'max_input_vars' ),
140 140
 			'Memory Limit' => ini_get( 'memory_limit' ),
141 141
 			'Post Max Size' => ini_get( 'post_max_size' ),
142
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
143
-			'Session Name' => esc_html( ini_get( 'session.name' )),
144
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
145
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ),
146
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ),
142
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
143
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
144
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
145
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
146
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
147 147
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
148 148
 		];
149 149
 	}
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		$counts = glsr( CountsManager::class )->getCounts();
157 157
 		$counts = glsr( Helper::class )->flattenArray( $counts );
158
- 		array_walk( $counts, function( &$ratings ) use( $counts ) {
159
-			if( !is_array( $ratings )) {
158
+ 		array_walk( $counts, function( &$ratings ) use($counts) {
159
+			if( !is_array( $ratings ) ) {
160 160
 				glsr_log()
161 161
 					->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
162 162
 					->debug( $ratings )
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 		ksort( $settings );
196 196
 		$details = [];
197 197
 		foreach( $settings as $key => $value ) {
198
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
199
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
198
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue;
199
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
200 200
 			$details[$key] = $value;
201 201
 		}
202 202
 		return $details;
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 			'WPE_APIKEY' => 'WP Engine',
269 269
 		];
270 270
 		foreach( $checks as $key => $value ) {
271
-			if( !$this->isWebhostCheckValid( $key ))continue;
271
+			if( !$this->isWebhostCheckValid( $key ) )continue;
272 272
 			return $value;
273 273
 		}
274
-		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
274
+		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
275 275
 	}
276 276
 
277 277
 	/**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	{
293 293
 		$plugins = get_plugins();
294 294
 		$activePlugins = (array)get_option( 'active_plugins', [] );
295
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
296
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
295
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
296
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
297 297
 		return $active + $inactive;
298 298
 	}
299 299
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	protected function implode( $title, array $details )
305 305
 	{
306 306
 		$strings = ['['.$title.']'];
307
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
307
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
308 308
 		$padding = max( [$padding, static::PAD] );
309 309
 		foreach( $details as $key => $value ) {
310 310
 			$strings[] = is_string( $key )
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 		$keys = [
348 348
 			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
349 349
 		];
350
-		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
350
+		array_walk( $settings, function( &$value, $setting ) use($keys) {
351 351
 			foreach( $keys as $key ) {
352
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
352
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue;
353 353
 				$value = str_repeat( '•', 13 );
354 354
 				return;
355 355
 			}
Please login to merge, or discard this patch.