ProductTypes   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 48
ccs 0
cts 12
cp 0
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 12 5
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\PayNL;
4
5
use Pronamic\WordPress\Pay\Payments\PaymentLineType;
6
7
/**
8
 * Product types.
9
 *
10
 * @author  Remco Tolsma
11
 * @version 2.0.1
12
 * @since   1.0.0
13
 * @see     https://admin.pay.nl/docpanel/api
14
 */
15
class ProductTypes {
16
	/**
17
	 * Article.
18
	 *
19
	 * @var string
20
	 */
21
	const ARTICLE = 'ARTICLE';
22
23
	/**
24
	 * Shipping.
25
	 *
26
	 * @var string
27
	 */
28
	const SHIPPING = 'SHIPPING';
29
30
	/**
31
	 * Handling.
32
	 *
33
	 * @var string
34
	 */
35
	const HANDLING = 'HANDLING';
36
37
	/**
38
	 * Discount.
39
	 *
40
	 * @var string
41
	 */
42
	const DISCOUNT = 'DISCOUNT';
43
44
	/**
45
	 * Transform a Pronamic Pay payment line type to a Pay.nl product type.
46
	 *
47
	 * @param string $type
48
	 *
49
	 * @return null|string
50
	 */
51
	public static function transform( $type ) {
52
		switch ( $type ) {
53
			case PaymentLineType::DIGITAL:
54
				return self::ARTICLE;
55
			case PaymentLineType::DISCOUNT:
56
				return self::DISCOUNT;
57
			case PaymentLineType::PHYSICAL:
58
				return self::ARTICLE;
59
			case PaymentLineType::SHIPPING:
60
				return self::SHIPPING;
61
			default:
62
				return null;
63
		}
64
	}
65
}
66