Test Failed
Push — hotfix/fix-counts ( 1fe4ce...872cd6 )
by Paul
03:14
created
helpers.php 1 patch
Spacing   +12 added lines, -12 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,7 +57,7 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function glsr_calculate_ratings() {
59 59
 	glsr( 'Controllers\AdminController' )->routerCountReviews( false );
60
-	glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ));
60
+	glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) );
61 61
 }
62 62
 
63 63
 /**
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @return \WP_Screen|object
75 75
  */
76 76
 function glsr_current_screen() {
77
-	if( function_exists( 'get_current_screen' )) {
77
+	if( function_exists( 'get_current_screen' ) ) {
78 78
 		$screen = get_current_screen();
79 79
 	}
80
-	return empty( $screen )
80
+	return empty($screen)
81 81
 		? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
82 82
 		: $screen;
83 83
 }
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
  */
135 135
 function glsr_get_review( $post_id ) {
136 136
 	$post = null;
137
-	if( is_numeric( $post_id )) {
137
+	if( is_numeric( $post_id ) ) {
138 138
 		$post = get_post( $post_id );
139 139
 	}
140
-	if( !( $post instanceof WP_Post )) {
140
+	if( !($post instanceof WP_Post) ) {
141 141
 		$post = new WP_Post( (object)[] );
142 142
 	}
143 143
 	return glsr( 'Database\ReviewManager' )->single( $post );
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
  * @return array
148 148
  */
149 149
 function glsr_get_reviews( $args = array() ) {
150
-	return glsr( 'Database\ReviewManager' )->get( glsr( 'Helper' )->consolidateArray( $args ));
150
+	return glsr( 'Database\ReviewManager' )->get( glsr( 'Helper' )->consolidateArray( $args ) );
151 151
 }
152 152
 
153 153
 /**
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	$args = func_get_args();
158 158
 	$console = glsr( 'Modules\Console' );
159 159
 	$value = glsr( 'Helper' )->dataGet( $args, '0' );
160
-	return !empty( $value )
161
-		? $console->log( 'debug', $value, glsr( 'Helper' )->dataGet( $args, '1', [] ))
160
+	return !empty($value)
161
+		? $console->log( 'debug', $value, glsr( 'Helper' )->dataGet( $args, '1', [] ) )
162 162
 		: $console;
163 163
 }
164 164
 
Please login to merge, or discard this patch.
plugin/Commands/CreateReview.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
 	public function __construct( $input )
31 31
 	{
32 32
 		$this->request = $input;
33
-		$this->ajax_request = isset( $input['_ajax_request'] );
33
+		$this->ajax_request = isset($input['_ajax_request']);
34 34
 		$this->assigned_to = $this->getNumeric( 'assign_to' );
35
-		$this->author = sanitize_text_field( $this->getUser( 'name' ));
35
+		$this->author = sanitize_text_field( $this->getUser( 'name' ) );
36 36
 		$this->avatar = $this->getAvatar();
37
-		$this->blacklisted = isset( $input['blacklisted'] );
38
-		$this->category = sanitize_key( $this->get( 'category' ));
39
-		$this->content = sanitize_textarea_field( $this->get( 'content' ));
37
+		$this->blacklisted = isset($input['blacklisted']);
38
+		$this->category = sanitize_key( $this->get( 'category' ) );
39
+		$this->content = sanitize_textarea_field( $this->get( 'content' ) );
40 40
 		$this->custom = $this->getCustom();
41 41
 		$this->date = $this->getDate( 'date' );
42
-		$this->email = sanitize_email( $this->getUser( 'email' ));
43
-		$this->form_id = sanitize_key( $this->get( 'form_id' ));
42
+		$this->email = sanitize_email( $this->getUser( 'email' ) );
43
+		$this->form_id = sanitize_key( $this->get( 'form_id' ) );
44 44
 		$this->ip_address = $this->get( 'ip_address' );
45
-		$this->post_id = intval( $this->get( '_post_id' ));
46
-		$this->rating = intval( $this->get( 'rating' ));
45
+		$this->post_id = intval( $this->get( '_post_id' ) );
46
+		$this->rating = intval( $this->get( 'rating' ) );
47 47
 		$this->referer = $this->get( '_referer' );
48
-		$this->response = sanitize_textarea_field( $this->get( 'response' ));
49
-		$this->terms = !empty( $input['terms'] );
50
-		$this->title = sanitize_text_field( $this->get( 'title' ));
51
-		$this->url = esc_url_raw( $this->get( 'url' ));
48
+		$this->response = sanitize_textarea_field( $this->get( 'response' ) );
49
+		$this->terms = !empty($input['terms']);
50
+		$this->title = sanitize_text_field( $this->get( 'title' ) );
51
+		$this->url = esc_url_raw( $this->get( 'url' ) );
52 52
 	}
53 53
 
54 54
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		$avatar = $this->get( 'avatar' );
69 69
 		return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED )
70
-			? (string)get_avatar_url( $this->get( 'email' ))
70
+			? (string)get_avatar_url( $this->get( 'email' ) )
71 71
 			: $avatar;
72 72
 	}
73 73
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset );
85 85
 		$custom = $this->request;
86 86
 		foreach( $unset as $value ) {
87
-			unset( $custom[$value] );
87
+			unset($custom[$value]);
88 88
 		}
89 89
 		return $custom;
90 90
 	}
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	protected function getDate( $key )
97 97
 	{
98
-		$date = strtotime( $this->get( $key ));
98
+		$date = strtotime( $this->get( $key ) );
99 99
 		if( $date === false ) {
100 100
 			$date = time();
101 101
 		}
102
-		return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ));
102
+		return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) );
103 103
 	}
104 104
 
105 105
 	/**
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 	protected function getUser( $key )
110 110
 	{
111 111
 		$value = $this->get( $key );
112
-		if( empty( $value )) {
112
+		if( empty($value) ) {
113 113
 			$user = wp_get_current_user();
114 114
 			$userValues = [
115 115
 				'email' => 'user_email',
116 116
 				'name' => 'display_name',
117 117
 			];
118
-			if( $user->exists() && array_key_exists( $key, $userValues )) {
118
+			if( $user->exists() && array_key_exists( $key, $userValues ) ) {
119 119
 				return $user->{$userValues[$key]};
120 120
 			}
121 121
 		}
Please login to merge, or discard this patch.
plugin/Modules/Schema/BaseType.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __call( $method, array $arguments )
41 41
 	{
42
-		return $this->setProperty( $method, glsr_get( $arguments, 0 ));
42
+		return $this->setProperty( $method, glsr_get( $arguments, 0 ) );
43 43
 	}
44 44
 
45 45
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param mixed $default
94 94
 	 * @return mixed
95 95
 	 */
96
-	public function getProperty( $property, $default = null)
96
+	public function getProperty( $property, $default = null )
97 97
 	{
98 98
 		return glsr_get( $this->properties, $property, $default );
99 99
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public function offsetUnset( $offset )
163 163
 	{
164
-		unset( $this->properties[$offset] );
164
+		unset($this->properties[$offset]);
165 165
 	}
166 166
 
167 167
 	/**
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function getParents( $parents = null )
209 209
 	{
210
-		if( !isset( $parents )) {
210
+		if( !isset($parents) ) {
211 211
 			$parents = $this->parents;
212 212
 		}
213 213
 		$newParents = $parents;
214 214
 		foreach( $parents as $parent ) {
215 215
 			$parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ );
216
-			if( !class_exists( $parentClass ))continue;
217
-			$newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ));
216
+			if( !class_exists( $parentClass ) )continue;
217
+			$newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ) );
218 218
 		}
219
-		return array_values( array_unique( $newParents ));
219
+		return array_values( array_unique( $newParents ) );
220 220
 	}
221 221
 
222 222
 	/**
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 		$parents = $this->getParents();
228 228
 		foreach( $parents as $parent ) {
229 229
 			$parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ );
230
-			if( !class_exists( $parentClass ))continue;
231
-			$this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed )));
230
+			if( !class_exists( $parentClass ) )continue;
231
+			$this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ) ) );
232 232
 		}
233 233
 	}
234 234
 
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	protected function serializeProperty( $property )
240 240
 	{
241
-		if( is_array( $property )) {
241
+		if( is_array( $property ) ) {
242 242
 			return array_map( [$this, 'serializeProperty'], $property );
243 243
 		}
244 244
 		if( $property instanceof Type ) {
245 245
 			$property = $property->toArray();
246
-			unset( $property['@context'] );
246
+			unset($property['@context']);
247 247
 		}
248 248
 		if( $property instanceof DateTimeInterface ) {
249 249
 			$property = $property->format( DateTime::ATOM );
250 250
 		}
251
-		if( is_object( $property )) {
251
+		if( is_object( $property ) ) {
252 252
 			throw new InvalidProperty();
253 253
 		}
254 254
 		return $property;
Please login to merge, or discard this patch.
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,10 +132,10 @@  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 = explode( ',', glsr_get( $request, 'excluded' ));
138
-		return array_diff_key( $rules, array_flip( $excluded ));
137
+		$excluded = explode( ',', glsr_get( $request, 'excluded' ) );
138
+		return array_diff_key( $rules, array_flip( $excluded ) );
139 139
 	}
140 140
 
141 141
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	{
146 146
 		$rules = $this->getValidationRules( $request );
147 147
 		$errors = glsr( Validator::class )->validate( $request, $rules );
148
-		if( empty( $errors )) {
148
+		if( empty($errors) ) {
149 149
 			return true;
150 150
 		}
151 151
 		$this->setSessionValues( 'errors', $errors );
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	protected function setSessionValues( $type, $value, $loggedMessage = '' )
163 163
 	{
164 164
 		glsr( Session::class )->set( $this->form_id.$type, $value );
165
-		if( !empty( $loggedMessage )) {
165
+		if( !empty($loggedMessage) ) {
166 166
 			glsr_log()->warning( $loggedMessage )->debug( $this->request );
167 167
 		}
168 168
 	}
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	protected function validateAkismet()
174 174
 	{
175
-		if( !empty( $this->error ))return;
176
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
175
+		if( !empty($this->error) )return;
176
+		if( !glsr( Akismet::class )->isSpam( $this->request ) )return;
177 177
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' );
178 178
 		$this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' );
179 179
 	}
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	protected function validateBlacklist()
185 185
 	{
186
-		if( !empty( $this->error ))return;
187
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
186
+		if( !empty($this->error) )return;
187
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return;
188 188
 		$blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
189 189
 		if( $blacklistAction == 'reject' ) {
190 190
 			$this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' );
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	protected function validateCustom()
201 201
 	{
202
-		if( !empty( $this->error ))return;
202
+		if( !empty($this->error) )return;
203 203
 		$validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
204 204
 		if( $validated === true )return;
205 205
 		$this->setSessionValues( 'errors', [] );
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function validateHoneyPot()
216 216
 	{
217
-		if( !empty( $this->error ))return;
218
-		if( empty( $this->request['gotcha'] ))return;
217
+		if( !empty($this->error) )return;
218
+		if( empty($this->request['gotcha']) )return;
219 219
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
220 220
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
221 221
 	}
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	protected function validateRecaptcha()
227 227
 	{
228
-		if( !empty( $this->error ))return;
228
+		if( !empty($this->error) )return;
229 229
 		$status = $this->getRecaptchaStatus();
230
-		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return;
230
+		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return;
231 231
 		if( $status == static::RECAPTCHA_EMPTY ) {
232 232
 			$this->setSessionValues( 'recaptcha', 'unset' );
233 233
 			$this->recaptchaIsUnset = true;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	protected function validateRequest( array $request )
249 249
 	{
250
-		if( !$this->isRequestValid( $request )) {
250
+		if( !$this->isRequestValid( $request ) ) {
251 251
 			$this->error = __( 'Please fix the submission errors.', 'site-reviews' );
252 252
 			return $request;
253 253
 		}
Please login to merge, or discard this patch.
plugin/Modules/Translation.php 1 patch
Spacing   +24 added lines, -24 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,7 +240,7 @@  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 245
 				try {
246 246
 					$entry = $this->normalizeEntryString( $entry, $key );
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	protected function normalizeEntryString( array $entry, $key )
262 262
 	{
263
-		if( isset( $entry[$key] )) {
263
+		if( isset($entry[$key]) ) {
264 264
 			$entry[$key] = $this->getEntryString( $entry, $key );
265 265
 		}
266 266
 		return $entry;
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 		$defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' );
275 275
 		$strings = array_filter( $strings, 'is_array' );
276 276
 		foreach( $strings as &$string ) {
277
-			$string['type'] = isset( $string['p1'] ) ? 'plural' : 'single';
277
+			$string['type'] = isset($string['p1']) ? 'plural' : 'single';
278 278
 			$string = wp_parse_args( $string, $defaultString );
279 279
 		}
280 280
 		return array_filter( $strings, function( $string ) {
281
-			return !empty( $string['id'] );
281
+			return !empty($string['id']);
282 282
 		});
283 283
 	}
284 284
 }
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.' )->debug( $command );
42 42
 			$referer = home_url();
43 43
 		}
Please login to merge, or discard this patch.
plugin/Controllers/SettingsController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	public function callbackRegisterSettings( $input )
19 19
 	{
20
-		if( !is_array( $input )) {
20
+		if( !is_array( $input ) ) {
21 21
 			$input = ['settings' => []];
22 22
 		}
23 23
 		if( key( $input ) == 'settings' ) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			$options = $this->sanitizeSubmissions( $input, $options );
27 27
 			$options = $this->sanitizeTranslations( $input, $options );
28 28
 			if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) {
29
-				glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ));
29
+				glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) );
30 30
 			}
31 31
 			return $options;
32 32
 		}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	{
42 42
 		register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [
43 43
 			'sanitize_callback' => [$this, 'callbackRegisterSettings'],
44
-		]);
44
+		] );
45 45
 	}
46 46
 
47 47
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	protected function sanitizeSubmissions( array $input, array $options )
67 67
 	{
68 68
 		$inputForm = $input['settings']['submissions'];
69
-		$options['settings']['submissions']['required'] = isset( $inputForm['required'] )
69
+		$options['settings']['submissions']['required'] = isset($inputForm['required'])
70 70
 			? $inputForm['required']
71 71
 			: [];
72 72
 		return $options;
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	protected function sanitizeTranslations( array $input, array $options )
79 79
 	{
80
-		if( isset( $input['settings']['strings'] )) {
81
-			$options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ));
80
+		if( isset($input['settings']['strings']) ) {
81
+			$options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) );
82 82
 			$allowedTags = [
83 83
 				'a' => ['class' => [], 'href' => [], 'target' => []],
84 84
 				'span' => ['class' => []],
85 85
 			];
86
-			array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) {
87
-				if( isset( $string['s2'] )) {
86
+			array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) {
87
+				if( isset($string['s2']) ) {
88 88
 					$string['s2'] = wp_kses( $string['s2'], $allowedTags );
89 89
 				}
90
-				if( isset( $string['p2'] )) {
90
+				if( isset($string['p2']) ) {
91 91
 					$string['p2'] = wp_kses( $string['p2'], $allowedTags );
92 92
 				}
93 93
 			});
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	protected function isPolylangActiveAndSupported()
102 102
 	{
103 103
 		if( !glsr( Polylang::class )->isActive() ) {
104
-			glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ));
104
+			glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) );
105 105
 			return false;
106 106
 		}
107 107
 		else if( !glsr( Polylang::class )->isSupported() ) {
108
-			glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ));
108
+			glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) );
109 109
 			return false;
110 110
 		}
111 111
 		return true;
Please login to merge, or discard this patch.
plugin/Container.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public static function load()
39 39
 	{
40
-		if( empty( static::$instance )) {
40
+		if( empty(static::$instance) ) {
41 41
 			static::$instance = new static;
42 42
 		}
43 43
 		return static::$instance;
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function __get( $property )
51 51
 	{
52
-		if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES )) {
52
+		if( property_exists( $this, $property ) && !in_array( $property, static::PROTECTED_PROPERTIES ) ) {
53 53
 			return $this->$property;
54 54
 		}
55
-		$constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property ));
56
-		if( defined( $constant )) {
55
+		$constant = 'static::'.strtoupper( $this->make( Helper::class )->snakeCase( $property ) );
56
+		if( defined( $constant ) ) {
57 57
 			return constant( $constant );
58 58
 		}
59 59
 		return glsr_get( $this->storage, $property, null );
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function __set( $property, $value )
68 68
 	{
69
-		if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES )) {
69
+		if( !property_exists( $this, $property ) || in_array( $property, static::PROTECTED_PROPERTIES ) ) {
70 70
 			$this->storage[$property] = $value;
71 71
 		}
72
-		else if( !isset( $this->$property )) {
72
+		else if( !isset($this->$property) ) {
73 73
 			$this->$property = $value;
74 74
 		}
75 75
 		else {
76
-			throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ));
76
+			throw new Exception( sprintf( 'The "%s" property cannot be changed once set.', $property ) );
77 77
 		}
78 78
 	}
79 79
 
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function make( $abstract )
97 97
 	{
98
-		if( !isset( $this->services[$abstract] )) {
98
+		if( !isset($this->services[$abstract]) ) {
99 99
 			$abstract = $this->addNamespace( $abstract );
100 100
 		}
101
-		if( isset( $this->services[$abstract] )) {
101
+		if( isset($this->services[$abstract]) ) {
102 102
 			$abstract = $this->services[$abstract];
103 103
 		}
104
-		if( is_callable( $abstract )) {
104
+		if( is_callable( $abstract ) ) {
105 105
 			return call_user_func_array( $abstract, [$this] );
106 106
 		}
107
-		if( is_object( $abstract )) {
107
+		if( is_object( $abstract ) ) {
108 108
 			return $abstract;
109 109
 		}
110 110
 		return $this->resolve( $abstract );
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function singleton( $alias, $binding )
120 120
 	{
121
-		$this->bind( $alias, $this->make( $binding ));
121
+		$this->bind( $alias, $this->make( $binding ) );
122 122
 	}
123 123
 
124 124
 	/**
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function addNamespace( $abstract )
130 130
 	{
131
-		if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) {
131
+		if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) {
132 132
 			$abstract = __NAMESPACE__.'\\'.$abstract;
133 133
 		}
134 134
 		return $abstract;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			throw new Exception( 'Target ['.$concrete.'] is not instantiable.' );
151 151
 		}
152 152
 		$constructor = $reflector->getConstructor();
153
-		if( empty( $constructor )) {
153
+		if( empty($constructor) ) {
154 154
 			return new $concrete;
155 155
 		}
156 156
 		return $reflector->newInstanceArgs(
Please login to merge, or discard this patch.
plugin/Database.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	public function getAssignedToPost( $postId, $assignedTo = '' )
22 22
 	{
23
-		if( empty( $assignedTo )) {
23
+		if( empty($assignedTo) ) {
24 24
 			$assignedTo = get_post_meta( $postId, 'assigned_to', true );
25 25
 		}
26
-		if( empty( $assignedTo ))return;
26
+		if( empty($assignedTo) )return;
27 27
 		$assignedPost = get_post( $assignedTo );
28 28
 		if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) {
29 29
 			return $assignedPost;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function getReviewsMeta( $key, $status = 'publish' )
65 65
 	{
66
-		if( $status == 'all' || empty( $status )) {
66
+		if( $status == 'all' || empty($status) ) {
67 67
 			$status = get_post_stati( ['exclude_from_search' => false] );
68 68
 		}
69 69
 		return glsr( SqlQueries::class )->getReviewsMeta( $key, $status );
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$termIds = [];
79 79
 		foreach( $values as $value ) {
80 80
 			$term = get_term_by( $field, $value, Application::TAXONOMY );
81
-			if( !isset( $term->term_id ))continue;
81
+			if( !isset($term->term_id) )continue;
82 82
 			$termIds[] = $term->term_id;
83 83
 		}
84 84
 		return $termIds;
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 			'fields' => 'id=>name',
95 95
 			'hide_empty' => false,
96 96
 			'taxonomy' => Application::TAXONOMY,
97
-		]);
97
+		] );
98 98
 		$terms = get_terms( $args );
99
-		if( is_wp_error( $terms )) {
99
+		if( is_wp_error( $terms ) ) {
100 100
 			glsr_log()->error( $terms->get_error_message() );
101 101
 			return [];
102 102
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			'post_status' => 'publish',
114 114
 			'post_type' => 'any',
115 115
 		];
116
-		if( is_numeric( $searchTerm )) {
116
+		if( is_numeric( $searchTerm ) ) {
117 117
 			$args['post__in'] = [$searchTerm];
118 118
 		}
119 119
 		else {
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 			ob_start();
133 133
 			glsr()->render( 'partials/editor/search-result', [
134 134
 				'ID' => get_the_ID(),
135
-				'permalink' => esc_url( (string) get_permalink() ),
135
+				'permalink' => esc_url( (string)get_permalink() ),
136 136
 				'title' => esc_attr( get_the_title() ),
137
-			]);
137
+			] );
138 138
 			$results .= ob_get_clean();
139 139
 		}
140 140
 		wp_reset_postdata();
Please login to merge, or discard this patch.