Passed
Push — master ( 3e60cb...36c2a1 )
by Paul
07:09 queued 03:38
created
plugin/Modules/Validator/ValidateReview.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$this->validateBlacklist();
68 68
 		$this->validateAkismet();
69 69
 		$this->validateRecaptcha();
70
-		if( !empty( $this->error )) {
70
+		if( !empty($this->error) ) {
71 71
 			$this->setSessionValues( 'message', $this->error );
72 72
 		}
73 73
 		return $this;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 		if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
92 92
 			return static::RECAPTCHA_DISABLED;
93 93
 		}
94
-		if( empty( $this->request['_recaptcha-token'] )) {
95
-			return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ))
94
+		if( empty($this->request['_recaptcha-token']) ) {
95
+			return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) )
96 96
 				? static::RECAPTCHA_EMPTY
97 97
 				: static::RECAPTCHA_FAILED;
98 98
 		}
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function getRecaptchaTokenStatus()
106 106
 	{
107
-		$endpoint = add_query_arg([
107
+		$endpoint = add_query_arg( [
108 108
 			'remoteip' => glsr( Helper::class )->getIpAddress(),
109 109
 			'response' => $this->request['_recaptcha-token'],
110 110
 			'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
111 111
 		], static::RECAPTCHA_ENDPOINT );
112
-		if( is_wp_error( $response = wp_remote_get( $endpoint ))) {
112
+		if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
113 113
 			glsr_log()->error( $response->get_error_message() );
114 114
 			return static::RECAPTCHA_FAILED;
115 115
 		}
116
-		$response = json_decode( wp_remote_retrieve_body( $response ));
117
-		if( !empty( $response->success )) {
116
+		$response = json_decode( wp_remote_retrieve_body( $response ) );
117
+		if( !empty($response->success) ) {
118 118
 			return boolval( $response->success )
119 119
 				? static::RECAPTCHA_VALID
120 120
 				: static::RECAPTCHA_INVALID;
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		$rules = array_intersect_key(
134 134
 			apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ),
135
-			array_flip( $this->getOption( 'settings.submissions.required', [] ))
135
+			array_flip( $this->getOption( 'settings.submissions.required', [] ) )
136 136
 		);
137
-		$excluded = isset( $request['excluded'] )
137
+		$excluded = isset($request['excluded'])
138 138
 			? explode( ',', $request['excluded'] )
139 139
 			: [];
140
-		return array_diff_key( $rules, array_flip( $excluded ));
140
+		return array_diff_key( $rules, array_flip( $excluded ) );
141 141
 	}
142 142
 
143 143
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	{
148 148
 		$rules = $this->getValidationRules( $request );
149 149
 		$errors = glsr( Validator::class )->validate( $request, $rules );
150
-		if( empty( $errors )) {
150
+		if( empty($errors) ) {
151 151
 			return true;
152 152
 		}
153 153
 		$this->setSessionValues( 'errors', $errors );
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	protected function setSessionValues( $type, $value, $loggedMessage = '' )
165 165
 	{
166 166
 		glsr( Session::class )->set( $this->form_id.$type, $value );
167
-		if( !empty( $loggedMessage )) {
167
+		if( !empty($loggedMessage) ) {
168 168
 			glsr_log()->warning( $loggedMessage );
169 169
 			glsr_log()->warning( $this->request );
170 170
 		}
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function validateAkismet()
177 177
 	{
178
-		if( !empty( $this->error ))return;
179
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
178
+		if( !empty($this->error) )return;
179
+		if( !glsr( Akismet::class )->isSpam( $this->request ) )return;
180 180
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' );
181 181
 		$this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' );
182 182
 	}
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	protected function validateBlacklist()
188 188
 	{
189
-		if( !empty( $this->error ))return;
190
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
189
+		if( !empty($this->error) )return;
190
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return;
191 191
 		$blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
192 192
 		if( $blacklistAction == 'reject' ) {
193 193
 			$this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	protected function validateCustom()
204 204
 	{
205
-		if( !empty( $this->error ))return;
205
+		if( !empty($this->error) )return;
206 206
 		$validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
207 207
 		if( $validated === true )return;
208 208
 		$this->setSessionValues( 'errors', [] );
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	protected function validateHoneyPot()
219 219
 	{
220
-		if( !empty( $this->error ))return;
221
-		if( empty( $this->request['gotcha'] ))return;
220
+		if( !empty($this->error) )return;
221
+		if( empty($this->request['gotcha']) )return;
222 222
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
223 223
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
224 224
 	}
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	protected function validateRecaptcha()
230 230
 	{
231
-		if( !empty( $this->error ))return;
231
+		if( !empty($this->error) )return;
232 232
 		$status = $this->getRecaptchaStatus();
233
-		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return;
233
+		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return;
234 234
 		if( $status == static::RECAPTCHA_EMPTY ) {
235 235
 			$this->setSessionValues( 'recaptcha', 'unset' );
236 236
 			$this->recaptchaIsUnset = true;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	protected function validateRequest( array $request )
252 252
 	{
253
-		if( !$this->isRequestValid( $request )) {
253
+		if( !$this->isRequestValid( $request ) ) {
254 254
 			$this->error = __( 'Please fix the submission errors.', 'site-reviews' );
255 255
 			return $request;
256 256
 		}
Please login to merge, or discard this patch.
plugin/Helper.php 1 patch
Spacing   +24 added lines, -24 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;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				Whip::IPV4 => $cloudflareIps['v4'],
196 196
 				Whip::IPV6 => $ipv6,
197 197
 			],
198
-		]))->getValidIpAddress();
198
+		] ))->getValidIpAddress();
199 199
 	}
200 200
 
201 201
 	/**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	{
209 209
 		$keys = explode( '.', $path );
210 210
 		foreach( $keys as $key ) {
211
-			if( !isset( $values[$key] )) {
211
+			if( !isset($values[$key]) ) {
212 212
 				return $fallback;
213 213
 			}
214 214
 			$values = $values[$key];
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public function insertInArray( array $array, array $insert, $key, $position = 'before' )
225 225
 	{
226
-		$keyPosition = intval( array_search( $key, array_keys( $array )));
226
+		$keyPosition = intval( array_search( $key, array_keys( $array ) ) );
227 227
 		if( 'after' == $position ) {
228 228
 			$keyPosition++;
229 229
 		}
230 230
 		if( false !== $keyPosition ) {
231 231
 			$result = array_slice( $array, 0, $keyPosition );
232 232
 			$result = array_merge( $result, $insert );
233
-			return array_merge( $result, array_slice( $array, $keyPosition ));
233
+			return array_merge( $result, array_slice( $array, $keyPosition ) );
234 234
 		}
235 235
 		return array_merge( $array, $insert );
236 236
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function isIndexedArray( $array )
243 243
 	{
244
-		if( !is_array( $array )) {
244
+		if( !is_array( $array ) ) {
245 245
 			return false;
246 246
 		}
247 247
 		$current = 0;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function isIndexedFlatArray( $array )
262 262
 	{
263
-		if( !is_array( $array ) || array_filter( $array, 'is_array' )) {
263
+		if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
264 264
 			return false;
265 265
 		}
266 266
 		return $this->isIndexedArray( $array );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	public function prefixString( $string, $prefix = '' )
275 275
 	{
276
-		return $prefix.str_replace( $prefix, '', trim( $string ));
276
+		return $prefix.str_replace( $prefix, '', trim( $string ) );
277 277
 	}
278 278
 
279 279
 	/**
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	public function removePrefix( $prefix, $text )
300 300
 	{
301 301
 		return 0 === strpos( $text, $prefix )
302
-			? substr( $text, strlen( $prefix ))
302
+			? substr( $text, strlen( $prefix ) )
303 303
 			: $text;
304 304
 	}
305 305
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	public function snakeCase( $string )
332 332
 	{
333
-		if( !ctype_lower( $string )) {
333
+		if( !ctype_lower( $string ) ) {
334 334
 			$string = preg_replace( '/\s+/u', '', $string );
335 335
 			$string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
336 336
 			$string = function_exists( 'mb_strtolower' )
@@ -347,6 +347,6 @@  discard block
 block discarded – undo
347 347
 	 */
348 348
 	public function startsWith( $needle, $haystack )
349 349
 	{
350
-		return substr( $haystack, 0, strlen( $needle )) === $needle;
350
+		return substr( $haystack, 0, strlen( $needle ) ) === $needle;
351 351
 	}
352 352
 }
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	public function __construct()
34 34
 	{
35 35
 		static::$instance = $this;
36
-		$this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' );
36
+		$this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' );
37 37
 		$plugin = get_file_data( $this->file, [
38 38
 			'languages' => 'Domain Path',
39 39
 			'name' => 'Plugin Name',
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		$constant = 'static::'.$property;
87 87
 		return defined( $constant )
88
-			? apply_filters( 'site-reviews/const/'.$property, constant( $constant ))
88
+			? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
89 89
 			: '';
90 90
 	}
91 91
 
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function file( $view )
105 105
 	{
106
-		$view.= '.php';
106
+		$view .= '.php';
107 107
 		$filePaths = [];
108
-		if( glsr( Helper::class )->startsWith( 'templates/', $view )) {
109
-			$filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ));
108
+		if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) {
109
+			$filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) );
110 110
 		}
111 111
 		$filePaths[] = $this->path( $view );
112 112
 		$filePaths[] = $this->path( 'views/'.$view );
113 113
 		foreach( $filePaths as $file ) {
114
-			if( !file_exists( $file ))continue;
114
+			if( !file_exists( $file ) )continue;
115 115
 			return $file;
116 116
 		}
117 117
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function getDefaults()
123 123
 	{
124
-		if( empty( $this->defaults )) {
124
+		if( empty($this->defaults) ) {
125 125
 			$this->defaults = $this->make( DefaultsManager::class )->get();
126 126
 			$this->upgrade();
127 127
 		}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	public function hasPermission()
135 135
 	{
136 136
 		$isAdmin = $this->isAdmin();
137
-		return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' )));
137
+		return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) ));
138 138
 	}
139 139
 
140 140
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$types = apply_filters( 'site-reviews/addon/types', [] );
191 191
 		$this->reviewTypes = wp_parse_args( $types, [
192 192
 			'local' => __( 'Local', 'site-reviews' ),
193
-		]);
193
+		] );
194 194
 	}
195 195
 
196 196
 	/**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	{
202 202
 		$view = apply_filters( 'site-reviews/render/view', $view, $data );
203 203
 		$file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
204
-		if( !file_exists( $file )) {
204
+		if( !file_exists( $file ) ) {
205 205
 			glsr_log()->error( 'File not found: '.$file );
206 206
 			return;
207 207
 		}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function scheduleCronJob()
217 217
 	{
218
-		if( wp_next_scheduled( static::CRON_EVENT ))return;
218
+		if( wp_next_scheduled( static::CRON_EVENT ) )return;
219 219
 		wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
220 220
 	}
221 221
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	public function unscheduleCronJob()
235 235
 	{
236
-		wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT );
236
+		wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
237 237
 	}
238 238
 
239 239
 	/**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	public function url( $path = '' )
267 267
 	{
268
-		$url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ));
268
+		$url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
269 269
 		return apply_filters( 'site-reviews/url', $url, $path );
270 270
 	}
271 271
 }
Please login to merge, or discard this patch.
plugin/Modules/Style.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 			'templates/form/submit-button',
51 51
 			'templates/reviews-form',
52 52
 		];
53
-		if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) {
53
+		if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) {
54 54
 			return $view;
55 55
 		}
56 56
 		$views = $this->generatePossibleViews( $view );
57 57
 		foreach( $views as $possibleView ) {
58
-			if( !file_exists( glsr()->file( $possibleView )))continue;
58
+			if( !file_exists( glsr()->file( $possibleView ) ) )continue;
59 59
 			return glsr( Helper::class )->removePrefix( 'views/', $possibleView );
60 60
 		}
61 61
 		return $view;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function modifyField( Builder $instance )
90 90
 	{
91
-		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return;
91
+		if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return;
92 92
 		call_user_func_array( [$this, 'customize'], [&$instance] );
93 93
 	}
94 94
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function customize( Builder $instance )
107 107
 	{
108
-		if( !array_key_exists( $instance->tag, $this->fields ))return;
109
-		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ));
108
+		if( !array_key_exists( $instance->tag, $this->fields ) )return;
109
+		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) );
110 110
 		$key = $instance->tag.'_'.$args['type'];
111
-		$classes = !isset( $this->fields[$key] )
111
+		$classes = !isset($this->fields[$key])
112 112
 			? $this->fields[$instance->tag]
113 113
 			: $this->fields[$key];
114 114
 		$instance->args['class'] = trim( $args['class'].' '.$classes );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$args = wp_parse_args( $instance->args, [
143 143
 			'is_public' => false,
144 144
 			'is_raw' => false,
145
-		]);
145
+		] );
146 146
 		if( is_admin() || !$args['is_public'] || $args['is_raw'] ) {
147 147
 			return false;
148 148
 		}
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 		}
56 56
 		$views = $this->generatePossibleViews( $view );
57 57
 		foreach( $views as $possibleView ) {
58
-			if( !file_exists( glsr()->file( $possibleView )))continue;
58
+			if( !file_exists( glsr()->file( $possibleView ))) {
59
+				continue;
60
+			}
59 61
 			return glsr( Helper::class )->removePrefix( 'views/', $possibleView );
60 62
 		}
61 63
 		return $view;
@@ -88,7 +90,9 @@  discard block
 block discarded – undo
88 90
 	 */
89 91
 	public function modifyField( Builder $instance )
90 92
 	{
91
-		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return;
93
+		if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) {
94
+			return;
95
+		}
92 96
 		call_user_func_array( [$this, 'customize'], [&$instance] );
93 97
 	}
94 98
 
@@ -105,7 +109,9 @@  discard block
 block discarded – undo
105 109
 	 */
106 110
 	protected function customize( Builder $instance )
107 111
 	{
108
-		if( !array_key_exists( $instance->tag, $this->fields ))return;
112
+		if( !array_key_exists( $instance->tag, $this->fields )) {
113
+			return;
114
+		}
109 115
 		$args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ));
110 116
 		$key = $instance->tag.'_'.$args['type'];
111 117
 		$classes = !isset( $this->fields[$key] )
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function enqueueAssets()
26 26
 	{
27
-		$command = new EnqueueAdminAssets([
27
+		$command = new EnqueueAdminAssets( [
28 28
 			'pointers' => [[
29 29
 				'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
30 30
 				'id' => 'glsr-pointer-pinned',
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				'target' => '#misc-pub-pinned',
37 37
 				'title' => __( 'Pin Your Reviews', 'site-reviews' ),
38 38
 			]],
39
-		]);
39
+		] );
40 40
 		$this->execute( $command );
41 41
 	}
42 42
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	{
49 49
 		$links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
50 50
 			'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
51
-		]);
51
+		] );
52 52
 		return $links;
53 53
 	}
54 54
 
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 	public function filterDashboardGlanceItems( $items )
61 61
 	{
62 62
 		$postCount = wp_count_posts( Application::POST_TYPE );
63
-		if( empty( $postCount->publish )) {
63
+		if( empty($postCount->publish) ) {
64 64
 			return $items;
65 65
 		}
66 66
 		$text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
67
-		$text = sprintf( $text, number_format_i18n( $postCount->publish ));
67
+		$text = sprintf( $text, number_format_i18n( $postCount->publish ) );
68 68
 		$items = glsr( Helper::class )->consolidateArray( $items );
69 69
 		$items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
70 70
 			? glsr( Builder::class )->a( $text, [
71 71
 				'class' => 'glsr-review-count',
72 72
 				'href' => 'edit.php?post_type='.Application::POST_TYPE,
73
-			])
73
+			] )
74 74
 			: glsr( Builder::class )->span( $text, [
75 75
 				'class' => 'glsr-review-count',
76
-			]);
76
+			] );
77 77
 		return $items;
78 78
 	}
79 79
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function filterTinymcePlugins( $plugins )
86 86
 	{
87
-		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) {
87
+		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
88 88
 			$plugins = glsr( Helper::class )->consolidateArray( $plugins );
89 89
 			$plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
90 90
 		}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function registerTinymcePopups()
99 99
 	{
100
-		$command = new RegisterTinymcePopups([
100
+		$command = new RegisterTinymcePopups( [
101 101
 			'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
102 102
 			'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
103 103
 			'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
104
-		]);
104
+		] );
105 105
 		$this->execute( $command );
106 106
 	}
107 107
 
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	public function renderTinymceButton( $editorId )
114 114
 	{
115 115
 		$allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
116
-		if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return;
116
+		if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return;
117 117
 		$shortcodes = [];
118 118
 		foreach( glsr()->mceShortcodes as $shortcode => $values ) {
119 119
 			$shortcodes[$shortcode] = $values;
120 120
 		}
121
-		if( empty( $shortcodes ))return;
121
+		if( empty($shortcodes) )return;
122 122
 		glsr()->render( 'partials/editor/tinymce', [
123 123
 			'shortcodes' => $shortcodes,
124
-		]);
124
+		] );
125 125
 	}
126 126
 
127 127
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	public function routerClearConsole()
131 131
 	{
132 132
 		glsr( Console::class )->clear();
133
-		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ));
133
+		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
134 134
 	}
135 135
 
136 136
 	/**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function routerFetchConsole()
140 140
 	{
141
-		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ));
141
+		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
142 142
 	}
143 143
 
144 144
 	/**
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		}
158 158
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
159 159
 		foreach( $postIds as $postId ) {
160
-			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ));
160
+			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) );
161 161
 		}
162 162
 		$countManager->setCounts( $countManager->buildCounts() );
163 163
 		if( $showNotice ) {
164
-			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ));
164
+			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
165 165
 		}
166
-		glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ));
166
+		glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) );
167 167
 	}
168 168
 
169 169
 	/**
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
 	{
198 198
 		$file = $_FILES['import-file'];
199 199
 		if( $file['error'] !== UPLOAD_ERR_OK ) {
200
-			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ));
200
+			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
201 201
 		}
202
-		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) {
203
-			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ));
202
+		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
203
+			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
204 204
 		}
205 205
 		$settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
206
-		if( empty( $settings )) {
207
-			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ));
206
+		if( empty($settings) ) {
207
+			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
208 208
 		}
209
-		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ));
210
-		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ));
209
+		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
210
+		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
211 211
 	}
212 212
 
213 213
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
226 226
 			UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
227 227
 		];
228
-		return !isset( $errors[$errorCode] )
228
+		return !isset($errors[$errorCode])
229 229
 			? __( 'Unknown upload error.', 'site-reviews' )
230 230
 			: $errors[$errorCode];
231 231
 	}
Please login to merge, or discard this patch.
plugin/Handlers/CreateReview.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 		$review = glsr( ReviewManager::class )->create( $command );
18 18
 		if( !$review ) {
19 19
 			glsr( Session::class )->set( $command->form_id.'errors', [] );
20
-			glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' ));
20
+			glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' ) );
21 21
 			return;
22 22
 		}
23
-		glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' ));
23
+		glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' ) );
24 24
 		glsr( Notification::class )->send( $review );
25 25
 		if( $command->ajax_request )return;
26
-		wp_safe_redirect( $this->getReferer( $command ));
26
+		wp_safe_redirect( $this->getReferer( $command ) );
27 27
 		exit;
28 28
 	}
29 29
 
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	protected function getReferer( Command $command )
34 34
 	{
35
-		$referer = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true )));
35
+		$referer = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) );
36 36
 		$referer = apply_filters( 'site-reviews/review/redirect', $referer, $command );
37
-		if( empty( $referer )) {
37
+		if( empty($referer) ) {
38 38
 			$referer = $command->referer;
39 39
 		}
40
-		if( empty( $referer )) {
40
+		if( empty($referer) ) {
41 41
 			glsr_log()->warning( 'The form referer ($_SERVER[REQUEST_URI]) was empty.' )->info( $command );
42 42
 			$referer = home_url();
43 43
 		}
Please login to merge, or discard this patch.
helpers.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 		'glsr_log',
21 21
 		'glsr_star_rating',
22 22
 	);
23
-	if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return;
24
-	add_filter( $hook, function() use( $hook, $args ) {
23
+	if( !in_array( $hook, $hooks ) || !function_exists( $hook ) )return;
24
+	add_filter( $hook, function() use($hook, $args) {
25 25
 		array_shift( $args ); // remove the fallback value
26 26
 		return call_user_func_array( $hook, $args );
27 27
 	});
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function glsr( $alias = null ) {
34 34
 	$app = \GeminiLabs\SiteReviews\Application::load();
35
-	return !empty( $alias )
35
+	return !empty($alias)
36 36
 		? $app->make( $alias )
37 37
 		: $app;
38 38
 }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	$result = array();
47 47
 	foreach( $array as $subarray ) {
48 48
 		$subarray = (array)$subarray;
49
-		if( !isset( $subarray[$column] ))continue;
49
+		if( !isset($subarray[$column]) )continue;
50 50
 		$result[] = $subarray[$column];
51 51
 	}
52 52
 	return $result;
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function glsr_calculate_ratings() {
59 59
 	glsr( 'Controllers\AdminController' )->routerCountReviews( false );
60
-	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ));
60
+	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ) );
61 61
 }
62 62
 
63 63
 /**
64 64
  * @return \GeminiLabs\SiteReviews\Review|false
65 65
  */
66 66
 function glsr_create_review( $reviewValues = array() ) {
67
-	if( !is_array( $reviewValues )) {
67
+	if( !is_array( $reviewValues ) ) {
68 68
 		$reviewValues = array();
69 69
 	}
70 70
 	$review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues );
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
  * @return \WP_Screen|object
76 76
  */
77 77
 function glsr_current_screen() {
78
-	if( function_exists( 'get_current_screen' )) {
78
+	if( function_exists( 'get_current_screen' ) ) {
79 79
 		$screen = get_current_screen();
80 80
 	}
81
-	return empty( $screen )
81
+	return empty($screen)
82 82
 		? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
83 83
 		: $screen;
84 84
 }
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
  */
126 126
 function glsr_get_review( $post_id ) {
127 127
 	$post = null;
128
-	if( is_numeric( $post_id )) {
128
+	if( is_numeric( $post_id ) ) {
129 129
 		$post = get_post( $post_id );
130 130
 	}
131
-	if( !( $post instanceof WP_Post )) {
131
+	if( !($post instanceof WP_Post) ) {
132 132
 		$post = new WP_Post( (object)[] );
133 133
 	}
134 134
 	return glsr( 'Database\ReviewManager' )->single( $post );
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
  * @return array
139 139
  */
140 140
 function glsr_get_reviews( $args = array() ) {
141
-	if( !is_array( $args )) {
141
+	if( !is_array( $args ) ) {
142 142
 		$args = [];
143 143
 	}
144 144
 	return glsr( 'Database\ReviewManager' )->get( $args );
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function glsr_log() {
151 151
 	$args = func_get_args();
152
-	$context = isset( $args[1] )
152
+	$context = isset($args[1])
153 153
 		? $args[1]
154 154
 		: [];
155 155
 	$console = glsr( 'Modules\Console' );
156
-	return !empty( $args )
156
+	return !empty($args)
157 157
 		? $console->log( 'debug', $args[0], $context )
158 158
 		: $console;
159 159
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 		'glsr_log',
21 21
 		'glsr_star_rating',
22 22
 	);
23
-	if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return;
23
+	if( !in_array( $hook, $hooks ) || !function_exists( $hook )) {
24
+		return;
25
+	}
24 26
 	add_filter( $hook, function() use( $hook, $args ) {
25 27
 		array_shift( $args ); // remove the fallback value
26 28
 		return call_user_func_array( $hook, $args );
@@ -30,7 +32,8 @@  discard block
 block discarded – undo
30 32
 /**
31 33
  * @return mixed
32 34
  */
33
-function glsr( $alias = null ) {
35
+function glsr( $alias = null )
36
+{
34 37
 	$app = \GeminiLabs\SiteReviews\Application::load();
35 38
 	return !empty( $alias )
36 39
 		? $app->make( $alias )
@@ -42,11 +45,14 @@  discard block
 block discarded – undo
42 45
  * @param $column string
43 46
  * @return array
44 47
  */
45
-function glsr_array_column( array $array, $column ) {
48
+function glsr_array_column( array $array, $column )
49
+{
46 50
 	$result = array();
47 51
 	foreach( $array as $subarray ) {
48 52
 		$subarray = (array)$subarray;
49
-		if( !isset( $subarray[$column] ))continue;
53
+		if( !isset( $subarray[$column] )) {
54
+			continue;
55
+		}
50 56
 		$result[] = $subarray[$column];
51 57
 	}
52 58
 	return $result;
@@ -55,7 +61,8 @@  discard block
 block discarded – undo
55 61
 /**
56 62
  * @return void
57 63
  */
58
-function glsr_calculate_ratings() {
64
+function glsr_calculate_ratings()
65
+{
59 66
 	glsr( 'Controllers\AdminController' )->routerCountReviews( false );
60 67
 	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ));
61 68
 }
@@ -63,7 +70,8 @@  discard block
 block discarded – undo
63 70
 /**
64 71
  * @return \GeminiLabs\SiteReviews\Review|false
65 72
  */
66
-function glsr_create_review( $reviewValues = array() ) {
73
+function glsr_create_review( $reviewValues = array() )
74
+{
67 75
 	if( !is_array( $reviewValues )) {
68 76
 		$reviewValues = array();
69 77
 	}
@@ -74,7 +82,8 @@  discard block
 block discarded – undo
74 82
 /**
75 83
  * @return \WP_Screen|object
76 84
  */
77
-function glsr_current_screen() {
85
+function glsr_current_screen()
86
+{
78 87
 	if( function_exists( 'get_current_screen' )) {
79 88
 		$screen = get_current_screen();
80 89
 	}
@@ -87,7 +96,8 @@  discard block
 block discarded – undo
87 96
  * @param mixed ...$vars
88 97
  * @return void
89 98
  */
90
-function glsr_debug( ...$vars ) {
99
+function glsr_debug( ...$vars )
100
+{
91 101
 	if( count( $vars ) == 1 ) {
92 102
 		$value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
93 103
 		printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
@@ -106,7 +116,8 @@  discard block
 block discarded – undo
106 116
  * @param mixed $fallback
107 117
  * @return string|array
108 118
  */
109
-function glsr_get_option( $path = '', $fallback = '' ) {
119
+function glsr_get_option( $path = '', $fallback = '' )
120
+{
110 121
 	return is_string( $path )
111 122
 		? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback )
112 123
 		: $fallback;
@@ -115,7 +126,8 @@  discard block
 block discarded – undo
115 126
 /**
116 127
  * @return array
117 128
  */
118
-function glsr_get_options() {
129
+function glsr_get_options()
130
+{
119 131
 	return glsr( 'Database\OptionManager' )->get( 'settings' );
120 132
 }
121 133
 
@@ -123,7 +135,8 @@  discard block
 block discarded – undo
123 135
  * @param int $post_id
124 136
  * @return \GeminiLabs\SiteReviews\Review
125 137
  */
126
-function glsr_get_review( $post_id ) {
138
+function glsr_get_review( $post_id )
139
+{
127 140
 	$post = null;
128 141
 	if( is_numeric( $post_id )) {
129 142
 		$post = get_post( $post_id );
@@ -137,7 +150,8 @@  discard block
 block discarded – undo
137 150
 /**
138 151
  * @return array
139 152
  */
140
-function glsr_get_reviews( $args = array() ) {
153
+function glsr_get_reviews( $args = array() )
154
+{
141 155
 	if( !is_array( $args )) {
142 156
 		$args = [];
143 157
 	}
@@ -147,7 +161,8 @@  discard block
 block discarded – undo
147 161
 /**
148 162
  * @return \GeminiLabs\SiteReviews\Modules\Console
149 163
  */
150
-function glsr_log() {
164
+function glsr_log()
165
+{
151 166
 	$args = func_get_args();
152 167
 	$context = isset( $args[1] )
153 168
 		? $args[1]
@@ -161,6 +176,7 @@  discard block
 block discarded – undo
161 176
 /**
162 177
  * @return string
163 178
  */
164
-function glsr_star_rating( $rating ) {
179
+function glsr_star_rating( $rating )
180
+{
165 181
 	return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] );
166 182
 }
Please login to merge, or discard this patch.
plugin/Modules/Translation.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$translations = $this->translations();
32 32
 		$entries = $this->filter( $translations, $this->entries() )->results();
33
-		array_walk( $translations, function( &$entry ) use( $entries ) {
33
+		array_walk( $translations, function( &$entry ) use($entries) {
34 34
 			$entry['desc'] = array_key_exists( $entry['id'], $entries )
35 35
 				? $this->getEntryString( $entries[$entry['id']], 'msgctxt' )
36 36
 				: '';
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function entries()
45 45
 	{
46
-		if( !isset( $this->entries )) {
46
+		if( !isset($this->entries) ) {
47 47
 			$potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' );
48 48
 			$entries = $this->extractEntriesFromPotFile( $potFile );
49 49
 			$entries = apply_filters( 'site-reviews/translation/entries', $entries );
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function filter( $filterWith = null, $entries = null, $intersect = true )
90 90
 	{
91
-		if( !is_array( $entries )) {
91
+		if( !is_array( $entries ) ) {
92 92
 			$entries = $this->results;
93 93
 		}
94
-		if( !is_array( $filterWith )) {
94
+		if( !is_array( $filterWith ) ) {
95 95
 			$filterWith = $this->translations();
96 96
 		}
97
-		$keys = array_flip( glsr_array_column( $filterWith, 'id' ));
97
+		$keys = array_flip( glsr_array_column( $filterWith, 'id' ) );
98 98
 		$this->results = $intersect
99 99
 			? array_intersect_key( $entries, $keys )
100 100
 			: array_diff_key( $entries, $keys );
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 	public function render( $template, array $entry )
109 109
 	{
110 110
 		$data = array_combine(
111
-			array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )),
111
+			array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ),
112 112
 			$entry
113 113
 		);
114 114
 		$data['data.class'] = $data['data.error'] = '';
115
-		if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' )) === false ) {
115
+		if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' ) ) === false ) {
116 116
 			$data['data.class'] = 'is-invalid';
117 117
 			$data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' );
118 118
 		}
119 119
 		return glsr( Template::class )->build( 'partials/translations/'.$template, [
120 120
 			'context' => $data,
121
-		]);
121
+		] );
122 122
 	}
123 123
 
124 124
 	/**
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 				'p1' => $this->getEntryString( $entry, 'msgid_plural' ),
151 151
 				's1' => $this->getEntryString( $entry, 'msgid' ),
152 152
 			];
153
-			$text = !empty( $data['p1'] )
153
+			$text = !empty($data['p1'])
154 154
 				? sprintf( '%s | %s', $data['s1'], $data['p1'] )
155 155
 				: $data['s1'];
156 156
 			$rendered .= $this->render( 'result', [
157
-				'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ),
157
+				'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ),
158 158
 				'text' => wp_strip_all_tags( $text ),
159
-			]);
159
+			] );
160 160
 		}
161 161
 		if( $resetAfterRender ) {
162 162
 			$this->reset();
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 	public function search( $needle = '' )
190 190
 	{
191 191
 		$this->reset();
192
-		$needle = trim( strtolower( $needle ));
192
+		$needle = trim( strtolower( $needle ) );
193 193
 		foreach( $this->entries() as $key => $entry ) {
194
-			$single = strtolower( $this->getEntryString( $entry, 'msgid' ));
195
-			$plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ));
194
+			$single = strtolower( $this->getEntryString( $entry, 'msgid' ) );
195
+			$plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) );
196 196
 			if( strlen( $needle ) < static::SEARCH_THRESHOLD ) {
197
-				if( in_array( $needle, [$single, $plural] )) {
197
+				if( in_array( $needle, [$single, $plural] ) ) {
198 198
 					$this->results[$key] = $entry;
199 199
 				}
200 200
 			}
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	public function translations()
213 213
 	{
214 214
 		static $translations;
215
-		if( empty( $translations )) {
215
+		if( empty($translations) ) {
216 216
 			$settings = glsr( OptionManager::class )->get( 'settings' );
217
-			$translations = isset( $settings['strings'] )
218
-				? $this->normalizeSettings( (array) $settings['strings'] )
217
+			$translations = isset($settings['strings'])
218
+				? $this->normalizeSettings( (array)$settings['strings'] )
219 219
 				: [];
220 220
 		}
221 221
 		return $translations;
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	protected function getEntryString( array $entry, $key )
229 229
 	{
230
-		return isset( $entry[$key] )
231
-			? implode( '', (array) $entry[$key] )
230
+		return isset($entry[$key])
231
+			? implode( '', (array)$entry[$key] )
232 232
 			: '';
233 233
 	}
234 234
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 		$keys = [
241 241
 			'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]',
242 242
 		];
243
-		array_walk( $entries, function( &$entry ) use( $keys ) {
243
+		array_walk( $entries, function( &$entry ) use($keys) {
244 244
 			foreach( $keys as $key ) {
245
-				if( is_array( $entry )) {
245
+				if( is_array( $entry ) ) {
246 246
 					$entry = $this->normalizeEntryString( $entry, $key );
247 247
 					continue;
248 248
 				}
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	protected function normalizeEntryString( array $entry, $key )
260 260
 	{
261
-		if( isset( $entry[$key] )) {
261
+		if( isset($entry[$key]) ) {
262 262
 			$entry[$key] = $this->getEntryString( $entry, $key );
263 263
 		}
264 264
 		return $entry;
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		$defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' );
273 273
 		$strings = array_filter( $strings, 'is_array' );
274 274
 		foreach( $strings as &$string ) {
275
-			$string['type'] = isset( $string['p1'] ) ? 'plural' : 'single';
275
+			$string['type'] = isset($string['p1']) ? 'plural' : 'single';
276 276
 			$string = wp_parse_args( $string, $defaultString );
277 277
 		}
278 278
 		return array_filter( $strings, function( $string ) {
279
-			return !empty( $string['id'] );
279
+			return !empty($string['id']);
280 280
 		});
281 281
 	}
282 282
 }
Please login to merge, or discard this patch.
plugin/Modules/Console.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function get()
112 112
 	{
113
-		return empty( $this->log )
113
+		return empty($this->log)
114 114
 			? __( 'Console is empty', 'site-reviews' )
115 115
 			: $this->log;
116 116
 	}
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	public function humanSize( $valueIfEmpty = null )
123 123
 	{
124 124
 		$bytes = $this->size();
125
-		if( empty( $bytes ) && is_string( $valueIfEmpty )) {
125
+		if( empty($bytes) && is_string( $valueIfEmpty ) ) {
126 126
 			return $valueIfEmpty;
127 127
 		}
128
-		$exponent = floor( log( max( $bytes, 1 ), 1024 ));
129
-		return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes','KB','MB','GB'][$exponent];
128
+		$exponent = floor( log( max( $bytes, 1 ), 1024 ) );
129
+		return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent];
130 130
 	}
131 131
 
132 132
 	/**
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 	public function log( $level, $message, array $context = [] )
150 150
 	{
151 151
 		$constants = (new ReflectionClass( __CLASS__ ))->getConstants();
152
-		if( in_array( $level, $constants, true )) {
152
+		if( in_array( $level, $constants, true ) ) {
153 153
 			$entry = $this->buildLogEntry( $level, $message, $context );
154
-			file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX );
154
+			file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX );
155 155
 			$this->reset();
156 156
 		}
157 157
 		return $this;
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	public function logOnce()
164 164
 	{
165 165
 		$single = glsr( Session::class )->get( 'glsr_log_once', null, true );
166
-		if( !is_array( $single ))return;
166
+		if( !is_array( $single ) )return;
167 167
 		foreach( $single as $message => $debug ) {
168
-			if( !empty( $debug )) {
169
-				$message.= PHP_EOL.print_r( $debug, 1 );
168
+			if( !empty($debug) ) {
169
+				$message .= PHP_EOL.print_r( $debug, 1 );
170 170
 			}
171 171
 			$this->log( static::RECURRING, $message );
172 172
 		}
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	public function once( $message, $debug = '' )
192 192
 	{
193 193
 		$once = glsr( Session::class )->get( 'glsr_log_once', [] );
194
-		if( !is_array( $once )) {
194
+		if( !is_array( $once ) ) {
195 195
 			$once = [];
196 196
 		}
197
-		if( !isset( $once[$message] )) {
197
+		if( !isset($once[$message]) ) {
198 198
 			$once[$message] = $debug;
199 199
 			glsr( Session::class )->set( 'glsr_log_once', $once );
200 200
 		}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	protected function interpolate( $message, $context = [] )
258 258
 	{
259
-		if( $this->isObjectOrArray( $message ) || !is_array( $context )) {
259
+		if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) {
260 260
 			return print_r( $message, true );
261 261
 		}
262 262
 		$replace = [];
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 		if( $value instanceof DateTime ) {
285 285
 			$value = $value->format( 'Y-m-d H:i:s' );
286 286
 		}
287
-		else if( $this->isObjectOrArray( $value )) {
287
+		else if( $this->isObjectOrArray( $value ) ) {
288 288
 			$value = json_encode( $value );
289 289
 		}
290 290
 		return (string)$value;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$this->clear();
300 300
 			file_put_contents(
301 301
 				$this->file,
302
-				$this->buildLogEntry( 'info', __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' ))
302
+				$this->buildLogEntry( 'info', __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' ) )
303 303
 			);
304 304
 		}
305 305
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,9 @@
 block discarded – undo
163 163
 	public function logOnce()
164 164
 	{
165 165
 		$single = glsr( Session::class )->get( 'glsr_log_once', null, true );
166
-		if( !is_array( $single ))return;
166
+		if( !is_array( $single )) {
167
+			return;
168
+		}
167 169
 		foreach( $single as $message => $debug ) {
168 170
 			if( !empty( $debug )) {
169 171
 				$message.= PHP_EOL.print_r( $debug, 1 );
Please login to merge, or discard this patch.