Code Duplication    Length = 19-19 lines in 3 locations

src/wordlift/shipping-data/class-flat-rate-shipping-method.php 1 location

@@ 7-25 (lines=19) @@
4
namespace Wordlift\Shipping_Data;
5
6
7
class Flat_Rate_Shipping_Method extends Shipping_Method {
8
9
	public function add_available_delivery_method( &$jsonld ) {
10
11
		if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) {
12
			$jsonld['availableDeliveryMethod'] = array();
13
		}
14
15
		if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) {
16
			$jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] );
17
		}
18
19
		if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) {
20
			array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' );
21
		}
22
23
	}
24
25
}
26

src/wordlift/shipping-data/class-free-shipping-shipping-method.php 1 location

@@ 7-25 (lines=19) @@
4
namespace Wordlift\Shipping_Data;
5
6
7
class Free_Shipping_Shipping_Method extends Shipping_Method {
8
9
	public function add_available_delivery_method( &$jsonld ) {
10
11
		if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) {
12
			$jsonld['availableDeliveryMethod'] = array();
13
		}
14
15
		if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) {
16
			$jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] );
17
		}
18
19
		if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'] ) ) {
20
			array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' );
21
		}
22
23
	}
24
25
}
26

src/wordlift/shipping-data/class-local-pickup-shipping-method.php 1 location

@@ 7-25 (lines=19) @@
4
namespace Wordlift\Shipping_Data;
5
6
7
class Local_Pickup_Shipping_Method extends Shipping_Method {
8
9
	public function add_available_delivery_method( &$jsonld ) {
10
11
		if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) {
12
			$jsonld['availableDeliveryMethod'] = array();
13
		}
14
15
		if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) {
16
			$jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] );
17
		}
18
19
		if ( ! in_array( 'OnSitePickup', $jsonld['availableDeliveryMethod'] ) ) {
20
			array_push( $jsonld['availableDeliveryMethod'], 'OnSitePickup' );
21
		}
22
23
	}
24
25
}
26