PaymentMethods   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 20
c 2
b 0
f 0
dl 0
loc 82
ccs 6
cts 7
cp 0.8571
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 16 5
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\EMS\ECommerce;
4
5
use Pronamic\WordPress\Pay\Core\PaymentMethods as Core_PaymentMethods;
6
7
/**
8
 * Title: EMS e-Commerce payment methods
9
 * Description:
10
 * Copyright: 2005-2022 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author Reüel van der Steege
14
 * @version 2.0.0
15
 * @since 1.0.0
16
 */
17
class PaymentMethods {
18
	/**
19
	 * Constant for the Bancontact payment method.
20
	 *
21
	 * @var string
22
	 */
23
	const BANCONTACT = 'BCMC';
24
25
	/**
26
	 * Constant for the MasterCard payment method.
27
	 *
28
	 * @var string
29
	 */
30
	const MASTERCARD = 'M';
31
32
	/**
33
	 * Constant for the VISA (Credit/Debit/Electron/Delta) payment method.
34
	 *
35
	 * @var string
36
	 */
37
	const VISA = 'V';
38
39
	/**
40
	 * Constant for the Maestro payment method.
41
	 *
42
	 * @var string
43
	 */
44
	const MAESTRO = 'MA';
45
46
	/**
47
	 * Constant for the Maestro UK payment method.
48
	 *
49
	 * @var string
50
	 */
51
	const MAESTROUK = 'maestroUK';
52
53
	/**
54
	 * Constant for the iDEAL payment method.
55
	 *
56
	 * @var string
57
	 */
58
	const IDEAL = 'ideal';
59
60
	/**
61
	 * Constant for the PayPal payment method.
62
	 *
63
	 * @var string
64
	 */
65
	const PAYPAL = 'paypal';
66
67
	/**
68
	 * Constant for the SOFORT Banking payment method.
69
	 *
70
	 * @var string
71
	 */
72
	const SOFORT = 'sofort';
73
74
	/**
75
	 * Transform WordPress payment method to EMS payment method.
76
	 *
77
	 * @since 1.0.0
78
	 *
79
	 * @param string|null $payment_method Payment method.
80
	 *
81
	 * @return string|null
82
	 */
83 4
	public static function transform( $payment_method ) {
84 4
		switch ( $payment_method ) {
85
			case Core_PaymentMethods::BANCONTACT:
86
				return self::BANCONTACT;
87
88
			case Core_PaymentMethods::IDEAL:
89 1
				return self::IDEAL;
90
91
			case Core_PaymentMethods::PAYPAL:
92 1
				return self::PAYPAL;
93
94
			case Core_PaymentMethods::SOFORT:
95 1
				return self::SOFORT;
96
97
			default:
98 1
				return null;
99
		}
100
	}
101
}
102