Failed Conditions
Push — feature/post-pay ( 891b87...037c25 )
by Reüel
06:06
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
namespace Pronamic\WordPress\Pay\Gateways\Sisow;
4
5
use Pronamic\WordPress\Pay\Core\Statuses as Core_Statuses;
6
7
/**
8
 * Title: Sisow statuses constants
9
 * Description:
10
 * Copyright: Copyright (c) 2005 - 2018
11
 * Company: Pronamic
12
 *
13
 * @author  Reüel van der Steege
14
 * @version 2.0.1
15
 * @since   2.0.1
16
 */
17
class Statuses {
18
	/**
19
	 * Open.
20
	 *
21
	 * @var string
22
	 */
23
	const OPEN = 'Open';
24
25
	/**
26
	 * Pending.
27
	 *
28
	 * @var string
29
	 */
30
	const PENDING = 'Pending';
31
32
	/**
33
	 * Reservation.
34
	 *
35
	 * @var string
36
	 */
37
	const RESERVATION = 'Reservation';
38
39
	/**
40
	 * Paid.
41
	 *
42
	 * @var string
43
	 */
44
	const SUCCESS = 'Success';
45
46
	/**
47
	 * Cancelled.
48
	 *
49
	 * @var string
50
	 */
51
	const CANCELLED = 'Cancelled';
52
53
	/**
54
	 * Expired.
55
	 *
56
	 * @var string
57
	 */
58
	const EXPIRED = 'Expired';
59
60
	/**
61
	 * Denied.
62
	 *
63
	 * @var string
64
	 */
65
	const DENIED = 'Denied';
66
67
	/**
68
	 * Failure.
69
	 *
70
	 * @var string
71
	 */
72
	const FAILURE = 'Failure';
73
74
	/**
75
	 * Reversed.
76
	 *
77
	 * @var string
78
	 */
79
	const REVERSED = 'Reversed';
80
81
	/**
82
	 * Transform an Sisow state to a more global status.
83
	 *
84
	 * @param string $status Sisow status.
85
	 *
86
	 * @return string|null Pay status.
87
	 */
88
	public static function transform( $status ) {
89
		switch ( $status ) {
90
			case self::PENDING:
91
			case self::OPEN:
92
				return Core_Statuses::OPEN;
93
94
			case self::RESERVATION:
95
				return Core_Statuses::RESERVED;
0 ignored issues
show
Bug introduced by
The constant Pronamic\WordPress\Pay\Core\Statuses::RESERVED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
96
97
			case self::SUCCESS:
98
				return Core_Statuses::SUCCESS;
99
100
			case self::CANCELLED:
101
				return Core_Statuses::CANCELLED;
102
103
			case self::EXPIRED:
104
				return Core_Statuses::EXPIRED;
105
106
			case self::DENIED:
107
			case self::FAILURE:
108
				return Core_Statuses::FAILURE;
109
110
			case self::REVERSED:
111
			default:
112
				return null;
113
		}
114
	}
115
}
116