Passed
Push — master ( 525778...0f3274 )
by Paul
04:54
created
plugin/Modules/Html/Builder.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function __call( $method, $args )
65 65
 	{
66
-		$instance = new static( $this->globals );
66
+		$instance = new static($this->globals);
67 67
 		$instance->setTagFromMethod( $method );
68
-		call_user_func_array( [$instance, 'normalize'], $args += ['',''] );
68
+		call_user_func_array( [$instance, 'normalize'], $args += ['', ''] );
69 69
 		$tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT );
70 70
 		$generatedTag = in_array( $instance->tag, $tags )
71 71
 			? $instance->buildTag()
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 			'render' => 'is_bool',
90 90
 			'tag' => 'is_string',
91 91
 		];
92
-		if( !isset( $properties[$property] )
93
-			|| empty( array_filter( [$value], $properties[$property] ))
92
+		if( !isset($properties[$property])
93
+			|| empty(array_filter( [$value], $properties[$property] ))
94 94
 		)return;
95 95
 		$this->$property = $value;
96 96
 	}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function getOpeningTag()
110 110
 	{
111
-		$attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString();
111
+		$attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString();
112 112
 		return '<'.trim( $this->tag.' '.$attributes ).'>';
113 113
 	}
114 114
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	protected function buildCustomField()
119 119
 	{
120 120
 		$className = glsr( Helper::class )->buildClassName( $this->tag, __NAMESPACE__.'\Fields' );
121
-		if( !class_exists( $className )) {
121
+		if( !class_exists( $className ) ) {
122 122
 			glsr_log()->error( 'Field missing: '.$className );
123 123
 			return;
124 124
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	protected function buildDefaultTag( $text = '' )
132 132
 	{
133
-		if( empty( $text )) {
133
+		if( empty($text) ) {
134 134
 			$text = $this->args['text'];
135 135
 		}
136 136
 		return $this->getOpeningTag().$text.$this->getClosingTag();
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	protected function buildFieldDescription()
143 143
 	{
144
-		if( empty( $this->args['description'] ))return;
145
-		if( !empty( $this->globals['is_widget'] )) {
144
+		if( empty($this->args['description']) )return;
145
+		if( !empty($this->globals['is_widget']) ) {
146 146
 			return $this->small( $this->args['description'] );
147 147
 		}
148 148
 		return $this->p( $this->args['description'], ['class' => 'description'] );
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	protected function buildFormInput()
155 155
 	{
156
-		if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) {
156
+		if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) {
157 157
 			return $this->buildFormLabel().$this->getOpeningTag();
158 158
 		}
159
-		return empty( $this->args['options'] )
159
+		return empty($this->args['options'])
160 160
 			? $this->buildFormInputChoice()
161 161
 			: $this->buildFormInputMultiChoice();
162 162
 	}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	protected function buildFormInputMultiChoice()
176 176
 	{
177 177
 		if( $this->args['type'] == 'checkbox' ) {
178
-			$this->args['name'].= '[]';
178
+			$this->args['name'] .= '[]';
179 179
 		}
180 180
 		$options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
181 181
 			return $carry.$this->li( $this->{$this->args['type']}([
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 				'name' => $this->args['name'],
184 184
 				'text' => $this->args['options'][$key],
185 185
 				'value' => $key,
186
-			]));
186
+			]) );
187 187
 		});
188 188
 		return $this->ul( $options, [
189 189
 			'class' => $this->args['class'],
190 190
 			'id' => $this->args['id'],
191
-		]);
191
+		] );
192 192
 	}
193 193
 
194 194
 	/**
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 	 */
197 197
 	protected function buildFormLabel()
198 198
 	{
199
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
200
-		return $this->label([
199
+		if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return;
200
+		return $this->label( [
201 201
 			'for' => $this->args['id'],
202 202
 			'text' => $this->args['label'],
203
-		]);
203
+		] );
204 204
 	}
205 205
 
206 206
 	/**
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 	protected function buildFormSelectOptions()
218 218
 	{
219 219
 		return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
220
-			return $carry.$this->option([
220
+			return $carry.$this->option( [
221 221
 				'selected' => $this->args['value'] == $key,
222 222
 				'text' => $this->args['options'][$key],
223 223
 				'value' => $key,
224
-			]);
224
+			] );
225 225
 		});
226 226
 	}
227 227
 
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	protected function buildTag()
240 240
 	{
241
-		if( in_array( $this->tag, static::TAGS_SINGLE )) {
241
+		if( in_array( $this->tag, static::TAGS_SINGLE ) ) {
242 242
 			return $this->getOpeningTag();
243 243
 		}
244
-		if( !in_array( $this->tag, static::TAGS_FORM )) {
244
+		if( !in_array( $this->tag, static::TAGS_FORM ) ) {
245 245
 			return $this->buildDefaultTag();
246 246
 		}
247 247
 		return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription();
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	protected function normalize( ...$params )
255 255
 	{
256
-		if( is_string( $params[0] ) || is_numeric( $params[0] )) {
256
+		if( is_string( $params[0] ) || is_numeric( $params[0] ) ) {
257 257
 			$this->setNameOrTextAttributeForTag( $params[0] );
258 258
 		}
259
-		if( is_array( $params[0] )) {
259
+		if( is_array( $params[0] ) ) {
260 260
 			$this->args += $params[0];
261 261
 		}
262
-		else if( is_array( $params[1] )) {
262
+		else if( is_array( $params[1] ) ) {
263 263
 			$this->args += $params[1];
264 264
 		}
265 265
 		$this->args = glsr( BuilderDefaults::class )->merge( $this->args );
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	protected function setTagFromMethod( $method )
285 285
 	{
286 286
 		$this->tag = strtolower( $method );
287
-		if( in_array( $this->tag, static::INPUT_TYPES )) {
287
+		if( in_array( $this->tag, static::INPUT_TYPES ) ) {
288 288
 			$this->args['type'] = $this->tag;
289 289
 			$this->tag = 'input';
290 290
 		}
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 				'navigation' => $navigation,
51 51
 			],
52 52
 			'reviews' => $this->buildReviews(),
53
-		]);
53
+		] );
54 54
 	}
55 55
 
56 56
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		$generatedReview = [];
75 75
 		foreach( $review as $key => $value ) {
76 76
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildReview' );
77
-			if( !method_exists( $this, $method ))continue;
77
+			if( !method_exists( $this, $method ) )continue;
78 78
 			$generatedReview[$key] = $this->$method( $key, $value );
79 79
 		}
80 80
 		return (object)$generatedReview;
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	protected function buildReviewAssignedTo( $key, $value )
89 89
 	{
90 90
 		if( !$this->isOptionEnabled( 'settings.reviews.assigned_links.enabled' )
91
-			|| empty( $value )
91
+			|| empty($value)
92 92
 		)return;
93
-		$post = get_post( intval( $value ));
94
-		if( !( $post instanceof WP_Post ))return;
93
+		$post = get_post( intval( $value ) );
94
+		if( !($post instanceof WP_Post) )return;
95 95
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
96 96
 			'href' => get_the_permalink( $post->ID ),
97
-		]);
97
+		] );
98 98
 		$permalink = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
99 99
 		return $this->wrap( $key, $permalink );
100 100
 	}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function buildReviewAuthor( $key, $value )
108 108
 	{
109
-		if( $this->isHidden( $key ))return;
109
+		if( $this->isHidden( $key ) )return;
110 110
 		$prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' )
111 111
 			? apply_filters( 'site-reviews/review/author/prefix', '&mdash;' )
112 112
 			: '';
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	protected function buildReviewAvatar( $key, $value )
122 122
 	{
123
-		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return;
123
+		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return;
124 124
 		$size = $this->getOption( 'settings.reviews.avatars.size', 36 );
125
-		return $this->wrap( $key, glsr( Builder::class )->img([
125
+		return $this->wrap( $key, glsr( Builder::class )->img( [
126 126
 			'src' => $value,
127 127
 			'height' => $size,
128 128
 			'width' => $size,
129
-		]));
129
+		] ) );
130 130
 	}
131 131
 
132 132
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	protected function buildReviewContent( $key, $value )
138 138
 	{
139 139
 		$text = $this->normalizeText( $value );
140
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
140
+		if( $this->isHiddenOrEmpty( $key, $text ) )return;
141 141
 		return $this->wrap( $key, $text );
142 142
 	}
143 143
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	protected function buildReviewDate( $key, $value )
150 150
 	{
151
-		if( $this->isHidden( $key ))return;
151
+		if( $this->isHidden( $key ) )return;
152 152
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
153 153
 		if( $dateFormat == 'relative' ) {
154 154
 			$date = glsr( Date::class )->relative( $value );
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			$format = $dateFormat == 'custom'
158 158
 				? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
159 159
 				: (string)get_option( 'date_format' );
160
-			$date = date_i18n( $format, strtotime( $value ));
160
+			$date = date_i18n( $format, strtotime( $value ) );
161 161
 		}
162 162
 		return $this->wrap( $key, $date );
163 163
 	}
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	protected function buildReviewRating( $key, $value )
171 171
 	{
172
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
172
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
173 173
 		$rating = glsr( Html::class )->buildPartial( 'star-rating', [
174 174
 			'rating' => $value,
175
-		]);
175
+		] );
176 176
 		return $this->wrap( $key, $rating );
177 177
 	}
178 178
 
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	protected function buildReviewResponse( $key, $value )
185 185
 	{
186
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
187
-		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
186
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
187
+		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
188 188
 		$text = $this->normalizeText( $value );
189 189
 		return $this->wrap( $key, '<p><strong>'.$title.'</strong></p>'.$text );
190 190
 	}
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 */
197 197
 	protected function buildReviewTitle( $key, $value )
198 198
 	{
199
-		if( $this->isHidden( $key ))return;
200
-		if( empty( $value )) {
199
+		if( $this->isHidden( $key ) )return;
200
+		if( empty($value) ) {
201 201
 			$value = __( 'No Title', 'site-reviews' );
202 202
 		}
203 203
 		return $this->wrap( $key, '<h3>'.$value.'</h3>' );
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	protected function generateSchema()
210 210
 	{
211
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
212
-		glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args ));
211
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
212
+		glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args ) );
213 213
 	}
214 214
 
215 215
 	/**
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
 	{
231 231
 		$limit = $this->getOption( 'settings.reviews.excerpt.length', 55 );
232 232
 		if( str_word_count( $text, 0 ) > $limit ) {
233
-			$words = array_keys( str_word_count( $text, 2 ));
234
-			$excerpt = ltrim( substr( $text, 0, $words[$limit] ));
235
-			$hiddenText = substr( $text, strlen( $excerpt ));
233
+			$words = array_keys( str_word_count( $text, 2 ) );
234
+			$excerpt = ltrim( substr( $text, 0, $words[$limit] ) );
235
+			$hiddenText = substr( $text, strlen( $excerpt ) );
236 236
 			$showMore = glsr( Builder::class )->span( $hiddenText, [
237 237
 				'class' => 'glsr-hidden glsr-hidden-text',
238 238
 				'data-show-less' => __( 'Show less', 'site-reviews' ),
239 239
 				'data-show-more' => __( 'Show more', 'site-reviews' ),
240
-			]);
240
+			] );
241 241
 			$text = $excerpt.$showMore;
242 242
 		}
243 243
 		return nl2br( $text );
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	protected function getOption( $path, $fallback = '' )
252 252
 	{
253
-		if( array_key_exists( $path, $this->options )) {
253
+		if( array_key_exists( $path, $this->options ) ) {
254 254
 			return $this->options[$path];
255 255
 		}
256 256
 		return $fallback;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 */
264 264
 	protected function isHidden( $key, $path = '' )
265 265
 	{
266
-		$isOptionEnabled = !empty( $path )
266
+		$isOptionEnabled = !empty($path)
267 267
 			? $this->isOptionEnabled( $path )
268 268
 			: true;
269 269
 		return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	protected function isHiddenOrEmpty( $key, $value )
278 278
 	{
279
-		return $this->isHidden( $key ) || empty( $value );
279
+		return $this->isHidden( $key ) || empty($value);
280 280
 	}
281 281
 
282 282
 	/**
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	protected function normalizeText( $text )
296 296
 	{
297 297
 		$text = wp_kses( $text, wp_kses_allowed_html() );
298
-		$text = convert_smilies( wptexturize( strip_shortcodes( $text )));
298
+		$text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) );
299 299
 		$text = str_replace( ']]>', ']]&gt;', $text );
300 300
 		$text = $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' )
301 301
 			? $this->getExcerpt( $text )
@@ -312,6 +312,6 @@  discard block
 block discarded – undo
312 312
 	{
313 313
 		return glsr( Builder::class )->div( $value, [
314 314
 			'class' => 'glsr-review-'.$key,
315
-		]);
315
+		] );
316 316
 	}
317 317
 }
Please login to merge, or discard this patch.
Braces   +33 added lines, -11 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
 		$generatedReview = [];
75 75
 		foreach( $review as $key => $value ) {
76 76
 			$method = glsr( Helper::class )->buildMethodName( $key, 'buildReview' );
77
-			if( !method_exists( $this, $method ))continue;
77
+			if( !method_exists( $this, $method )) {
78
+				continue;
79
+			}
78 80
 			$generatedReview[$key] = $this->$method( $key, $value );
79 81
 		}
80 82
 		return (object)$generatedReview;
@@ -89,9 +91,13 @@  discard block
 block discarded – undo
89 91
 	{
90 92
 		if( !$this->isOptionEnabled( 'settings.reviews.assigned_links.enabled' )
91 93
 			|| empty( $value )
92
-		)return;
94
+		) {
95
+			return;
96
+		}
93 97
 		$post = get_post( intval( $value ));
94
-		if( !( $post instanceof WP_Post ))return;
98
+		if( !( $post instanceof WP_Post )) {
99
+			return;
100
+		}
95 101
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
96 102
 			'href' => get_the_permalink( $post->ID ),
97 103
 		]);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 	 */
107 113
 	protected function buildReviewAuthor( $key, $value )
108 114
 	{
109
-		if( $this->isHidden( $key ))return;
115
+		if( $this->isHidden( $key )) {
116
+			return;
117
+		}
110 118
 		$prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' )
111 119
 			? apply_filters( 'site-reviews/review/author/prefix', '&mdash;' )
112 120
 			: '';
@@ -120,7 +128,9 @@  discard block
 block discarded – undo
120 128
 	 */
121 129
 	protected function buildReviewAvatar( $key, $value )
122 130
 	{
123
-		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return;
131
+		if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) {
132
+			return;
133
+		}
124 134
 		$size = $this->getOption( 'settings.reviews.avatars.size', 36 );
125 135
 		return $this->wrap( $key, glsr( Builder::class )->img([
126 136
 			'src' => $value,
@@ -137,7 +147,9 @@  discard block
 block discarded – undo
137 147
 	protected function buildReviewContent( $key, $value )
138 148
 	{
139 149
 		$text = $this->normalizeText( $value );
140
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
150
+		if( $this->isHiddenOrEmpty( $key, $text )) {
151
+			return;
152
+		}
141 153
 		return $this->wrap( $key, $text );
142 154
 	}
143 155
 
@@ -148,7 +160,9 @@  discard block
 block discarded – undo
148 160
 	 */
149 161
 	protected function buildReviewDate( $key, $value )
150 162
 	{
151
-		if( $this->isHidden( $key ))return;
163
+		if( $this->isHidden( $key )) {
164
+			return;
165
+		}
152 166
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
153 167
 		if( $dateFormat == 'relative' ) {
154 168
 			$date = glsr( Date::class )->relative( $value );
@@ -169,7 +183,9 @@  discard block
 block discarded – undo
169 183
 	 */
170 184
 	protected function buildReviewRating( $key, $value )
171 185
 	{
172
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
186
+		if( $this->isHiddenOrEmpty( $key, $value )) {
187
+			return;
188
+		}
173 189
 		$rating = glsr( Html::class )->buildPartial( 'star-rating', [
174 190
 			'rating' => $value,
175 191
 		]);
@@ -183,7 +199,9 @@  discard block
 block discarded – undo
183 199
 	 */
184 200
 	protected function buildReviewResponse( $key, $value )
185 201
 	{
186
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
202
+		if( $this->isHiddenOrEmpty( $key, $value )) {
203
+			return;
204
+		}
187 205
 		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
188 206
 		$text = $this->normalizeText( $value );
189 207
 		return $this->wrap( $key, '<p><strong>'.$title.'</strong></p>'.$text );
@@ -196,7 +214,9 @@  discard block
 block discarded – undo
196 214
 	 */
197 215
 	protected function buildReviewTitle( $key, $value )
198 216
 	{
199
-		if( $this->isHidden( $key ))return;
217
+		if( $this->isHidden( $key )) {
218
+			return;
219
+		}
200 220
 		if( empty( $value )) {
201 221
 			$value = __( 'No Title', 'site-reviews' );
202 222
 		}
@@ -208,7 +228,9 @@  discard block
 block discarded – undo
208 228
 	 */
209 229
 	protected function generateSchema()
210 230
 	{
211
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
231
+		if( !wp_validate_boolean( $this->args['schema'] )) {
232
+			return;
233
+		}
212 234
 		glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args ));
213 235
 	}
214 236
 
Please login to merge, or discard this patch.