Failed Conditions
Push — develop ( fc7b68...4eeca8 )
by Reüel
05:13
created

src/PaymentMethods.php (1 issue)

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Buckaroo;
4
5
use Pronamic\WordPress\Pay\Core\PaymentMethods as Core_PaymentMethods;
6
7
/**
8
 * Title: Buckaroo payment methods constants
9
 * Description:
10
 * Copyright: 2005-2020 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author Remco Tolsma
14
 * @version 2.0.0
15
 * @since 1.0.0
16
 */
17
class PaymentMethods {
18
	/**
19
	 * Indicator for the 'Achteraf Betalen' payment method
20
	 *
21
	 * @var string
22
	 */
23
	const PAYMENT_GUARANTEE = 'paymentguarantee';
24
25
	/**
26
	 * Indicator for the 'American Express' payment method
27
	 *
28
	 * @var string
29
	 */
30
	const AMERICAN_EXPRESS = 'amex';
31
32
	/**
33
	 * Indicator for the 'Bancontact / Mr Cash' payment method
34
	 *
35
	 * @var string
36
	 */
37
	const BANCONTACT_MISTER_CASH = 'bancontactmrcash';
38
39
	/**
40
	 * Indicator for the 'èM! Payment' payment method
41
	 *
42
	 * @var string
43
	 */
44
	const EM_PAYMENT = 'empayment';
45
46
	/**
47
	 * Indicator for the 'Giropay' payment method
48
	 *
49
	 * @var string
50
	 */
51
	const GIROPAY = 'giropay';
52
53
	/**
54
	 * Indicator for the 'iDEAL' payment method
55
	 *
56
	 * @var string
57
	 */
58
	const IDEAL = 'ideal';
59
60
	/**
61
	 * Indicator for the 'Maestro' payment method
62
	 *
63
	 * @var string
64
	 */
65
	const MAESTRO = 'maestro';
66
67
	/**
68
	 * Indicator for the 'MasterCard' payment method
69
	 *
70
	 * @var string
71
	 */
72
	const MASTERCARD = 'mastercard';
73
74
	/**
75
	 * Indicator for the 'Overschrijving' payment method
76
	 *
77
	 * @var string
78
	 */
79
	const TRANSFER = 'transfer';
80
81
	/**
82
	 * Indicator for the 'PayPal' payment method
83
	 *
84
	 * @var string
85
	 */
86
	const PAYPAL = 'paypal';
87
88
	/**
89
	 * Indicator for the 'paysafecard' payment method
90
	 *
91
	 * @var string
92
	 */
93
	const PAYSAFECARD = 'paysafecard';
94
95
	/**
96
	 * Indicator for the 'Sofortüberweisung' payment method
97
	 *
98
	 * @var string
99
	 */
100
	const SOFORTUEBERWEISING = 'sofortueberweisung';
101
102
	/**
103
	 * Indicator for the 'Ukash' payment method
104
	 *
105
	 * @var string
106
	 */
107
	const UKASH = 'Ukash';
108
109
	/**
110
	 * Indicator for the 'Visa' payment method
111
	 *
112
	 * @var string
113
	 */
114
	const VISA = 'visa';
115
116
	/**
117
	 * Payments methods map.
118
	 *
119
	 * @var array
120
	 */
121
	private static $map = array(
122
		Core_PaymentMethods::BANK_TRANSFER => self::TRANSFER,
123
		Core_PaymentMethods::BANCONTACT    => self::BANCONTACT_MISTER_CASH,
124
		Core_PaymentMethods::MISTER_CASH   => self::BANCONTACT_MISTER_CASH,
125
		Core_PaymentMethods::GIROPAY       => self::GIROPAY,
126
		Core_PaymentMethods::IDEAL         => self::IDEAL,
127
		Core_PaymentMethods::PAYPAL        => self::PAYPAL,
128
		Core_PaymentMethods::SOFORT        => self::SOFORTUEBERWEISING,
129
	);
130
131
	/**
132
	 * Transform WordPress payment method to Buckaroo method.
133
	 *
134
	 * @since 1.1.6
135
	 *
136
	 * @param string $payment_method WordPress payment method to transform to Buckaroo method.
137
	 * @param mixed  $default        Default payment method.
138
	 *
139
	 * @return string
140
	 */
141
	public static function transform( $payment_method, $default = null ) {
142
		if ( ! is_scalar( $payment_method ) ) {
0 ignored issues
show
The condition is_scalar($payment_method) is always true.
Loading history...
143
			return null;
144
		}
145
146
		if ( isset( self::$map[ $payment_method ] ) ) {
147
			return self::$map[ $payment_method ];
148
		}
149
150
		return $default;
151
	}
152
}
153