Statuses::transform()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 13
c 2
b 0
f 0
nc 6
nop 1
dl 0
loc 19
ccs 0
cts 14
cp 0
crap 42
rs 9.2222
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Nocks;
4
5
use Pronamic\WordPress\Pay\Payments\PaymentStatus as Core_Statuses;
6
7
/**
8
 * Title: Nocks statuses
9
 * Description:
10
 * Copyright: 2005-2020 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Reüel van der Steege
14
 * @version 2.0.3
15
 * @since   1.0.0
16
 */
17
class Statuses {
18
	/**
19
	 * Cancelled
20
	 *
21
	 * @var string
22
	 */
23
	const CANCELLED = 'cancelled';
24
25
	/**
26
	 * Completed
27
	 *
28
	 * @var string
29
	 */
30
	const COMPLETED = 'completed';
31
32
	/**
33
	 * Expired.
34
	 *
35
	 * @var string
36
	 */
37
	const EXPIRED = 'expired';
38
39
	/**
40
	 * Failed
41
	 *
42
	 * @var string
43
	 */
44
	const FAILED = 'failed';
45
46
	/**
47
	 * Pending
48
	 *
49
	 * @var string
50
	 */
51
	const PENDING = 'pending';
52
53
	/**
54
	 * Processing
55
	 *
56
	 * @var string
57
	 */
58
	const PROCESSING = 'processing';
59
60
	/**
61
	 * Transform a Nocks status to Pronamic Pay status.
62
	 *
63
	 * @param string $status
64
	 *
65
	 * @return string|null
66
	 */
67
	public static function transform( $status ) {
68
		switch ( $status ) {
69
			case self::CANCELLED:
70
				return Core_Statuses::CANCELLED;
71
72
			case self::COMPLETED:
73
				return Core_Statuses::SUCCESS;
74
75
			case self::EXPIRED:
76
				return Core_Statuses::EXPIRED;
77
78
			case self::FAILED:
79
				return Core_Statuses::FAILURE;
80
81
			case self::PENDING:
82
				return Core_Statuses::OPEN;
83
84
			default:
85
				return null;
86
		}
87
	}
88
}
89