Passed
Push — master ( e0dbf5...75834f )
by Paul
04:31
created
plugin/Modules/Schema/BaseType.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -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 $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
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function setProperty( $property, $value )
173 173
 	{
174
-		if( !in_array( $property, $this->allowed )) {
174
+		if( !in_array( $property, $this->allowed ) ) {
175 175
 			glsr_log()->error( 'Invalid schema property ('.$property.') for '.$this->getType() );
176 176
 			return $this;
177 177
 		}
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	protected function getParents( $parents = null )
208 208
 	{
209
-		if( !isset( $parents )) {
209
+		if( !isset($parents) ) {
210 210
 			$parents = $this->parents;
211 211
 		}
212 212
 		$newParents = $parents;
213 213
 		foreach( $parents as $parent ) {
214 214
 			$parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ );
215
-			if( !class_exists( $parentClass ))continue;
216
-			$newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ));
215
+			if( !class_exists( $parentClass ) )continue;
216
+			$newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ) );
217 217
 		}
218
-		return array_values( array_unique( $newParents ));
218
+		return array_values( array_unique( $newParents ) );
219 219
 	}
220 220
 
221 221
 	/**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		$parents = $this->getParents();
227 227
 		foreach( $parents as $parent ) {
228 228
 			$parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ );
229
-			if( !class_exists( $parentClass ))continue;
230
-			$this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed )));
229
+			if( !class_exists( $parentClass ) )continue;
230
+			$this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ) ) );
231 231
 		}
232 232
 	}
233 233
 
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	protected function serializeProperty( $property )
239 239
 	{
240
-		if( is_array( $property )) {
240
+		if( is_array( $property ) ) {
241 241
 			return array_map( [$this, 'serializeProperty'], $property );
242 242
 		}
243 243
 		if( $property instanceof Type ) {
244 244
 			$property = $property->toArray();
245
-			unset( $property['@context'] );
245
+			unset($property['@context']);
246 246
 		}
247 247
 		if( $property instanceof DateTimeInterface ) {
248 248
 			$property = $property->format( DateTime::ATOM );
249 249
 		}
250
-		if( is_object( $property )) {
250
+		if( is_object( $property ) ) {
251 251
 			throw new InvalidProperty();
252 252
 		}
253 253
 		return $property;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -212,7 +212,9 @@  discard block
 block discarded – undo
212 212
 		$newParents = $parents;
213 213
 		foreach( $parents as $parent ) {
214 214
 			$parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ );
215
-			if( !class_exists( $parentClass ))continue;
215
+			if( !class_exists( $parentClass )) {
216
+				continue;
217
+			}
216 218
 			$newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ));
217 219
 		}
218 220
 		return array_values( array_unique( $newParents ));
@@ -226,7 +228,9 @@  discard block
 block discarded – undo
226 228
 		$parents = $this->getParents();
227 229
 		foreach( $parents as $parent ) {
228 230
 			$parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ );
229
-			if( !class_exists( $parentClass ))continue;
231
+			if( !class_exists( $parentClass )) {
232
+				continue;
233
+			}
230 234
 			$this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed )));
231 235
 		}
232 236
 	}
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 		foreach( glsr( Database::class )->getReviews( $this->args )->results as $review ) {
35 35
 			$reviews[] = $this->buildReview( $review );
36 36
 		}
37
-		if( !empty( $reviews )) {
37
+		if( !empty($reviews) ) {
38 38
 			array_walk( $reviews, function( &$review ) {
39
-				unset( $review['@context'] );
40
-				unset( $review['itemReviewed'] );
39
+				unset($review['@context']);
40
+				unset($review['itemReviewed']);
41 41
 			});
42 42
 			$schema['review'] = $reviews;
43 43
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function buildSummary( $args = null )
52 52
 	{
53
-		if( is_array( $args )) {
53
+		if( is_array( $args ) ) {
54 54
 			$this->args = $args;
55 55
 		}
56 56
 		$buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$schema = method_exists( $this, $buildSummary )
59 59
 			? $this->$buildSummary()
60 60
 			: $this->buildSummaryForCustom();
61
-		if( !empty( $count )) {
61
+		if( !empty($count) ) {
62 62
 			$schema->aggregateRating( $this->getSchemaType( 'AggregateRating' )
63 63
 				->ratingValue( $this->getRatingValue() )
64 64
 				->reviewCount( $count )
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function render()
78 78
 	{
79
-		if( is_null( glsr()->schemas ))return;
79
+		if( is_null( glsr()->schemas ) )return;
80 80
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
81 81
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
82 82
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
83
-		));
83
+		) );
84 84
 	}
85 85
 
86 86
 	/**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	{
91 91
 		$schemas = glsr()->schemas;
92 92
 		$schemas[] = $schema;
93
-		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas )));
93
+		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
94 94
 	}
95 95
 
96 96
 	/**
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 	protected function buildReview( $review )
101 101
 	{
102 102
 		$schema = $this->getSchemaType( 'Review' )
103
-			->doIf( !in_array( 'title', $this->args['hide'] ), function( SchemaReview $schema ) use( $review ) {
103
+			->doIf( !in_array( 'title', $this->args['hide'] ), function( SchemaReview $schema ) use($review) {
104 104
 				$schema->name( $review->title );
105 105
 			})
106
-			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( SchemaReview $schema ) use( $review ) {
106
+			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( SchemaReview $schema ) use($review) {
107 107
 				$schema->reviewBody( $review->content );
108 108
 			})
109
-			->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 ))
110
-			->author( $this->getSchemaType( 'Person' )->name( $review->author ))
111
-			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' )));
112
-		if( !empty( $review->rating )) {
109
+			->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) )
110
+			->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
111
+			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
112
+		if( !empty($review->rating) ) {
113 113
 			$schema->reviewRating( $this->getSchemaType( 'Rating' )
114 114
 				->ratingValue( $review->rating )
115 115
 				->bestRating( Rating::MAX_RATING )
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	{
127 127
 		foreach( $values as $value ) {
128 128
 			$option = $this->getSchemaOptionValue( $value );
129
-			if( empty( $option ))continue;
129
+			if( empty($option) )continue;
130 130
 			$schema->$value( $option );
131 131
 		}
132 132
 		return $schema;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	{
140 140
 		return $this->buildSchemaValues( $this->getSchemaType(), [
141 141
 			'description', 'image', 'name', 'url',
142
-		]);
142
+		] );
143 143
 	}
144 144
 
145 145
 	/**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	{
150 150
 		return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
151 151
 			'address', 'priceRange', 'telephone',
152
-		]);
152
+		] );
153 153
 	}
154 154
 
155 155
 	/**
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 	{
160 160
 		$offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [
161 161
 			'highPrice', 'lowPrice', 'priceCurrency',
162
-		]);
162
+		] );
163 163
 		return $this->buildSummaryForCustom()
164 164
 			->offers( $offers )
165
-			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ));
165
+			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ) );
166 166
 	}
167 167
 
168 168
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	protected function getReviews( $force = false )
188 188
 	{
189
-		if( !isset( $this->reviews ) || $force ) {
189
+		if( !isset($this->reviews) || $force ) {
190 190
 			$args = wp_parse_args( ['count' => -1], $this->args );
191 191
 			$this->reviews = glsr( Database::class )->getReviews( $args )->results;
192 192
 		}
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 	protected function getSchemaOption( $option, $fallback )
202 202
 	{
203 203
 		$option = strtolower( $option );
204
-		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) {
204
+		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
205 205
 			return $schemaOption;
206 206
 		}
207 207
 		$setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
208
-		if( is_array( $setting )) {
208
+		if( is_array( $setting ) ) {
209 209
 			return $this->getSchemaOptionDefault( $setting, $fallback );
210 210
 		}
211
-		return !empty( $setting )
211
+		return !empty($setting)
212 212
 			? $setting
213 213
 			: $fallback;
214 214
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		$setting = wp_parse_args( $setting, [
224 224
 			'custom' => '',
225 225
 			'default' => $fallback,
226
-		]);
226
+		] );
227 227
 		return $setting['default'] != 'custom'
228 228
 			? $setting['default']
229 229
 			: $setting['custom'];
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	protected function getSchemaType( $type = null )
262 262
 	{
263
-		if( !is_string( $type )) {
263
+		if( !is_string( $type ) ) {
264 264
 			$type = $this->getSchemaOption( 'type', 'LocalBusiness' );
265 265
 		}
266 266
 		$className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' );
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	protected function getThingDescription()
276 276
 	{
277 277
 		$post = get_post();
278
-		if( !( $post instanceof WP_Post )) {
278
+		if( !($post instanceof WP_Post) ) {
279 279
 			return '';
280 280
 		}
281
-		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ));
282
-		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ));
281
+		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) );
282
+		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) );
283 283
 	}
284 284
 
285 285
 	/**
Please login to merge, or discard this patch.