Completed
Push — develop ( bfde1a...07de1c )
by David
03:08
created

Shipping_Method::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Wordlift\Shipping_Data;
5
6
7
use WC_Shipping_Method;
8
9
class Shipping_Method {
10
11
	/**
12
	 * @var WC_Shipping_Method $wc_shipping_method
13
	 */
14
	protected $wc_shipping_method;
15
16
	/**
17
	 * Shipping_Method constructor.
18
	 *
19
	 * @param WC_Shipping_Method $wc_shipping_method
20
	 */
21
	public function __construct( $wc_shipping_method ) {
22
		$this->wc_shipping_method = $wc_shipping_method;
23
	}
24
25
	/**
26
	 * @param WC_Shipping_Method $wc_shipping_method
27
	 *
28
	 * @return Shipping_Method
29
	 */
30
	public static function from_wc_shipping_method( $wc_shipping_method ) {
31
32
		switch ( get_class( $wc_shipping_method ) ) {
33
			case 'WC_Shipping_Local_Pickup':
34
				return new Local_Pickup_Shipping_Method( $wc_shipping_method );
35
36
			case 'WC_Shipping_Flat_Rate':
37
				return new Flat_Rate_Shipping_Method( $wc_shipping_method );
38
39
			case 'WC_Shipping_Free_Shipping':
40
				return new Free_Shipping_Shipping_Method( $wc_shipping_method );
41
42
			default:
43
				return new self( $wc_shipping_method );
44
		}
45
46
	}
47
48
	public function add_available_delivery_method( &$jsonld ) {
49
50
	}
51
52
}