Statuses   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 16
c 3
b 0
f 0
dl 0
loc 47
ccs 10
cts 10
cp 1
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 12 5
1
<?php
2
/**
3
 * Statuses
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2022 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\OmniKassa2
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2;
12
13
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
14
15
/**
16
 * Statuses
17
 *
18
 * @author  Remco Tolsma
19
 * @version 2.1.0
20
 * @since   1.0.0
21
 */
22
class Statuses {
23
	/**
24
	 * Cancelled.
25
	 *
26
	 * @var string
27
	 */
28
	const CANCELLED = 'CANCELLED';
29
30
	/**
31
	 * Completed.
32
	 *
33
	 * @var string
34
	 */
35
	const COMPLETED = 'COMPLETED';
36
37
	/**
38
	 * Expired.
39
	 *
40
	 * @var string
41
	 */
42
	const EXPIRED = 'EXPIRED';
43
44
	/**
45
	 * In progress.
46
	 *
47
	 * @var string
48
	 */
49
	const IN_PROGRESS = 'IN_PROGRESS';
50
51
	/**
52
	 * Transform an OmniKassa 2.0 status to Pronamic Pay status.
53
	 *
54
	 * @param string $status OmniKassa 2.0 status.
55
	 * @return string|null
56
	 */
57 5
	public static function transform( $status ) {
58
		switch ( $status ) {
59 5
			case self::CANCELLED:
60 1
				return PaymentStatus::CANCELLED;
61 4
			case self::COMPLETED:
62 1
				return PaymentStatus::SUCCESS;
63 3
			case self::EXPIRED:
64 1
				return PaymentStatus::EXPIRED;
65 2
			case self::IN_PROGRESS:
66 1
				return PaymentStatus::OPEN;
67
			default:
68 1
				return null;
69
		}
70
	}
71
}
72