Methods   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 173
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 38
c 3
b 0
f 0
dl 0
loc 173
ccs 0
cts 6
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 10 3
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\PayNL;
4
5
use Pronamic\WordPress\Pay\Core\PaymentMethods;
6
7
/**
8
 * Title: Pay.nl payment methods
9
 * Description:
10
 * Copyright: 2005-2021 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Reüel van der Steege
14
 * @version 2.0.1
15
 * @since   1.0.0
16
 * @see     https://admin.pay.nl/data/payment_profiles
17
 */
18
class Methods {
19
	/**
20
	 * Constant for the AfterPay method.
21
	 *
22
	 *  739 = AfterPay
23
	 *  740 = AfterPay EM
24
	 * 1921 = AfterPay NL B2B
25
	 * 1918 = AfterPay NL B2C
26
	 *
27
	 * @link https://admin.pay.nl/data/payment_profiles
28
	 *
29
	 * @var string
30
	 */
31
	const AFTERPAY = '739';
32
33
	/**
34
	 * Constant for the Bancontact method.
35
	 *
36
	 * @var string
37
	 */
38
	const BANCONTACT = '436';
39
40
	/**
41
	 * Constant for the Bank transfer method.
42
	 *
43
	 * @var string
44
	 */
45
	const BANKTRANSFER = '136';
46
47
	/**
48
	 * Constant for the Billink < € 100 method.
49
	 *
50
	 * @var string
51
	 */
52
	const BILLINK_LOW = '1672';
53
54
	/**
55
	 * Constant for the Billink > € 100 method.
56
	 *
57
	 * @var string
58
	 */
59
	const BILLINK_HIGH = '1675';
60
61
	/**
62
	 * Constant for the Capayable Achteraf Betalen method.
63
	 *
64
	 * @var string
65
	 */
66
	const CAPAYABLE = '1744';
67
68
	/**
69
	 * Constant for the Credit Card method.
70
	 *
71
	 * @var string
72
	 */
73
	const CREDITCARD = '706';
74
75
	/**
76
	 * Constant for the Focum method.
77
	 *
78
	 * @var string
79
	 */
80
	const FOCUM = '1702';
81
82
	/**
83
	 * Constant for the Giropay method.
84
	 *
85
	 * @var string
86
	 */
87
	const GIROPAY = '694';
88
89
	/**
90
	 * Constant for the iDEAL method.
91
	 *
92
	 * @var string
93
	 */
94
	const IDEAL = '10';
95
96
	/**
97
	 * Constant for the In3 (Gesprek betalen) method.
98
	 *
99
	 * @var string
100
	 */
101
	const IN3 = '1813';
102
103
	/**
104
	 * Constant for the Klarna method.
105
	 *
106
	 * @var string
107
	 */
108
	const KLARNA_PAY_LATER = '1717';
109
110
	/**
111
	 * Constant for the Maestro method.
112
	 *
113
	 * @var string
114
	 */
115
	const MAESTRO = '712';
116
117
	/**
118
	 * Constant for the PayPal method.
119
	 *
120
	 * @var string
121
	 */
122
	const PAYPAL = '138';
123
124
	/**
125
	 * Constant for the Paysafecard method.
126
	 *
127
	 * @var string
128
	 */
129
	const PAYSAFECARD = '553';
130
131
	/**
132
	 * Constant for the Sofort (Digital Services) method.
133
	 *
134
	 * 559 = Sofortbanking eCommerce (fysieke producten)
135
	 * 577 = Sofortbanking Digital services
136
	 * 595 = Sofortbanking High risk
137
	 *
138
	 * @link https://admin.pay.nl/data/payment_profiles
139
	 *
140
	 * @var string
141
	 */
142
	const SOFORT = '577';
143
144
	/**
145
	 * Constant for the SprayPay method.
146
	 *
147
	 * @link https://docs.pay.nl/developers#transaction-paylater
148
	 * @var string
149
	 */
150
	const SPRAYPAY = '1987';
151
152
	/**
153
	 * Payments methods map.
154
	 *
155
	 * @var array
156
	 */
157
	private static $map = array(
158
		PaymentMethods::AFTERPAY         => self::AFTERPAY,
159
		PaymentMethods::BANCONTACT       => self::BANCONTACT,
160
		PaymentMethods::BANK_TRANSFER    => self::BANKTRANSFER,
161
		PaymentMethods::CREDIT_CARD      => self::CREDITCARD,
162
		PaymentMethods::FOCUM            => self::FOCUM,
163
		PaymentMethods::GIROPAY          => self::GIROPAY,
164
		PaymentMethods::IDEAL            => self::IDEAL,
165
		PaymentMethods::IN3              => self::IN3,
166
		PaymentMethods::KLARNA_PAY_LATER => self::KLARNA_PAY_LATER,
167
		PaymentMethods::MISTER_CASH      => self::BANCONTACT,
168
		PaymentMethods::MAESTRO          => self::MAESTRO,
169
		PaymentMethods::PAYPAL           => self::PAYPAL,
170
		PaymentMethods::SOFORT           => self::SOFORT,
171
		PaymentMethods::SPRAYPAY         => self::SPRAYPAY,
172
	);
173
174
	/**
175
	 * Transform WordPress payment method to Pay.nl method.
176
	 *
177
	 * @param mixed $payment_method Payment method.
178
	 *
179
	 * @return null|string
180
	 */
181
	public static function transform( $payment_method ) {
182
		if ( ! is_scalar( $payment_method ) ) {
183
			return null;
184
		}
185
186
		if ( isset( self::$map[ $payment_method ] ) ) {
187
			return self::$map[ $payment_method ];
188
		}
189
190
		return null;
191
	}
192
}
193