BrandId::from_core()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
eloc 13
nc 6
nop 1
dl 0
loc 19
ccs 6
cts 6
cp 1
crap 6
rs 9.2222
c 0
b 0
f 0
1
<?php
2
/**
3
 * Brand ID
4
 *
5
 * @author Pronamic <[email protected]>
6
 * @copyright 2005-2022 Pronamic
7
 * @license GPL-3.0-or-later
8
 * @package Pronamic\WordPress\Pay\Gateways\Payvision
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Payvision;
12
13
use Pronamic\WordPress\Pay\Core\PaymentMethods;
14
15
/**
16
 * Brand ID
17
 *
18
 * @link https://developers.acehubpaymentservices.com/v3.3/reference#brands
19
 * @author Remco Tolsma
20
 * @version 1.1.0
21
 * @since 1.0.0
22
 */
23
class BrandId {
24
	/**
25
	 * VISA.
26
	 *
27
	 * @var string
28
	 */
29
	const VISA = '1010';
30
31
	/**
32
	 * American Express.
33
	 *
34
	 * @var string
35
	 */
36
	const AMERICAN_EXPRESS = '1030';
37
38
	/**
39
	 * Maestro.
40
	 *
41
	 * @var string
42
	 */
43
	const MAESTRO = '1050';
44
45
	/**
46
	 * Bancontact (BCMC = Bancontact / Mister Cash).
47
	 *
48
	 * @var string
49
	 */
50
	const BCMC = '1210';
51
52
	/**
53
	 * IDeal.
54
	 *
55
	 * @var string
56
	 */
57
	const IDEAL = '3010';
58
59
	/**
60
	 * PayPal.
61
	 *
62
	 * @var string
63
	 */
64
	const PAYPAL = '4010';
65
66
	/**
67
	 * AfterPay.
68
	 *
69
	 * Note: this is for AfterPay (afterpay.nl) and not for Afterpay (afterpay.com)
70
	 *
71
	 * @var string
72
	 */
73
	const AFTERPAY = '5020';
74
75
	/**
76
	 * From core.
77
	 *
78
	 * @param string|null $method Method.
79 7
	 * @return string|null
80 7
	 */
81
	public static function from_core( $method ) {
82 1
		switch ( $method ) {
83
			case PaymentMethods::AFTERPAY_NL:
84
				return self::AFTERPAY;
85 1
86
			case PaymentMethods::BANCONTACT:
87
				return self::BCMC;
88 1
89
			case PaymentMethods::IDEAL:
90
				return self::IDEAL;
91 1
92
			case PaymentMethods::PAYPAL:
93
				return self::PAYPAL;
94 1
95
			case PaymentMethods::MAESTRO:
96
				return self::MAESTRO;
97 2
98
			default:
99
				return null;
100
		}
101
	}
102
}
103