Statuses   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 94
ccs 10
cts 10
cp 1
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\TargetPay;
4
5
use Pronamic\WordPress\Pay\Payments\PaymentStatus as Core_Statuses;
6
7
/**
8
 * Title: TargetPay response codes
9
 * Description:
10
 * Copyright: 2005-2021 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.3
15
 * @since   1.0.0
16
 */
17
class Statuses {
18
	/**
19
	 * OK
20
	 *
21
	 * @var string
22
	 */
23
	const OK = '000000';
24
25
	/**
26
	 * Transaction has not been completed, try again later
27
	 *
28
	 * @var string
29
	 */
30
	const TRANSACTION_NOT_COMPLETED = ' TP0010';
31
32
	/**
33
	 * Transaction has been cancelled
34
	 *
35
	 * @var string
36
	 */
37
	const TRANSACTION_CANCLLED = 'TP0011';
38
39
	/**
40
	 * Transaction has expired (max. 10 minutes)
41
	 *
42
	 * @var string
43
	 */
44
	const TRANSACTION_EXPIRED = 'TP0012';
45
46
	/**
47
	 * The transaction could not be processed
48
	 *
49
	 * @var string
50
	 */
51
	const TRANSACTION_NOT_PROCESSED = 'TP0013';
52
53
	/**
54
	 * Already used
55
	 *
56
	 * @var string
57
	 */
58
	const ALREADY_USED = 'TP0014';
59
60
	/**
61
	 * Layoutcode not entered
62
	 *
63
	 * @var string
64
	 */
65
	const LAYOUTCODE_NOT_ENTERED = 'TP0020';
66
67
	/**
68
	 * Tansaction ID not entered
69
	 *
70
	 * @var string
71
	 */
72
	const TRANSACTION_ID_NOT_ENTERED = 'TP0021';
73
74
	/**
75
	 * No transaction found with this ID
76
	 *
77
	 * @var string
78
	 */
79
	const TRANSACTION_NOT_FOUND = 'TP0022';
80
81
	/**
82
	 * Layoutcode does not match this transaction
83
	 *
84
	 * @var string
85
	 */
86
	const LAYOUCODE_NOT_MATCH_TRANSACTION = 'TP0023';
87
88
	/**
89
	 * Transform an TargetPay response code to an more global status
90
	 *
91
	 * @param string $response_code
92
	 *
93
	 * @return null|string
94
	 */
95 5
	public static function transform( $response_code ) {
96
		switch ( $response_code ) {
97 5
			case self::OK:
98 1
				return Core_Statuses::SUCCESS;
99
100 4
			case self::TRANSACTION_NOT_COMPLETED:
101 1
				return Core_Statuses::OPEN;
102
103 3
			case self::TRANSACTION_CANCLLED:
104 1
				return Core_Statuses::CANCELLED;
105
106 2
			case self::TRANSACTION_EXPIRED:
107 1
				return Core_Statuses::EXPIRED;
108
109
			default:
110 1
				return null;
111
		}
112
	}
113
}
114