Completed
Pull Request — develop (#1554)
by Naveen
48s
created
src/wordlift/shipping-data/class-shipping-zone.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -10,140 +10,140 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Shipping_Zone {
12 12
 
13
-	/**
14
-	 * @var WC_Shipping_Zone
15
-	 */
16
-	private $wc_shipping_zone;
13
+    /**
14
+     * @var WC_Shipping_Zone
15
+     */
16
+    private $wc_shipping_zone;
17 17
 
18
-	/**
19
-	 * @var Shipping_Method[]
20
-	 */
21
-	private $methods;
18
+    /**
19
+     * @var Shipping_Method[]
20
+     */
21
+    private $methods;
22 22
 
23
-	/**
24
-	 * @var string
25
-	 */
26
-	private $country_code;
23
+    /**
24
+     * @var string
25
+     */
26
+    private $country_code;
27 27
 
28
-	/**
29
-	 * @var string[]
30
-	 */
31
-	private $regions = array();
28
+    /**
29
+     * @var string[]
30
+     */
31
+    private $regions = array();
32 32
 
33
-	/**
34
-	 * @var string[]
35
-	 */
36
-	private $postal_codes = array();
33
+    /**
34
+     * @var string[]
35
+     */
36
+    private $postal_codes = array();
37 37
 
38
-	/**
39
-	 * @var string[]
40
-	 */
41
-	private $postal_code_prefixes = array();
38
+    /**
39
+     * @var string[]
40
+     */
41
+    private $postal_code_prefixes = array();
42 42
 
43
-	/**
44
-	 * @var string[]
45
-	 */
46
-	private $postal_code_ranges = array();
43
+    /**
44
+     * @var string[]
45
+     */
46
+    private $postal_code_ranges = array();
47 47
 
48
-	/**
49
-	 * Shipping_Zone constructor.
50
-	 *
51
-	 * @param WC_Shipping_Zone $wc_shipping_zone
52
-	 * @param string $country_code
53
-	 */
54
-	public function __construct( $wc_shipping_zone, $country_code ) {
48
+    /**
49
+     * Shipping_Zone constructor.
50
+     *
51
+     * @param WC_Shipping_Zone $wc_shipping_zone
52
+     * @param string $country_code
53
+     */
54
+    public function __construct( $wc_shipping_zone, $country_code ) {
55 55
 
56
-		$this->wc_shipping_zone = $wc_shipping_zone;
57
-		$this->country_code     = $country_code;
56
+        $this->wc_shipping_zone = $wc_shipping_zone;
57
+        $this->country_code     = $country_code;
58 58
 
59
-		$this->load_zone_locations();
59
+        $this->load_zone_locations();
60 60
 
61
-	}
61
+    }
62 62
 
63
-	private function load_zone_locations() {
63
+    private function load_zone_locations() {
64 64
 
65
-		$this->regions              = array();
66
-		$this->postal_codes         = array();
67
-		$this->postal_code_prefixes = array();
68
-		$this->postal_code_ranges   = array();
65
+        $this->regions              = array();
66
+        $this->postal_codes         = array();
67
+        $this->postal_code_prefixes = array();
68
+        $this->postal_code_ranges   = array();
69 69
 
70
-		// Bail out if country code isn't set.
71
-		if ( ! isset( $this->country_code ) ) {
72
-			return;
73
-		}
70
+        // Bail out if country code isn't set.
71
+        if ( ! isset( $this->country_code ) ) {
72
+            return;
73
+        }
74 74
 
75
-		foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) {
76
-			switch ( $zone_location->type ) {
77
-				case 'state':
78
-					if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) {
79
-						$this->regions[] = substr( $zone_location->code, 3 );
80
-					}
75
+        foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) {
76
+            switch ( $zone_location->type ) {
77
+                case 'state':
78
+                    if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) {
79
+                        $this->regions[] = substr( $zone_location->code, 3 );
80
+                    }
81 81
 
82
-					break;
82
+                    break;
83 83
 
84
-				case 'postcode':
85
-					if ( '*' === substr( $zone_location->code, - 1 ) ) {
86
-						$this->postal_code_prefixes[] = $zone_location->code;
87
-					} else if ( - 1 < strpos( $zone_location->code, '...' ) ) {
88
-						$this->postal_code_ranges[] = $zone_location->code;
89
-					} else {
90
-						$this->postal_codes[] = $zone_location->code;
91
-					}
84
+                case 'postcode':
85
+                    if ( '*' === substr( $zone_location->code, - 1 ) ) {
86
+                        $this->postal_code_prefixes[] = $zone_location->code;
87
+                    } else if ( - 1 < strpos( $zone_location->code, '...' ) ) {
88
+                        $this->postal_code_ranges[] = $zone_location->code;
89
+                    } else {
90
+                        $this->postal_codes[] = $zone_location->code;
91
+                    }
92 92
 
93
-					break;
93
+                    break;
94 94
 
95
-				default:
96
-			}
97
-		}
95
+                default:
96
+            }
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	private function load_methods() {
101
+    private function load_methods() {
102 102
 
103
-		$this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
-			$this->wc_shipping_zone->get_shipping_methods( true ) );
103
+        $this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
+            $this->wc_shipping_zone->get_shipping_methods( true ) );
105 105
 
106
-	}
106
+    }
107 107
 
108
-	public function add_available_delivery_method( &$jsonld ) {
108
+    public function add_available_delivery_method( &$jsonld ) {
109 109
 
110
-		$this->load_methods();
110
+        $this->load_methods();
111 111
 
112
-		foreach ( $this->methods as $method ) {
113
-			$method->add_available_delivery_method( $jsonld );
114
-		}
112
+        foreach ( $this->methods as $method ) {
113
+            $method->add_available_delivery_method( $jsonld );
114
+        }
115 115
 
116
-	}
116
+    }
117 117
 
118
-	/**
119
-	 * @param array $jsonld
120
-	 * @param Product $product
121
-	 */
122
-	public function add_offer_shipping_details( &$jsonld, $product ) {
118
+    /**
119
+     * @param array $jsonld
120
+     * @param Product $product
121
+     */
122
+    public function add_offer_shipping_details( &$jsonld, $product ) {
123 123
 
124
-		$this->load_methods();
124
+        $this->load_methods();
125 125
 
126
-		// Ignore the default zone if no methods are configured.
127
-		if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) {
128
-			return;
129
-		}
126
+        // Ignore the default zone if no methods are configured.
127
+        if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) {
128
+            return;
129
+        }
130 130
 
131
-		$this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld );
131
+        $this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld );
132 132
 
133
-		if ( empty( $this->methods ) ) {
134
-			$this->add_shipping_details_with_shipping_method( $jsonld, $product );
135
-		} else {
136
-			foreach ( $this->methods as $method ) {
137
-				$this->add_shipping_details_with_shipping_method( $jsonld, $product, $method );
138
-			}
139
-		}
133
+        if ( empty( $this->methods ) ) {
134
+            $this->add_shipping_details_with_shipping_method( $jsonld, $product );
135
+        } else {
136
+            foreach ( $this->methods as $method ) {
137
+                $this->add_shipping_details_with_shipping_method( $jsonld, $product, $method );
138
+            }
139
+        }
140 140
 
141
-	}
141
+    }
142 142
 
143
-	/**
144
-	 * @param array $jsonld
145
-	 * @param Product $product
146
-	 */
143
+    /**
144
+     * @param array $jsonld
145
+     * @param Product $product
146
+     */
147 147
 //	private function add_shipping_details_when_no_shipping_methods( &$jsonld, $product ) {
148 148
 //
149 149
 //		$offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
@@ -166,180 +166,180 @@  discard block
 block discarded – undo
166 166
 //
167 167
 //	}
168 168
 
169
-	/**
170
-	 * @param array $jsonld
171
-	 * @param Product $product
172
-	 * @param Shipping_Method $method
173
-	 */
174
-	private function add_shipping_details_with_shipping_method( &$jsonld, $product, $method = null ) {
169
+    /**
170
+     * @param array $jsonld
171
+     * @param Product $product
172
+     * @param Shipping_Method $method
173
+     */
174
+    private function add_shipping_details_with_shipping_method( &$jsonld, $product, $method = null ) {
175 175
 
176
-		$offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
177
-		$shipping_delivery_time = array( '@type' => 'ShippingDeliveryTime', );
176
+        $offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
177
+        $shipping_delivery_time = array( '@type' => 'ShippingDeliveryTime', );
178 178
 
179
-		$this->add_shipping_destination( $offer_shipping_details );
179
+        $this->add_shipping_destination( $offer_shipping_details );
180 180
 
181
-		/*
181
+        /*
182 182
 		 * Use Case UC003
183 183
 		 * 1.4.3
184 184
 		 */
185
-		if ( isset( $method ) ) {
186
-			$method->add_shipping_rate( $offer_shipping_details );
187
-			$method->add_transit_time( $shipping_delivery_time );
188
-		}
185
+        if ( isset( $method ) ) {
186
+            $method->add_shipping_rate( $offer_shipping_details );
187
+            $method->add_transit_time( $shipping_delivery_time );
188
+        }
189 189
 
190
-		/*
190
+        /*
191 191
 		 * Use Case UC004
192 192
 		 */
193
-		$product->add_handling_time( $shipping_delivery_time );
193
+        $product->add_handling_time( $shipping_delivery_time );
194 194
 
195
-		$this->add_cutoff_time( $shipping_delivery_time );
196
-		$this->add_business_days( $shipping_delivery_time );
195
+        $this->add_cutoff_time( $shipping_delivery_time );
196
+        $this->add_business_days( $shipping_delivery_time );
197 197
 
198
-		if ( 1 < count( $shipping_delivery_time ) ) {
199
-			$offer_shipping_details['deliveryTime'] = $shipping_delivery_time;
200
-		}
198
+        if ( 1 < count( $shipping_delivery_time ) ) {
199
+            $offer_shipping_details['deliveryTime'] = $shipping_delivery_time;
200
+        }
201 201
 
202
-		$jsonld['shippingDetails'][] = $offer_shipping_details;
202
+        $jsonld['shippingDetails'][] = $offer_shipping_details;
203 203
 
204
-	}
204
+    }
205 205
 
206
-	private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) {
206
+    private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) {
207 207
 
208
-		if ( ! isset( $jsonld['shippingDetails'] ) ) {
209
-			$jsonld['shippingDetails'] = array();
210
-		}
208
+        if ( ! isset( $jsonld['shippingDetails'] ) ) {
209
+            $jsonld['shippingDetails'] = array();
210
+        }
211 211
 
212
-		if ( ! is_array( $jsonld['shippingDetails'] ) ||
213
-		     ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) {
214
-			$jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] );
215
-		}
212
+        if ( ! is_array( $jsonld['shippingDetails'] ) ||
213
+             ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) {
214
+            $jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] );
215
+        }
216 216
 
217
-	}
217
+    }
218 218
 
219
-	private function add_shipping_destination( &$shipping_details ) {
219
+    private function add_shipping_destination( &$shipping_details ) {
220 220
 
221
-		if ( ! isset( $this->country_code ) ) {
222
-			return;
223
-		}
221
+        if ( ! isset( $this->country_code ) ) {
222
+            return;
223
+        }
224 224
 
225
-		$shipping_destination = array(
226
-			'@type'          => 'DefinedRegion',
227
-			'addressCountry' => $this->country_code,
228
-		);
225
+        $shipping_destination = array(
226
+            '@type'          => 'DefinedRegion',
227
+            'addressCountry' => $this->country_code,
228
+        );
229 229
 
230
-		$this->add_address_region( $shipping_destination );
231
-		$this->add_postal_code( $shipping_destination );
232
-		$this->add_postal_code_prefix( $shipping_destination );
233
-		$this->add_postal_code_range( $shipping_destination );
230
+        $this->add_address_region( $shipping_destination );
231
+        $this->add_postal_code( $shipping_destination );
232
+        $this->add_postal_code_prefix( $shipping_destination );
233
+        $this->add_postal_code_range( $shipping_destination );
234 234
 
235
-		$shipping_details['shippingDestination'] = $shipping_destination;
235
+        $shipping_details['shippingDestination'] = $shipping_destination;
236 236
 
237 237
 
238
-	}
238
+    }
239 239
 
240
-	private function add_address_region( &$shipping_destination ) {
240
+    private function add_address_region( &$shipping_destination ) {
241 241
 
242
-		if ( empty( $this->regions ) ) {
243
-			return;
244
-		}
242
+        if ( empty( $this->regions ) ) {
243
+            return;
244
+        }
245 245
 
246
-		$shipping_destination['addressRegion'] = $this->regions;
246
+        $shipping_destination['addressRegion'] = $this->regions;
247 247
 
248
-	}
248
+    }
249 249
 
250
-	private function add_postal_code( &$shipping_destination ) {
250
+    private function add_postal_code( &$shipping_destination ) {
251 251
 
252
-		if ( empty( $this->postal_codes ) ) {
253
-			return;
254
-		}
252
+        if ( empty( $this->postal_codes ) ) {
253
+            return;
254
+        }
255 255
 
256
-		$shipping_destination['postalCode'] = $this->postal_codes;
256
+        $shipping_destination['postalCode'] = $this->postal_codes;
257 257
 
258
-	}
258
+    }
259 259
 
260
-	private function add_postal_code_prefix( &$shipping_destination ) {
260
+    private function add_postal_code_prefix( &$shipping_destination ) {
261 261
 
262
-		if ( empty( $this->postal_code_prefixes ) ) {
263
-			return;
264
-		}
262
+        if ( empty( $this->postal_code_prefixes ) ) {
263
+            return;
264
+        }
265 265
 
266
-		foreach ( $this->postal_code_prefixes as $postal_code_prefix ) {
267
-			$shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 );
268
-		}
266
+        foreach ( $this->postal_code_prefixes as $postal_code_prefix ) {
267
+            $shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 );
268
+        }
269 269
 
270
-	}
270
+    }
271 271
 
272
-	private function add_postal_code_range( &$shipping_destination ) {
272
+    private function add_postal_code_range( &$shipping_destination ) {
273 273
 
274
-		if ( empty( $this->postal_code_ranges ) ) {
275
-			return;
276
-		}
274
+        if ( empty( $this->postal_code_ranges ) ) {
275
+            return;
276
+        }
277 277
 
278
-		$shipping_destination['postalCodeRanges'] = array();
279
-		foreach ( $this->postal_code_ranges as $post_code_range ) {
280
-			$range = explode( '...', $post_code_range );
278
+        $shipping_destination['postalCodeRanges'] = array();
279
+        foreach ( $this->postal_code_ranges as $post_code_range ) {
280
+            $range = explode( '...', $post_code_range );
281 281
 
282
-			$shipping_destination['postalCodeRanges'][] = array(
283
-				'postalCodeBegin' => $range[0],
284
-				'postalCodeEnd'   => $range[1],
285
-			);
286
-		}
282
+            $shipping_destination['postalCodeRanges'][] = array(
283
+                'postalCodeBegin' => $range[0],
284
+                'postalCodeEnd'   => $range[1],
285
+            );
286
+        }
287 287
 
288
-	}
288
+    }
289 289
 
290
-	public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) {
290
+    public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) {
291 291
 
292
-		return new self( $wc_shipping_zone, $country_code );
293
-	}
292
+        return new self( $wc_shipping_zone, $country_code );
293
+    }
294 294
 
295
-	private function add_cutoff_time( &$shipping_delivery_time ) {
295
+    private function add_cutoff_time( &$shipping_delivery_time ) {
296 296
 
297
-		$wpsso_options = get_option( 'wpsso_options' );
297
+        $wpsso_options = get_option( 'wpsso_options' );
298 298
 
299
-		if ( empty( $wpsso_options['wcsdt_shipdept_cutoff'] )
300
-		     || empty( $wpsso_options['wcsdt_shipdept_timezone'] ) ) {
301
-			return;
302
-		}
299
+        if ( empty( $wpsso_options['wcsdt_shipdept_cutoff'] )
300
+             || empty( $wpsso_options['wcsdt_shipdept_timezone'] ) ) {
301
+            return;
302
+        }
303 303
 
304
-		$cutoff_time = $wpsso_options['wcsdt_shipdept_cutoff'];
304
+        $cutoff_time = $wpsso_options['wcsdt_shipdept_cutoff'];
305 305
 
306
-		if ( 'none' !== $cutoff_time ) {
307
-			$timezone = $wpsso_options['wcsdt_shipdept_timezone'];
306
+        if ( 'none' !== $cutoff_time ) {
307
+            $timezone = $wpsso_options['wcsdt_shipdept_timezone'];
308 308
 
309
-			$time   = new DateTime( 'now', new DateTimeZone( $timezone ) );
310
-			$offset = $time->format( 'P' );
309
+            $time   = new DateTime( 'now', new DateTimeZone( $timezone ) );
310
+            $offset = $time->format( 'P' );
311 311
 
312
-			$shipping_delivery_time['cutOffTime'] = "{$cutoff_time}{$offset}";
313
-		}
312
+            $shipping_delivery_time['cutOffTime'] = "{$cutoff_time}{$offset}";
313
+        }
314 314
 
315
-	}
315
+    }
316 316
 
317
-	private function add_business_days( &$shipping_delivery_time ) {
317
+    private function add_business_days( &$shipping_delivery_time ) {
318 318
 
319
-		$wpsso_options = get_option( 'wpsso_options' );
319
+        $wpsso_options = get_option( 'wpsso_options' );
320 320
 
321
-		$day_of_week = array();
322
-		$prefix      = 'wcsdt_shipdept_day_';
323
-		foreach ( array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ) as $day ) {
324
-			$key = $prefix . strtolower( $day );
321
+        $day_of_week = array();
322
+        $prefix      = 'wcsdt_shipdept_day_';
323
+        foreach ( array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ) as $day ) {
324
+            $key = $prefix . strtolower( $day );
325 325
 
326
-			if (
327
-				( empty( $wpsso_options["{$key}_open"] ) && empty( $wpsso_options["{$key}_close"] ) )
328
-				|| ( 'none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"] )
329
-			) {
330
-				continue;
331
-			}
326
+            if (
327
+                ( empty( $wpsso_options["{$key}_open"] ) && empty( $wpsso_options["{$key}_close"] ) )
328
+                || ( 'none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"] )
329
+            ) {
330
+                continue;
331
+            }
332 332
 
333
-			$day_of_week[] = "https://schema.org/$day";
334
-		}
333
+            $day_of_week[] = "https://schema.org/$day";
334
+        }
335 335
 
336
-		if ( ! empty( $day_of_week ) ) {
337
-			$shipping_delivery_time['businessDays'] = array(
338
-				'@type'     => 'OpeningHoursSpecification',
339
-				'dayOfWeek' => $day_of_week,
340
-			);
341
-		}
336
+        if ( ! empty( $day_of_week ) ) {
337
+            $shipping_delivery_time['businessDays'] = array(
338
+                '@type'     => 'OpeningHoursSpecification',
339
+                'dayOfWeek' => $day_of_week,
340
+            );
341
+        }
342 342
 
343
-	}
343
+    }
344 344
 
345 345
 }
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param WC_Shipping_Zone $wc_shipping_zone
52 52
 	 * @param string $country_code
53 53
 	 */
54
-	public function __construct( $wc_shipping_zone, $country_code ) {
54
+	public function __construct($wc_shipping_zone, $country_code) {
55 55
 
56 56
 		$this->wc_shipping_zone = $wc_shipping_zone;
57 57
 		$this->country_code     = $country_code;
@@ -68,23 +68,23 @@  discard block
 block discarded – undo
68 68
 		$this->postal_code_ranges   = array();
69 69
 
70 70
 		// Bail out if country code isn't set.
71
-		if ( ! isset( $this->country_code ) ) {
71
+		if ( ! isset($this->country_code)) {
72 72
 			return;
73 73
 		}
74 74
 
75
-		foreach ( $this->wc_shipping_zone->get_zone_locations() as $zone_location ) {
76
-			switch ( $zone_location->type ) {
75
+		foreach ($this->wc_shipping_zone->get_zone_locations() as $zone_location) {
76
+			switch ($zone_location->type) {
77 77
 				case 'state':
78
-					if ( 0 === strpos( $zone_location->code, "$this->country_code:" ) ) {
79
-						$this->regions[] = substr( $zone_location->code, 3 );
78
+					if (0 === strpos($zone_location->code, "$this->country_code:")) {
79
+						$this->regions[] = substr($zone_location->code, 3);
80 80
 					}
81 81
 
82 82
 					break;
83 83
 
84 84
 				case 'postcode':
85
-					if ( '*' === substr( $zone_location->code, - 1 ) ) {
85
+					if ('*' === substr($zone_location->code, - 1)) {
86 86
 						$this->postal_code_prefixes[] = $zone_location->code;
87
-					} else if ( - 1 < strpos( $zone_location->code, '...' ) ) {
87
+					} else if ( -1 < strpos($zone_location->code, '...') ) {
88 88
 						$this->postal_code_ranges[] = $zone_location->code;
89 89
 					} else {
90 90
 						$this->postal_codes[] = $zone_location->code;
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 
101 101
 	private function load_methods() {
102 102
 
103
-		$this->methods = array_map( 'Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
-			$this->wc_shipping_zone->get_shipping_methods( true ) );
103
+		$this->methods = array_map('Wordlift\Shipping_Data\Shipping_Method::from_wc_shipping_method',
104
+			$this->wc_shipping_zone->get_shipping_methods(true));
105 105
 
106 106
 	}
107 107
 
108
-	public function add_available_delivery_method( &$jsonld ) {
108
+	public function add_available_delivery_method(&$jsonld) {
109 109
 
110 110
 		$this->load_methods();
111 111
 
112
-		foreach ( $this->methods as $method ) {
113
-			$method->add_available_delivery_method( $jsonld );
112
+		foreach ($this->methods as $method) {
113
+			$method->add_available_delivery_method($jsonld);
114 114
 		}
115 115
 
116 116
 	}
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
 	 * @param array $jsonld
120 120
 	 * @param Product $product
121 121
 	 */
122
-	public function add_offer_shipping_details( &$jsonld, $product ) {
122
+	public function add_offer_shipping_details(&$jsonld, $product) {
123 123
 
124 124
 		$this->load_methods();
125 125
 
126 126
 		// Ignore the default zone if no methods are configured.
127
-		if ( 0 === $this->wc_shipping_zone->get_id() && 0 === count( $this->methods ) ) {
127
+		if (0 === $this->wc_shipping_zone->get_id() && 0 === count($this->methods)) {
128 128
 			return;
129 129
 		}
130 130
 
131
-		$this->make_sure_shipping_details_exists_and_it_is_an_array( $jsonld );
131
+		$this->make_sure_shipping_details_exists_and_it_is_an_array($jsonld);
132 132
 
133
-		if ( empty( $this->methods ) ) {
134
-			$this->add_shipping_details_with_shipping_method( $jsonld, $product );
133
+		if (empty($this->methods)) {
134
+			$this->add_shipping_details_with_shipping_method($jsonld, $product);
135 135
 		} else {
136
-			foreach ( $this->methods as $method ) {
137
-				$this->add_shipping_details_with_shipping_method( $jsonld, $product, $method );
136
+			foreach ($this->methods as $method) {
137
+				$this->add_shipping_details_with_shipping_method($jsonld, $product, $method);
138 138
 			}
139 139
 		}
140 140
 
@@ -171,31 +171,31 @@  discard block
 block discarded – undo
171 171
 	 * @param Product $product
172 172
 	 * @param Shipping_Method $method
173 173
 	 */
174
-	private function add_shipping_details_with_shipping_method( &$jsonld, $product, $method = null ) {
174
+	private function add_shipping_details_with_shipping_method(&$jsonld, $product, $method = null) {
175 175
 
176
-		$offer_shipping_details = array( '@type' => 'OfferShippingDetails', );
177
-		$shipping_delivery_time = array( '@type' => 'ShippingDeliveryTime', );
176
+		$offer_shipping_details = array('@type' => 'OfferShippingDetails',);
177
+		$shipping_delivery_time = array('@type' => 'ShippingDeliveryTime',);
178 178
 
179
-		$this->add_shipping_destination( $offer_shipping_details );
179
+		$this->add_shipping_destination($offer_shipping_details);
180 180
 
181 181
 		/*
182 182
 		 * Use Case UC003
183 183
 		 * 1.4.3
184 184
 		 */
185
-		if ( isset( $method ) ) {
186
-			$method->add_shipping_rate( $offer_shipping_details );
187
-			$method->add_transit_time( $shipping_delivery_time );
185
+		if (isset($method)) {
186
+			$method->add_shipping_rate($offer_shipping_details);
187
+			$method->add_transit_time($shipping_delivery_time);
188 188
 		}
189 189
 
190 190
 		/*
191 191
 		 * Use Case UC004
192 192
 		 */
193
-		$product->add_handling_time( $shipping_delivery_time );
193
+		$product->add_handling_time($shipping_delivery_time);
194 194
 
195
-		$this->add_cutoff_time( $shipping_delivery_time );
196
-		$this->add_business_days( $shipping_delivery_time );
195
+		$this->add_cutoff_time($shipping_delivery_time);
196
+		$this->add_business_days($shipping_delivery_time);
197 197
 
198
-		if ( 1 < count( $shipping_delivery_time ) ) {
198
+		if (1 < count($shipping_delivery_time)) {
199 199
 			$offer_shipping_details['deliveryTime'] = $shipping_delivery_time;
200 200
 		}
201 201
 
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
 
204 204
 	}
205 205
 
206
-	private function make_sure_shipping_details_exists_and_it_is_an_array( &$jsonld ) {
206
+	private function make_sure_shipping_details_exists_and_it_is_an_array(&$jsonld) {
207 207
 
208
-		if ( ! isset( $jsonld['shippingDetails'] ) ) {
208
+		if ( ! isset($jsonld['shippingDetails'])) {
209 209
 			$jsonld['shippingDetails'] = array();
210 210
 		}
211 211
 
212
-		if ( ! is_array( $jsonld['shippingDetails'] ) ||
213
-		     ( ! empty( $jsonld['shippingDetails'] ) && ! is_numeric( key( $jsonld['shippingDetails'] ) ) ) ) {
214
-			$jsonld['shippingDetails'] = array( $jsonld['shippingDetails'] );
212
+		if ( ! is_array($jsonld['shippingDetails']) ||
213
+		     ( ! empty($jsonld['shippingDetails']) && ! is_numeric(key($jsonld['shippingDetails'])))) {
214
+			$jsonld['shippingDetails'] = array($jsonld['shippingDetails']);
215 215
 		}
216 216
 
217 217
 	}
218 218
 
219
-	private function add_shipping_destination( &$shipping_details ) {
219
+	private function add_shipping_destination(&$shipping_details) {
220 220
 
221
-		if ( ! isset( $this->country_code ) ) {
221
+		if ( ! isset($this->country_code)) {
222 222
 			return;
223 223
 		}
224 224
 
@@ -227,19 +227,19 @@  discard block
 block discarded – undo
227 227
 			'addressCountry' => $this->country_code,
228 228
 		);
229 229
 
230
-		$this->add_address_region( $shipping_destination );
231
-		$this->add_postal_code( $shipping_destination );
232
-		$this->add_postal_code_prefix( $shipping_destination );
233
-		$this->add_postal_code_range( $shipping_destination );
230
+		$this->add_address_region($shipping_destination);
231
+		$this->add_postal_code($shipping_destination);
232
+		$this->add_postal_code_prefix($shipping_destination);
233
+		$this->add_postal_code_range($shipping_destination);
234 234
 
235 235
 		$shipping_details['shippingDestination'] = $shipping_destination;
236 236
 
237 237
 
238 238
 	}
239 239
 
240
-	private function add_address_region( &$shipping_destination ) {
240
+	private function add_address_region(&$shipping_destination) {
241 241
 
242
-		if ( empty( $this->regions ) ) {
242
+		if (empty($this->regions)) {
243 243
 			return;
244 244
 		}
245 245
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 
248 248
 	}
249 249
 
250
-	private function add_postal_code( &$shipping_destination ) {
250
+	private function add_postal_code(&$shipping_destination) {
251 251
 
252
-		if ( empty( $this->postal_codes ) ) {
252
+		if (empty($this->postal_codes)) {
253 253
 			return;
254 254
 		}
255 255
 
@@ -257,27 +257,27 @@  discard block
 block discarded – undo
257 257
 
258 258
 	}
259 259
 
260
-	private function add_postal_code_prefix( &$shipping_destination ) {
260
+	private function add_postal_code_prefix(&$shipping_destination) {
261 261
 
262
-		if ( empty( $this->postal_code_prefixes ) ) {
262
+		if (empty($this->postal_code_prefixes)) {
263 263
 			return;
264 264
 		}
265 265
 
266
-		foreach ( $this->postal_code_prefixes as $postal_code_prefix ) {
267
-			$shipping_destination['postalCodePrefix'][] = substr( $postal_code_prefix, 0, - 1 );
266
+		foreach ($this->postal_code_prefixes as $postal_code_prefix) {
267
+			$shipping_destination['postalCodePrefix'][] = substr($postal_code_prefix, 0, - 1);
268 268
 		}
269 269
 
270 270
 	}
271 271
 
272
-	private function add_postal_code_range( &$shipping_destination ) {
272
+	private function add_postal_code_range(&$shipping_destination) {
273 273
 
274
-		if ( empty( $this->postal_code_ranges ) ) {
274
+		if (empty($this->postal_code_ranges)) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		$shipping_destination['postalCodeRanges'] = array();
279
-		foreach ( $this->postal_code_ranges as $post_code_range ) {
280
-			$range = explode( '...', $post_code_range );
279
+		foreach ($this->postal_code_ranges as $post_code_range) {
280
+			$range = explode('...', $post_code_range);
281 281
 
282 282
 			$shipping_destination['postalCodeRanges'][] = array(
283 283
 				'postalCodeBegin' => $range[0],
@@ -287,45 +287,45 @@  discard block
 block discarded – undo
287 287
 
288 288
 	}
289 289
 
290
-	public static function from_wc_shipping_zone( $wc_shipping_zone, $country_code = null ) {
290
+	public static function from_wc_shipping_zone($wc_shipping_zone, $country_code = null) {
291 291
 
292
-		return new self( $wc_shipping_zone, $country_code );
292
+		return new self($wc_shipping_zone, $country_code);
293 293
 	}
294 294
 
295
-	private function add_cutoff_time( &$shipping_delivery_time ) {
295
+	private function add_cutoff_time(&$shipping_delivery_time) {
296 296
 
297
-		$wpsso_options = get_option( 'wpsso_options' );
297
+		$wpsso_options = get_option('wpsso_options');
298 298
 
299
-		if ( empty( $wpsso_options['wcsdt_shipdept_cutoff'] )
300
-		     || empty( $wpsso_options['wcsdt_shipdept_timezone'] ) ) {
299
+		if (empty($wpsso_options['wcsdt_shipdept_cutoff'])
300
+		     || empty($wpsso_options['wcsdt_shipdept_timezone'])) {
301 301
 			return;
302 302
 		}
303 303
 
304 304
 		$cutoff_time = $wpsso_options['wcsdt_shipdept_cutoff'];
305 305
 
306
-		if ( 'none' !== $cutoff_time ) {
306
+		if ('none' !== $cutoff_time) {
307 307
 			$timezone = $wpsso_options['wcsdt_shipdept_timezone'];
308 308
 
309
-			$time   = new DateTime( 'now', new DateTimeZone( $timezone ) );
310
-			$offset = $time->format( 'P' );
309
+			$time   = new DateTime('now', new DateTimeZone($timezone));
310
+			$offset = $time->format('P');
311 311
 
312 312
 			$shipping_delivery_time['cutOffTime'] = "{$cutoff_time}{$offset}";
313 313
 		}
314 314
 
315 315
 	}
316 316
 
317
-	private function add_business_days( &$shipping_delivery_time ) {
317
+	private function add_business_days(&$shipping_delivery_time) {
318 318
 
319
-		$wpsso_options = get_option( 'wpsso_options' );
319
+		$wpsso_options = get_option('wpsso_options');
320 320
 
321 321
 		$day_of_week = array();
322 322
 		$prefix      = 'wcsdt_shipdept_day_';
323
-		foreach ( array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ) as $day ) {
324
-			$key = $prefix . strtolower( $day );
323
+		foreach (array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') as $day) {
324
+			$key = $prefix.strtolower($day);
325 325
 
326 326
 			if (
327
-				( empty( $wpsso_options["{$key}_open"] ) && empty( $wpsso_options["{$key}_close"] ) )
328
-				|| ( 'none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"] )
327
+				(empty($wpsso_options["{$key}_open"]) && empty($wpsso_options["{$key}_close"]))
328
+				|| ('none' === $wpsso_options["{$key}_open"] && 'none' === $wpsso_options["{$key}_close"])
329 329
 			) {
330 330
 				continue;
331 331
 			}
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 			$day_of_week[] = "https://schema.org/$day";
334 334
 		}
335 335
 
336
-		if ( ! empty( $day_of_week ) ) {
336
+		if ( ! empty($day_of_week)) {
337 337
 			$shipping_delivery_time['businessDays'] = array(
338 338
 				'@type'     => 'OpeningHoursSpecification',
339 339
 				'dayOfWeek' => $day_of_week,
Please login to merge, or discard this patch.
src/wordlift/videoobject/parser/class-classic-editor-parser.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,46 +7,46 @@
 block discarded – undo
7 7
 
8 8
 class Classic_Editor_Parser implements Parser {
9 9
 
10
-	public function get_videos( $post_id ) {
10
+    public function get_videos( $post_id ) {
11 11
 
12
-		$post = get_post( $post_id );
12
+        $post = get_post( $post_id );
13 13
 
14
-		$content = $post->post_content;
14
+        $content = $post->post_content;
15 15
 
16
-		$line_matches      = array();
17
-		$paragraph_matches = array();
16
+        $line_matches      = array();
17
+        $paragraph_matches = array();
18 18
 
19
-		/**
20
-		 * This replicates the wp autoembed function, instead of replacing we capture
21
-		 * all the urls.
22
-		 */
23
-		if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
24
-			// Find URLs on their own line.
25
-			preg_match_all( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER );
26
-			// Find URLs in their own paragraph.
27
-			preg_match_all( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER );
28
-		}
19
+        /**
20
+         * This replicates the wp autoembed function, instead of replacing we capture
21
+         * all the urls.
22
+         */
23
+        if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
24
+            // Find URLs on their own line.
25
+            preg_match_all( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER );
26
+            // Find URLs in their own paragraph.
27
+            preg_match_all( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER );
28
+        }
29 29
 
30
-		$regex_matches = array_merge( $line_matches, $paragraph_matches );
31
-		$matches = array_map( array( $this, 'get_url_from_match' ),  $regex_matches);
30
+        $regex_matches = array_merge( $line_matches, $paragraph_matches );
31
+        $matches = array_map( array( $this, 'get_url_from_match' ),  $regex_matches);
32 32
 
33
-		$matches = array_values( array_unique( array_filter( $matches ) ) );
33
+        $matches = array_values( array_unique( array_filter( $matches ) ) );
34 34
 
35
-		return array_map( array( $this, 'url_to_embedded_video_object' ), $matches );
36
-	}
35
+        return array_map( array( $this, 'url_to_embedded_video_object' ), $matches );
36
+    }
37 37
 
38 38
 
39
-	/**
40
-	 * @param $url
41
-	 *
42
-	 * @return Embedded_Video
43
-	 */
44
-	private static function url_to_embedded_video_object( $url ) {
45
-		return Embedded_Video_Factory::get_embedded_video( trim($url) );
46
-	}
39
+    /**
40
+     * @param $url
41
+     *
42
+     * @return Embedded_Video
43
+     */
44
+    private static function url_to_embedded_video_object( $url ) {
45
+        return Embedded_Video_Factory::get_embedded_video( trim($url) );
46
+    }
47 47
 
48
-	public static function get_url_from_match( $match ) {
49
-		return  array_key_exists( 0, $match ) ? $match[0] : false;
50
-	}
48
+    public static function get_url_from_match( $match ) {
49
+        return  array_key_exists( 0, $match ) ? $match[0] : false;
50
+    }
51 51
 
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 class Classic_Editor_Parser implements Parser {
9 9
 
10
-	public function get_videos( $post_id ) {
10
+	public function get_videos($post_id) {
11 11
 
12
-		$post = get_post( $post_id );
12
+		$post = get_post($post_id);
13 13
 
14 14
 		$content = $post->post_content;
15 15
 
@@ -20,19 +20,19 @@  discard block
 block discarded – undo
20 20
 		 * This replicates the wp autoembed function, instead of replacing we capture
21 21
 		 * all the urls.
22 22
 		 */
23
-		if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
23
+		if (preg_match('#(^|\s|>)https?://#i', $content)) {
24 24
 			// Find URLs on their own line.
25
-			preg_match_all( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER );
25
+			preg_match_all('|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER);
26 26
 			// Find URLs in their own paragraph.
27
-			preg_match_all( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER );
27
+			preg_match_all('|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER);
28 28
 		}
29 29
 
30
-		$regex_matches = array_merge( $line_matches, $paragraph_matches );
31
-		$matches = array_map( array( $this, 'get_url_from_match' ),  $regex_matches);
30
+		$regex_matches = array_merge($line_matches, $paragraph_matches);
31
+		$matches = array_map(array($this, 'get_url_from_match'), $regex_matches);
32 32
 
33
-		$matches = array_values( array_unique( array_filter( $matches ) ) );
33
+		$matches = array_values(array_unique(array_filter($matches)));
34 34
 
35
-		return array_map( array( $this, 'url_to_embedded_video_object' ), $matches );
35
+		return array_map(array($this, 'url_to_embedded_video_object'), $matches);
36 36
 	}
37 37
 
38 38
 
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return Embedded_Video
43 43
 	 */
44
-	private static function url_to_embedded_video_object( $url ) {
45
-		return Embedded_Video_Factory::get_embedded_video( trim($url) );
44
+	private static function url_to_embedded_video_object($url) {
45
+		return Embedded_Video_Factory::get_embedded_video(trim($url));
46 46
 	}
47 47
 
48
-	public static function get_url_from_match( $match ) {
49
-		return  array_key_exists( 0, $match ) ? $match[0] : false;
48
+	public static function get_url_from_match($match) {
49
+		return  array_key_exists(0, $match) ? $match[0] : false;
50 50
 	}
51 51
 
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/videoobject/parser/class-block-editor-parser.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,32 +10,32 @@
 block discarded – undo
10 10
  */
11 11
 class Block_Editor_Parser implements Parser {
12 12
 
13
-	public function get_videos( $post_id ) {
14
-		$post            = get_post( $post_id );
15
-		$content         = $post->post_content;
16
-		$video_blocks    = array_filter( parse_blocks( $content ), array( $this, 'filter_blocks' ) );
17
-		return array_map( array( $this, 'block_to_video' ), $video_blocks );
18
-	}
13
+    public function get_videos( $post_id ) {
14
+        $post            = get_post( $post_id );
15
+        $content         = $post->post_content;
16
+        $video_blocks    = array_filter( parse_blocks( $content ), array( $this, 'filter_blocks' ) );
17
+        return array_map( array( $this, 'block_to_video' ), $video_blocks );
18
+    }
19 19
 
20
-	/**
21
-	 * @param $block
22
-	 *
23
-	 * @return Embedded_Video
24
-	 */
25
-	public function block_to_video( $block ) {
26
-		return Embedded_Video_Factory::get_embedded_video( $block['attrs']['url'] );
27
-	}
20
+    /**
21
+     * @param $block
22
+     *
23
+     * @return Embedded_Video
24
+     */
25
+    public function block_to_video( $block ) {
26
+        return Embedded_Video_Factory::get_embedded_video( $block['attrs']['url'] );
27
+    }
28 28
 
29
-	public function filter_blocks( $block ) {
30
-		return array_key_exists( 'blockName', $block )
31
-		       && ( $block['blockName'] === 'core/embed' || $block['blockName'] === 'core-embed/youtube'
32
-		            || $block['blockName'] === 'core-embed/vimeo')
33
-		       // Check if attributes present
34
-		       && array_key_exists( 'attrs', $block )
35
-		       && is_array( $block['attrs'] )
36
-		       // check if valid url present.
37
-		       && array_key_exists( 'url', $block['attrs'] )
38
-		       && is_string( $block['attrs']['url'] );
39
-	}
29
+    public function filter_blocks( $block ) {
30
+        return array_key_exists( 'blockName', $block )
31
+               && ( $block['blockName'] === 'core/embed' || $block['blockName'] === 'core-embed/youtube'
32
+                    || $block['blockName'] === 'core-embed/vimeo')
33
+                // Check if attributes present
34
+               && array_key_exists( 'attrs', $block )
35
+               && is_array( $block['attrs'] )
36
+                // check if valid url present.
37
+               && array_key_exists( 'url', $block['attrs'] )
38
+               && is_string( $block['attrs']['url'] );
39
+    }
40 40
 
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Block_Editor_Parser implements Parser {
12 12
 
13
-	public function get_videos( $post_id ) {
14
-		$post            = get_post( $post_id );
13
+	public function get_videos($post_id) {
14
+		$post            = get_post($post_id);
15 15
 		$content         = $post->post_content;
16
-		$video_blocks    = array_filter( parse_blocks( $content ), array( $this, 'filter_blocks' ) );
17
-		return array_map( array( $this, 'block_to_video' ), $video_blocks );
16
+		$video_blocks    = array_filter(parse_blocks($content), array($this, 'filter_blocks'));
17
+		return array_map(array($this, 'block_to_video'), $video_blocks);
18 18
 	}
19 19
 
20 20
 	/**
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @return Embedded_Video
24 24
 	 */
25
-	public function block_to_video( $block ) {
26
-		return Embedded_Video_Factory::get_embedded_video( $block['attrs']['url'] );
25
+	public function block_to_video($block) {
26
+		return Embedded_Video_Factory::get_embedded_video($block['attrs']['url']);
27 27
 	}
28 28
 
29
-	public function filter_blocks( $block ) {
30
-		return array_key_exists( 'blockName', $block )
31
-		       && ( $block['blockName'] === 'core/embed' || $block['blockName'] === 'core-embed/youtube'
29
+	public function filter_blocks($block) {
30
+		return array_key_exists('blockName', $block)
31
+		       && ($block['blockName'] === 'core/embed' || $block['blockName'] === 'core-embed/youtube'
32 32
 		            || $block['blockName'] === 'core-embed/vimeo')
33 33
 		       // Check if attributes present
34
-		       && array_key_exists( 'attrs', $block )
35
-		       && is_array( $block['attrs'] )
34
+		       && array_key_exists('attrs', $block)
35
+		       && is_array($block['attrs'])
36 36
 		       // check if valid url present.
37
-		       && array_key_exists( 'url', $block['attrs'] )
38
-		       && is_string( $block['attrs']['url'] );
37
+		       && array_key_exists('url', $block['attrs'])
38
+		       && is_string($block['attrs']['url']);
39 39
 	}
40 40
 
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/vocabulary/data/term-data/class-default-term-data.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,31 +9,31 @@
 block discarded – undo
9 9
 
10 10
 class Default_Term_Data implements Term_Data {
11 11
 
12
-	/**
13
-	 * @var array An array of entities bound to the term.
14
-	 */
15
-	private $entities;
16
-	/**
17
-	 * @var \WP_Term
18
-	 */
19
-	private $term;
12
+    /**
13
+     * @var array An array of entities bound to the term.
14
+     */
15
+    private $entities;
16
+    /**
17
+     * @var \WP_Term
18
+     */
19
+    private $term;
20 20
 
21
-	public function __construct( $term, $entities ) {
22
-		$this->term     = $term;
23
-		$this->entities = $entities;
24
-	}
21
+    public function __construct( $term, $entities ) {
22
+        $this->term     = $term;
23
+        $this->entities = $entities;
24
+    }
25 25
 
26
-	public function get_data() {
26
+    public function get_data() {
27 27
 
28
-		return array(
29
-			'tagId'          => $this->term->term_id,
30
-			'tagName'        => $this->term->name,
31
-			'tagDescription' => $this->term->description,
32
-			// Before 4.5.0 taxonomy parameter **must** be passed to this function.
33
-			'tagLink'        => get_edit_term_link( $this->term->term_id, $this->term->taxonomy ),
34
-			'tagPostCount'   => $this->term->count,
35
-			'tagTaxonomy'    => get_taxonomy( $this->term->taxonomy )->label,
36
-			'entities'       => $this->entities,
37
-		);
38
-	}
28
+        return array(
29
+            'tagId'          => $this->term->term_id,
30
+            'tagName'        => $this->term->name,
31
+            'tagDescription' => $this->term->description,
32
+            // Before 4.5.0 taxonomy parameter **must** be passed to this function.
33
+            'tagLink'        => get_edit_term_link( $this->term->term_id, $this->term->taxonomy ),
34
+            'tagPostCount'   => $this->term->count,
35
+            'tagTaxonomy'    => get_taxonomy( $this->term->taxonomy )->label,
36
+            'entities'       => $this->entities,
37
+        );
38
+    }
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 */
19 19
 	private $term;
20 20
 
21
-	public function __construct( $term, $entities ) {
21
+	public function __construct($term, $entities) {
22 22
 		$this->term     = $term;
23 23
 		$this->entities = $entities;
24 24
 	}
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 			'tagName'        => $this->term->name,
31 31
 			'tagDescription' => $this->term->description,
32 32
 			// Before 4.5.0 taxonomy parameter **must** be passed to this function.
33
-			'tagLink'        => get_edit_term_link( $this->term->term_id, $this->term->taxonomy ),
33
+			'tagLink'        => get_edit_term_link($this->term->term_id, $this->term->taxonomy),
34 34
 			'tagPostCount'   => $this->term->count,
35
-			'tagTaxonomy'    => get_taxonomy( $this->term->taxonomy )->label,
35
+			'tagTaxonomy'    => get_taxonomy($this->term->taxonomy)->label,
36 36
 			'entities'       => $this->entities,
37 37
 		);
38 38
 	}
Please login to merge, or discard this patch.
src/wordlift/vocabulary/data/term-count/class-cached-term-count-manager.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
  */
10 10
 class Cached_Term_count_Manager {
11 11
 
12
-	public function connect_hook() {
12
+    public function connect_hook() {
13 13
 
14
-		add_action( 'wordlift_vocabulary_analysis_complete_for_terms_batch', function () {
15
-			delete_transient( Cached_Term_Count::TRANSIENT_KEY );
16
-		} );
14
+        add_action( 'wordlift_vocabulary_analysis_complete_for_terms_batch', function () {
15
+            delete_transient( Cached_Term_Count::TRANSIENT_KEY );
16
+        } );
17 17
 
18
-		$taxonomies = Terms_Compat::get_public_taxonomies();
19
-		foreach ( $taxonomies as $taxonomy ) {
20
-			add_action( "created_${taxonomy}", function () {
21
-				delete_transient( Cached_Term_Count::TRANSIENT_KEY );
22
-			} );
23
-		}
18
+        $taxonomies = Terms_Compat::get_public_taxonomies();
19
+        foreach ( $taxonomies as $taxonomy ) {
20
+            add_action( "created_${taxonomy}", function () {
21
+                delete_transient( Cached_Term_Count::TRANSIENT_KEY );
22
+            } );
23
+        }
24 24
 
25
-	}
25
+    }
26 26
 
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
 
12 12
 	public function connect_hook() {
13 13
 
14
-		add_action( 'wordlift_vocabulary_analysis_complete_for_terms_batch', function () {
15
-			delete_transient( Cached_Term_Count::TRANSIENT_KEY );
14
+		add_action('wordlift_vocabulary_analysis_complete_for_terms_batch', function() {
15
+			delete_transient(Cached_Term_Count::TRANSIENT_KEY);
16 16
 		} );
17 17
 
18 18
 		$taxonomies = Terms_Compat::get_public_taxonomies();
19
-		foreach ( $taxonomies as $taxonomy ) {
20
-			add_action( "created_${taxonomy}", function () {
21
-				delete_transient( Cached_Term_Count::TRANSIENT_KEY );
19
+		foreach ($taxonomies as $taxonomy) {
20
+			add_action("created_${taxonomy}", function() {
21
+				delete_transient(Cached_Term_Count::TRANSIENT_KEY);
22 22
 			} );
23 23
 		}
24 24
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/data/term-count/class-default-term-count.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,28 +13,28 @@
 block discarded – undo
13 13
  */
14 14
 class Default_Term_Count implements Term_Count {
15 15
 
16
-	/**
17
-	 * Return count of terms which have entities and also not matched by editor, currently
18
-	 * it is used for the menu icon badge.
19
-	 * @return int
20
-	 */
21
-	public function get_term_count() {
22
-		return count( Terms_Compat::get_terms( Terms_Compat::get_public_taxonomies(), array(
23
-			'hide_empty' => false,
24
-			'fields'     => 'ids',
25
-			'meta_query' => array(
26
-				array(
27
-					'key'     => Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING,
28
-					'compare' => 'NOT EXISTS',
29
-				),
30
-				array(
31
-					'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
32
-					'compare' => 'EXISTS'
33
-				)
34
-			),
35
-		) ) );
36
-
37
-	}
16
+    /**
17
+     * Return count of terms which have entities and also not matched by editor, currently
18
+     * it is used for the menu icon badge.
19
+     * @return int
20
+     */
21
+    public function get_term_count() {
22
+        return count( Terms_Compat::get_terms( Terms_Compat::get_public_taxonomies(), array(
23
+            'hide_empty' => false,
24
+            'fields'     => 'ids',
25
+            'meta_query' => array(
26
+                array(
27
+                    'key'     => Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING,
28
+                    'compare' => 'NOT EXISTS',
29
+                ),
30
+                array(
31
+                    'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
32
+                    'compare' => 'EXISTS'
33
+                )
34
+            ),
35
+        ) ) );
36
+
37
+    }
38 38
 
39 39
 
40 40
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @return int
20 20
 	 */
21 21
 	public function get_term_count() {
22
-		return count( Terms_Compat::get_terms( Terms_Compat::get_public_taxonomies(), array(
22
+		return count(Terms_Compat::get_terms(Terms_Compat::get_public_taxonomies(), array(
23 23
 			'hide_empty' => false,
24 24
 			'fields'     => 'ids',
25 25
 			'meta_query' => array(
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 					'compare' => 'EXISTS'
33 33
 				)
34 34
 			),
35
-		) ) );
35
+		)));
36 36
 
37 37
 	}
38 38
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/data/entity-list/class-default-entity-list.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,162 +9,162 @@
 block discarded – undo
9 9
  */
10 10
 class Default_Entity_List extends Entity_List {
11 11
 
12
-	const META_KEY = '_wl_vocabulary_entity_match_for_term';
13
-
14
-	/**
15
-	 * @var Legacy_Entity_List
16
-	 */
17
-	private $legacy_entity;
18
-
19
-	/**
20
-	 * Default_Entity constructor.
21
-	 *
22
-	 * @param $term_id int
23
-	 * @param $legacy_entity Legacy_Entity_List
24
-	 */
25
-	public function __construct( $term_id, $legacy_entity ) {
26
-		parent::__construct( $term_id );
27
-		$this->legacy_entity = $legacy_entity;
28
-	}
29
-
30
-	/**
31
-	 * @param $values
32
-	 *
33
-	 * @return array
34
-	 */
35
-	private static function extract_jsonld_values( $values ) {
36
-		return array_map( function ( $value ) {
37
-			if ( ! is_array($value) || ! array_key_exists( '@value', $value ) ) {
38
-				return $value;
39
-			}
40
-
41
-			return $value['@value'];
42
-		}, $values );
43
-	}
44
-
45
-	/**
46
-	 * Check if the key exists and value is array.
47
-	 *
48
-	 * @param $entity_data
49
-	 *
50
-	 * @return bool
51
-	 */
52
-	private static function is_value_array( $key, $entity_data ) {
53
-		return array_key_exists( $key, $entity_data ) && is_array( $entity_data[ $key ] );
54
-	}
55
-
56
-	public function get_jsonld_data() {
57
-		$default_data = get_term_meta( $this->term_id, self::META_KEY );
58
-		if ( is_array( $default_data ) && $default_data ) {
59
-			return $default_data;
60
-		}
61
-
62
-		// Use legacy entity if the data doesnt exist on that key.
63
-		return $this->legacy_entity->get_jsonld_data();
64
-	}
65
-
66
-	public function save_jsonld_data( $entity_data ) {
67
-
68
-		$entity_id = $entity_data['@id'];
69
-
70
-		if ( $entity_id ) {
71
-			$entity_data['sameAs'] = array_merge( $entity_data['sameAs'], array( $entity_id ) );
72
-		}
73
-
74
-		$entity_list = get_term_meta( $this->term_id, self::META_KEY );
75
-
76
-		$entity_list[] = $this->compact_jsonld( $this->filter_entity_data( $entity_data ) );
77
-
78
-		$this->clear_and_save_list( $entity_list );
79
-
80
-	}
81
-
82
-	public function clear_data() {
83
-		delete_term_meta( $this->term_id, self::META_KEY );
84
-	}
85
-
86
-
87
-	public function remove_entity_by_id( $entity_id ) {
88
-		$entity_list = get_term_meta( $this->term_id, self::META_KEY );
89
-		foreach ( $entity_list as $key => $entity ) {
90
-			$same_as = $entity['sameAs'];
91
-			if ( in_array( $entity_id, $same_as ) ) {
92
-				// since entity ids are unique, we break after finding the first instance.
93
-				unset( $entity_list[ $key ] );
94
-				break;
95
-			}
96
-		}
97
-		$this->clear_and_save_list( $entity_list );
98
-
99
-	}
100
-
101
-	/**
102
-	 * @param $entity_list
103
-	 */
104
-	private function save_entity_list( $entity_list ) {
105
-		foreach ( $entity_list as $single_entity ) {
106
-			add_term_meta( $this->term_id, self::META_KEY, $single_entity );
107
-		}
108
-	}
109
-
110
-	/**
111
-	 * @param $entity_list
112
-	 */
113
-	private function clear_and_save_list( $entity_list ) {
114
-		// Clear all data and add the new one.
115
-		$this->clear_data();
116
-		$this->save_entity_list( $entity_list );
117
-	}
118
-
119
-
120
-	/**
121
-	 * For now support only these properties.
122
-	 *
123
-	 * @param $entity_data
124
-	 *
125
-	 * @return array
126
-	 */
127
-	private function filter_entity_data( $entity_data ) {
128
-		$allowed_keys = array( '@id', 'description', 'sameAs', '@type', 'name' );
129
-		$data         = array();
130
-		foreach ( $entity_data as $key => $value ) {
131
-			if ( in_array( $key, $allowed_keys ) ) {
132
-				$data[ $key ] = $value;
133
-			}
134
-		}
135
-
136
-		return $data;
137
-	}
138
-
139
-
140
-	public static function compact_jsonld( $entity_data ) {
141
-
142
-		if ( self::is_value_array( '@type', $entity_data ) ) {
143
-			$entity_data['@type'] = array_map( function ( $type ) {
144
-				return str_replace( "http://schema.org/", "", $type );
145
-			}, $entity_data['@type'] );
146
-		}
147
-
148
-		if ( self::is_value_array( 'description', $entity_data ) ) {
149
-			$entity_data['description'] = self::extract_jsonld_values( $entity_data['description'] );
150
-		}
151
-
152
-
153
-		if ( self::is_value_array( 'name', $entity_data ) ) {
154
-			$entity_data['name'] = self::extract_jsonld_values( $entity_data['name'] );
155
-		}
156
-
157
-
158
-		if ( self::is_value_array( 'sameAs', $entity_data ) ) {
159
-			$entity_data['sameAs'] = array_map( function ( $sameas ) {
160
-				if ( ! is_array($sameas) || ! array_key_exists( '@id', $sameas ) ) {
161
-					return $sameas;
162
-				}
163
-				return $sameas['@id'];
164
-			}, $entity_data['sameAs'] );
165
-		}
166
-
12
+    const META_KEY = '_wl_vocabulary_entity_match_for_term';
13
+
14
+    /**
15
+     * @var Legacy_Entity_List
16
+     */
17
+    private $legacy_entity;
18
+
19
+    /**
20
+     * Default_Entity constructor.
21
+     *
22
+     * @param $term_id int
23
+     * @param $legacy_entity Legacy_Entity_List
24
+     */
25
+    public function __construct( $term_id, $legacy_entity ) {
26
+        parent::__construct( $term_id );
27
+        $this->legacy_entity = $legacy_entity;
28
+    }
29
+
30
+    /**
31
+     * @param $values
32
+     *
33
+     * @return array
34
+     */
35
+    private static function extract_jsonld_values( $values ) {
36
+        return array_map( function ( $value ) {
37
+            if ( ! is_array($value) || ! array_key_exists( '@value', $value ) ) {
38
+                return $value;
39
+            }
40
+
41
+            return $value['@value'];
42
+        }, $values );
43
+    }
44
+
45
+    /**
46
+     * Check if the key exists and value is array.
47
+     *
48
+     * @param $entity_data
49
+     *
50
+     * @return bool
51
+     */
52
+    private static function is_value_array( $key, $entity_data ) {
53
+        return array_key_exists( $key, $entity_data ) && is_array( $entity_data[ $key ] );
54
+    }
55
+
56
+    public function get_jsonld_data() {
57
+        $default_data = get_term_meta( $this->term_id, self::META_KEY );
58
+        if ( is_array( $default_data ) && $default_data ) {
59
+            return $default_data;
60
+        }
61
+
62
+        // Use legacy entity if the data doesnt exist on that key.
63
+        return $this->legacy_entity->get_jsonld_data();
64
+    }
65
+
66
+    public function save_jsonld_data( $entity_data ) {
67
+
68
+        $entity_id = $entity_data['@id'];
69
+
70
+        if ( $entity_id ) {
71
+            $entity_data['sameAs'] = array_merge( $entity_data['sameAs'], array( $entity_id ) );
72
+        }
73
+
74
+        $entity_list = get_term_meta( $this->term_id, self::META_KEY );
75
+
76
+        $entity_list[] = $this->compact_jsonld( $this->filter_entity_data( $entity_data ) );
77
+
78
+        $this->clear_and_save_list( $entity_list );
79
+
80
+    }
81
+
82
+    public function clear_data() {
83
+        delete_term_meta( $this->term_id, self::META_KEY );
84
+    }
85
+
86
+
87
+    public function remove_entity_by_id( $entity_id ) {
88
+        $entity_list = get_term_meta( $this->term_id, self::META_KEY );
89
+        foreach ( $entity_list as $key => $entity ) {
90
+            $same_as = $entity['sameAs'];
91
+            if ( in_array( $entity_id, $same_as ) ) {
92
+                // since entity ids are unique, we break after finding the first instance.
93
+                unset( $entity_list[ $key ] );
94
+                break;
95
+            }
96
+        }
97
+        $this->clear_and_save_list( $entity_list );
98
+
99
+    }
100
+
101
+    /**
102
+     * @param $entity_list
103
+     */
104
+    private function save_entity_list( $entity_list ) {
105
+        foreach ( $entity_list as $single_entity ) {
106
+            add_term_meta( $this->term_id, self::META_KEY, $single_entity );
107
+        }
108
+    }
109
+
110
+    /**
111
+     * @param $entity_list
112
+     */
113
+    private function clear_and_save_list( $entity_list ) {
114
+        // Clear all data and add the new one.
115
+        $this->clear_data();
116
+        $this->save_entity_list( $entity_list );
117
+    }
118
+
119
+
120
+    /**
121
+     * For now support only these properties.
122
+     *
123
+     * @param $entity_data
124
+     *
125
+     * @return array
126
+     */
127
+    private function filter_entity_data( $entity_data ) {
128
+        $allowed_keys = array( '@id', 'description', 'sameAs', '@type', 'name' );
129
+        $data         = array();
130
+        foreach ( $entity_data as $key => $value ) {
131
+            if ( in_array( $key, $allowed_keys ) ) {
132
+                $data[ $key ] = $value;
133
+            }
134
+        }
135
+
136
+        return $data;
137
+    }
138
+
139
+
140
+    public static function compact_jsonld( $entity_data ) {
141
+
142
+        if ( self::is_value_array( '@type', $entity_data ) ) {
143
+            $entity_data['@type'] = array_map( function ( $type ) {
144
+                return str_replace( "http://schema.org/", "", $type );
145
+            }, $entity_data['@type'] );
146
+        }
147
+
148
+        if ( self::is_value_array( 'description', $entity_data ) ) {
149
+            $entity_data['description'] = self::extract_jsonld_values( $entity_data['description'] );
150
+        }
151
+
152
+
153
+        if ( self::is_value_array( 'name', $entity_data ) ) {
154
+            $entity_data['name'] = self::extract_jsonld_values( $entity_data['name'] );
155
+        }
156
+
157
+
158
+        if ( self::is_value_array( 'sameAs', $entity_data ) ) {
159
+            $entity_data['sameAs'] = array_map( function ( $sameas ) {
160
+                if ( ! is_array($sameas) || ! array_key_exists( '@id', $sameas ) ) {
161
+                    return $sameas;
162
+                }
163
+                return $sameas['@id'];
164
+            }, $entity_data['sameAs'] );
165
+        }
166
+
167 167
 
168
-		return $entity_data;
169
-	}
168
+        return $entity_data;
169
+    }
170 170
 }
171 171
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	 * @param $term_id int
23 23
 	 * @param $legacy_entity Legacy_Entity_List
24 24
 	 */
25
-	public function __construct( $term_id, $legacy_entity ) {
26
-		parent::__construct( $term_id );
25
+	public function __construct($term_id, $legacy_entity) {
26
+		parent::__construct($term_id);
27 27
 		$this->legacy_entity = $legacy_entity;
28 28
 	}
29 29
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return array
34 34
 	 */
35
-	private static function extract_jsonld_values( $values ) {
36
-		return array_map( function ( $value ) {
37
-			if ( ! is_array($value) || ! array_key_exists( '@value', $value ) ) {
35
+	private static function extract_jsonld_values($values) {
36
+		return array_map(function($value) {
37
+			if ( ! is_array($value) || ! array_key_exists('@value', $value)) {
38 38
 				return $value;
39 39
 			}
40 40
 
41 41
 			return $value['@value'];
42
-		}, $values );
42
+		}, $values);
43 43
 	}
44 44
 
45 45
 	/**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @return bool
51 51
 	 */
52
-	private static function is_value_array( $key, $entity_data ) {
53
-		return array_key_exists( $key, $entity_data ) && is_array( $entity_data[ $key ] );
52
+	private static function is_value_array($key, $entity_data) {
53
+		return array_key_exists($key, $entity_data) && is_array($entity_data[$key]);
54 54
 	}
55 55
 
56 56
 	public function get_jsonld_data() {
57
-		$default_data = get_term_meta( $this->term_id, self::META_KEY );
58
-		if ( is_array( $default_data ) && $default_data ) {
57
+		$default_data = get_term_meta($this->term_id, self::META_KEY);
58
+		if (is_array($default_data) && $default_data) {
59 59
 			return $default_data;
60 60
 		}
61 61
 
@@ -63,57 +63,57 @@  discard block
 block discarded – undo
63 63
 		return $this->legacy_entity->get_jsonld_data();
64 64
 	}
65 65
 
66
-	public function save_jsonld_data( $entity_data ) {
66
+	public function save_jsonld_data($entity_data) {
67 67
 
68 68
 		$entity_id = $entity_data['@id'];
69 69
 
70
-		if ( $entity_id ) {
71
-			$entity_data['sameAs'] = array_merge( $entity_data['sameAs'], array( $entity_id ) );
70
+		if ($entity_id) {
71
+			$entity_data['sameAs'] = array_merge($entity_data['sameAs'], array($entity_id));
72 72
 		}
73 73
 
74
-		$entity_list = get_term_meta( $this->term_id, self::META_KEY );
74
+		$entity_list = get_term_meta($this->term_id, self::META_KEY);
75 75
 
76
-		$entity_list[] = $this->compact_jsonld( $this->filter_entity_data( $entity_data ) );
76
+		$entity_list[] = $this->compact_jsonld($this->filter_entity_data($entity_data));
77 77
 
78
-		$this->clear_and_save_list( $entity_list );
78
+		$this->clear_and_save_list($entity_list);
79 79
 
80 80
 	}
81 81
 
82 82
 	public function clear_data() {
83
-		delete_term_meta( $this->term_id, self::META_KEY );
83
+		delete_term_meta($this->term_id, self::META_KEY);
84 84
 	}
85 85
 
86 86
 
87
-	public function remove_entity_by_id( $entity_id ) {
88
-		$entity_list = get_term_meta( $this->term_id, self::META_KEY );
89
-		foreach ( $entity_list as $key => $entity ) {
87
+	public function remove_entity_by_id($entity_id) {
88
+		$entity_list = get_term_meta($this->term_id, self::META_KEY);
89
+		foreach ($entity_list as $key => $entity) {
90 90
 			$same_as = $entity['sameAs'];
91
-			if ( in_array( $entity_id, $same_as ) ) {
91
+			if (in_array($entity_id, $same_as)) {
92 92
 				// since entity ids are unique, we break after finding the first instance.
93
-				unset( $entity_list[ $key ] );
93
+				unset($entity_list[$key]);
94 94
 				break;
95 95
 			}
96 96
 		}
97
-		$this->clear_and_save_list( $entity_list );
97
+		$this->clear_and_save_list($entity_list);
98 98
 
99 99
 	}
100 100
 
101 101
 	/**
102 102
 	 * @param $entity_list
103 103
 	 */
104
-	private function save_entity_list( $entity_list ) {
105
-		foreach ( $entity_list as $single_entity ) {
106
-			add_term_meta( $this->term_id, self::META_KEY, $single_entity );
104
+	private function save_entity_list($entity_list) {
105
+		foreach ($entity_list as $single_entity) {
106
+			add_term_meta($this->term_id, self::META_KEY, $single_entity);
107 107
 		}
108 108
 	}
109 109
 
110 110
 	/**
111 111
 	 * @param $entity_list
112 112
 	 */
113
-	private function clear_and_save_list( $entity_list ) {
113
+	private function clear_and_save_list($entity_list) {
114 114
 		// Clear all data and add the new one.
115 115
 		$this->clear_data();
116
-		$this->save_entity_list( $entity_list );
116
+		$this->save_entity_list($entity_list);
117 117
 	}
118 118
 
119 119
 
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return array
126 126
 	 */
127
-	private function filter_entity_data( $entity_data ) {
128
-		$allowed_keys = array( '@id', 'description', 'sameAs', '@type', 'name' );
127
+	private function filter_entity_data($entity_data) {
128
+		$allowed_keys = array('@id', 'description', 'sameAs', '@type', 'name');
129 129
 		$data         = array();
130
-		foreach ( $entity_data as $key => $value ) {
131
-			if ( in_array( $key, $allowed_keys ) ) {
132
-				$data[ $key ] = $value;
130
+		foreach ($entity_data as $key => $value) {
131
+			if (in_array($key, $allowed_keys)) {
132
+				$data[$key] = $value;
133 133
 			}
134 134
 		}
135 135
 
@@ -137,31 +137,31 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 
140
-	public static function compact_jsonld( $entity_data ) {
140
+	public static function compact_jsonld($entity_data) {
141 141
 
142
-		if ( self::is_value_array( '@type', $entity_data ) ) {
143
-			$entity_data['@type'] = array_map( function ( $type ) {
144
-				return str_replace( "http://schema.org/", "", $type );
145
-			}, $entity_data['@type'] );
142
+		if (self::is_value_array('@type', $entity_data)) {
143
+			$entity_data['@type'] = array_map(function($type) {
144
+				return str_replace("http://schema.org/", "", $type);
145
+			}, $entity_data['@type']);
146 146
 		}
147 147
 
148
-		if ( self::is_value_array( 'description', $entity_data ) ) {
149
-			$entity_data['description'] = self::extract_jsonld_values( $entity_data['description'] );
148
+		if (self::is_value_array('description', $entity_data)) {
149
+			$entity_data['description'] = self::extract_jsonld_values($entity_data['description']);
150 150
 		}
151 151
 
152 152
 
153
-		if ( self::is_value_array( 'name', $entity_data ) ) {
154
-			$entity_data['name'] = self::extract_jsonld_values( $entity_data['name'] );
153
+		if (self::is_value_array('name', $entity_data)) {
154
+			$entity_data['name'] = self::extract_jsonld_values($entity_data['name']);
155 155
 		}
156 156
 
157 157
 
158
-		if ( self::is_value_array( 'sameAs', $entity_data ) ) {
159
-			$entity_data['sameAs'] = array_map( function ( $sameas ) {
160
-				if ( ! is_array($sameas) || ! array_key_exists( '@id', $sameas ) ) {
158
+		if (self::is_value_array('sameAs', $entity_data)) {
159
+			$entity_data['sameAs'] = array_map(function($sameas) {
160
+				if ( ! is_array($sameas) || ! array_key_exists('@id', $sameas)) {
161 161
 					return $sameas;
162 162
 				}
163 163
 				return $sameas['@id'];
164
-			}, $entity_data['sameAs'] );
164
+			}, $entity_data['sameAs']);
165 165
 		}
166 166
 
167 167
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/hooks/class-tag-created-hook.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
 
8 8
 class Tag_Created_Hook {
9 9
 
10
-	/**
11
-	 * @var $analysis_background_service Analysis_Background_Service
12
-	 */
13
-	private $analysis_background_service;
10
+    /**
11
+     * @var $analysis_background_service Analysis_Background_Service
12
+     */
13
+    private $analysis_background_service;
14 14
 
15
-	/**
16
-	 * Tag_Created_Hook constructor.
17
-	 *
18
-	 * @param $analysis_background_service Analysis_Background_Service
19
-	 */
20
-	public function __construct( $analysis_background_service ) {
21
-		$this->analysis_background_service = $analysis_background_service;
22
-		$taxonomies = Terms_Compat::get_public_taxonomies();
23
-		foreach ( $taxonomies as $taxonomy ) {
24
-			add_action( "created_${taxonomy}", array( $this, 'created_term' ) );
25
-		}
26
-	}
15
+    /**
16
+     * Tag_Created_Hook constructor.
17
+     *
18
+     * @param $analysis_background_service Analysis_Background_Service
19
+     */
20
+    public function __construct( $analysis_background_service ) {
21
+        $this->analysis_background_service = $analysis_background_service;
22
+        $taxonomies = Terms_Compat::get_public_taxonomies();
23
+        foreach ( $taxonomies as $taxonomy ) {
24
+            add_action( "created_${taxonomy}", array( $this, 'created_term' ) );
25
+        }
26
+    }
27 27
 
28
-	public function created_term() {
29
-		$this->analysis_background_service->start();
30
-	}
28
+    public function created_term() {
29
+        $this->analysis_background_service->start();
30
+    }
31 31
 
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
 	 *
18 18
 	 * @param $analysis_background_service Analysis_Background_Service
19 19
 	 */
20
-	public function __construct( $analysis_background_service ) {
20
+	public function __construct($analysis_background_service) {
21 21
 		$this->analysis_background_service = $analysis_background_service;
22 22
 		$taxonomies = Terms_Compat::get_public_taxonomies();
23
-		foreach ( $taxonomies as $taxonomy ) {
24
-			add_action( "created_${taxonomy}", array( $this, 'created_term' ) );
23
+		foreach ($taxonomies as $taxonomy) {
24
+			add_action("created_${taxonomy}", array($this, 'created_term'));
25 25
 		}
26 26
 	}
27 27
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-reconcile-progress-endpoint.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,66 +15,66 @@
 block discarded – undo
15 15
  */
16 16
 class Reconcile_Progress_Endpoint {
17 17
 
18
-	public function register_routes() {
19
-		$that = $this;
20
-		add_action( 'rest_api_init',
21
-			function () use ( $that ) {
22
-				$that->register_progress_route();
23
-			} );
24
-	}
18
+    public function register_routes() {
19
+        $that = $this;
20
+        add_action( 'rest_api_init',
21
+            function () use ( $that ) {
22
+                $that->register_progress_route();
23
+            } );
24
+    }
25 25
 
26 26
 
27
-	public function progress() {
27
+    public function progress() {
28 28
 
29
-		$total_tags = count( Terms_Compat::get_terms( Terms_Compat::get_public_taxonomies(), array(
30
-			'hide_empty' => false,
31
-			'fields'     => 'ids',
32
-			'meta_query' => array(
33
-				array(
34
-					'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
35
-					'compare' => '=',
36
-					'value'   => '1'
37
-				)
38
-			),
39
-		) ) );
29
+        $total_tags = count( Terms_Compat::get_terms( Terms_Compat::get_public_taxonomies(), array(
30
+            'hide_empty' => false,
31
+            'fields'     => 'ids',
32
+            'meta_query' => array(
33
+                array(
34
+                    'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
35
+                    'compare' => '=',
36
+                    'value'   => '1'
37
+                )
38
+            ),
39
+        ) ) );
40 40
 
41
-		$completed = count( Terms_Compat::get_terms(
42
-			Terms_Compat::get_public_taxonomies(),
43
-			array(
44
-				'hide_empty' => false,
45
-				'fields'     => 'ids',
46
-				'meta_query' => array(
47
-					array(
48
-						'key'     => Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING,
49
-						'compare' => '=',
50
-						'value'   => '1'
51
-					)
52
-				),
53
-			)
54
-		)
55
-		);
41
+        $completed = count( Terms_Compat::get_terms(
42
+            Terms_Compat::get_public_taxonomies(),
43
+            array(
44
+                'hide_empty' => false,
45
+                'fields'     => 'ids',
46
+                'meta_query' => array(
47
+                    array(
48
+                        'key'     => Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING,
49
+                        'compare' => '=',
50
+                        'value'   => '1'
51
+                    )
52
+                ),
53
+            )
54
+        )
55
+        );
56 56
 
57 57
 
58
-		return array(
59
-			'completed' => $completed,
60
-			'total'     => $total_tags
61
-		);
62
-	}
58
+        return array(
59
+            'completed' => $completed,
60
+            'total'     => $total_tags
61
+        );
62
+    }
63 63
 
64 64
 
65
-	private function register_progress_route() {
66
-		register_rest_route(
67
-			Api_Config::REST_NAMESPACE,
68
-			'/reconcile_progress/progress',
69
-			array(
70
-				'methods'             => \WP_REST_Server::CREATABLE,
71
-				'callback'            => array( $this, 'progress' ),
72
-				'permission_callback' => function () {
73
-					return current_user_can( 'manage_options' );
74
-				},
75
-			)
76
-		);
77
-	}
65
+    private function register_progress_route() {
66
+        register_rest_route(
67
+            Api_Config::REST_NAMESPACE,
68
+            '/reconcile_progress/progress',
69
+            array(
70
+                'methods'             => \WP_REST_Server::CREATABLE,
71
+                'callback'            => array( $this, 'progress' ),
72
+                'permission_callback' => function () {
73
+                    return current_user_can( 'manage_options' );
74
+                },
75
+            )
76
+        );
77
+    }
78 78
 
79 79
 
80 80
 }
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function register_routes() {
19 19
 		$that = $this;
20
-		add_action( 'rest_api_init',
21
-			function () use ( $that ) {
20
+		add_action('rest_api_init',
21
+			function() use ($that) {
22 22
 				$that->register_progress_route();
23 23
 			} );
24 24
 	}
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function progress() {
28 28
 
29
-		$total_tags = count( Terms_Compat::get_terms( Terms_Compat::get_public_taxonomies(), array(
29
+		$total_tags = count(Terms_Compat::get_terms(Terms_Compat::get_public_taxonomies(), array(
30 30
 			'hide_empty' => false,
31 31
 			'fields'     => 'ids',
32 32
 			'meta_query' => array(
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					'value'   => '1'
37 37
 				)
38 38
 			),
39
-		) ) );
39
+		)));
40 40
 
41
-		$completed = count( Terms_Compat::get_terms(
41
+		$completed = count(Terms_Compat::get_terms(
42 42
 			Terms_Compat::get_public_taxonomies(),
43 43
 			array(
44 44
 				'hide_empty' => false,
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 			'/reconcile_progress/progress',
69 69
 			array(
70 70
 				'methods'             => \WP_REST_Server::CREATABLE,
71
-				'callback'            => array( $this, 'progress' ),
72
-				'permission_callback' => function () {
73
-					return current_user_can( 'manage_options' );
71
+				'callback'            => array($this, 'progress'),
72
+				'permission_callback' => function() {
73
+					return current_user_can('manage_options');
74 74
 				},
75 75
 			)
76 76
 		);
Please login to merge, or discard this patch.