Failed Conditions
Push — feature/post-pay ( 4d43ec...e3663d )
by Remco
04:52
created

Category::transform()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 5
nop 1
dl 0
loc 12
ccs 0
cts 12
cp 0
crap 30
rs 9.6111
c 0
b 0
f 0
1
<?php
2
/**
3
 * Category
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 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\PaymentLineType;
14
15
/**
16
 * Category
17
 *
18
 * @author  Remco Tolsma
19
 * @version 2.0.2
20
 * @since   1.0.0
21
 */
22
class Category {
23
	/**
24
	 * Physical.
25
	 *
26
	 * @var string
27
	 */
28
	const PHYSICAL = 'PHYSICAL';
29
30
	/**
31
	 * Digital.
32
	 *
33
	 * @var string
34
	 */
35
	const DIGITAL = 'DIGITAL';
36
37
	/**
38
	 * Transform an OmniKassa 2.0 status to Pronamic Pay status.
39
	 *
40
	 * @param string $status OmniKassa 2.0 status.
41
	 * @return string|null
42
	 */
43
	public static function transform( $type ) {
44
		switch ( $type ) {
45
			case PaymentLineType::DIGITAL:
46
				return self::DIGITAL;
47
			case PaymentLineType::DISCOUNT:
48
				return self::DIGITAL;
49
			case PaymentLineType::PHYSICAL:
50
				return self::PHYSICAL;
51
			case PaymentLineType::SHIPPING:
52
				return self::DIGITAL;
53
			default:
54
				return self::DIGITAL;
55
		}
56
	}
57
}
58