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

Shipping_Method   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A from_wc_shipping_method() 0 17 4
A add_available_delivery_method() 0 3 1
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
}