Test Failed
Push — develop ( fd928b...40893b )
by Remco
04:14
created

Statuses::transform()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 25
rs 8.4444
c 0
b 0
f 0
cc 8
nc 8
nop 1
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay;
4
5
use Pronamic\WordPress\Pay\Core\Statuses as Core_Statuses;
6
7
/**
8
 * Title: MultiSafepay statuses constants
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.2
15
 */
16
class Statuses {
17
	/**
18
	 * Completed successfully
19
	 *
20
	 * @var string
21
	 */
22
	const COMPLETED = 'completed';
23
24
	/**
25
	 * Created, but uncompleted
26
	 *
27
	 * @var string
28
	 */
29
	const INITIALIZED = 'initialized';
30
31
	/**
32
	 * Created, but not yet exempted (credit cards)
33
	 *
34
	 * @var string
35
	 */
36
	const UNCLEARED = 'uncleared';
37
38
	/**
39
	 * Cancelled
40
	 *
41
	 * @var string
42
	 */
43
	const VOID = 'void';
44
45
	/**
46
	 * Rejected
47
	 *
48
	 * @var string
49
	 */
50
	const DECLINED = 'declined';
51
52
	/**
53
	 * Refunded
54
	 *
55
	 * @var string
56
	 */
57
	const REFUNDED = 'refunded';
58
59
	/**
60
	 * Expired
61
	 *
62
	 * @var string
63
	 */
64
	const EXPIRED = 'expired';
65
66
	/**
67
	 * Transform an MultiSafepay state to an more global status
68
	 *
69
	 * @param string $status
70
	 *
71
	 * @return null|string
72
	 */
73
	public static function transform( $status ) {
74
		switch ( $status ) {
75
			case self::COMPLETED:
76
				return Core_Statuses::SUCCESS;
77
78
			case self::INITIALIZED:
79
				return Core_Statuses::OPEN;
80
81
			case self::UNCLEARED:
82
				return Core_Statuses::OPEN;
83
84
			case self::VOID:
85
				return Core_Statuses::CANCELLED;
86
87
			case self::DECLINED:
88
				return Core_Statuses::FAILURE;
89
90
			case self::REFUNDED:
91
				return Core_Statuses::CANCELLED;
92
93
			case self::EXPIRED:
94
				return Core_Statuses::EXPIRED;
95
96
			default:
97
				return null;
98
		}
99
	}
100
}
101