Passed
Push — master ( df4ed5...14d15a )
by Remco
21:23 queued 11:46
created

Statuses   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 10
eloc 28
dl 0
loc 96
c 0
b 0
f 0
ccs 0
cts 19
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B transform() 0 25 10
1
<?php
2
/**
3
 * Statuses
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Sisow;
12
13
use Pronamic\WordPress\Pay\Core\Statuses as Core_Statuses;
14
15
/**
16
 * Title: Sisow statuses constants
17
 * Description:
18
 * Copyright: Copyright (c) 2005 - 2018
19
 * Company: Pronamic
20
 *
21
 * @author  Reüel van der Steege
22
 * @version 2.0.1
23
 * @since   2.0.1
24
 */
25
class Statuses {
26
	/**
27
	 * Open.
28
	 *
29
	 * @var string
30
	 */
31
	const OPEN = 'Open';
32
33
	/**
34
	 * Pending.
35
	 *
36
	 * @var string
37
	 */
38
	const PENDING = 'Pending';
39
40
	/**
41
	 * Reservation.
42
	 *
43
	 * @var string
44
	 */
45
	const RESERVATION = 'Reservation';
46
47
	/**
48
	 * Paid.
49
	 *
50
	 * @var string
51
	 */
52
	const SUCCESS = 'Success';
53
54
	/**
55
	 * Cancelled.
56
	 *
57
	 * @var string
58
	 */
59
	const CANCELLED = 'Cancelled';
60
61
	/**
62
	 * Expired.
63
	 *
64
	 * @var string
65
	 */
66
	const EXPIRED = 'Expired';
67
68
	/**
69
	 * Denied.
70
	 *
71
	 * @var string
72
	 */
73
	const DENIED = 'Denied';
74
75
	/**
76
	 * Failure.
77
	 *
78
	 * @var string
79
	 */
80
	const FAILURE = 'Failure';
81
82
	/**
83
	 * Reversed.
84
	 *
85
	 * @var string
86
	 */
87
	const REVERSED = 'Reversed';
88
89
	/**
90
	 * Transform an Sisow state to a more global status.
91
	 *
92
	 * @param string $status Sisow status.
93
	 *
94
	 * @return string|null Pay status.
95
	 */
96
	public static function transform( $status ) {
97
		switch ( $status ) {
98
			case self::PENDING:
99
			case self::OPEN:
100
				return Core_Statuses::OPEN;
101
102
			case self::RESERVATION:
103
				return Core_Statuses::RESERVED;
104
105
			case self::SUCCESS:
106
				return Core_Statuses::SUCCESS;
107
108
			case self::CANCELLED:
109
				return Core_Statuses::CANCELLED;
110
111
			case self::EXPIRED:
112
				return Core_Statuses::EXPIRED;
113
114
			case self::DENIED:
115
			case self::FAILURE:
116
				return Core_Statuses::FAILURE;
117
118
			case self::REVERSED:
119
			default:
120
				return null;
121
		}
122
	}
123
}
124