OrderRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 89
ccs 0
cts 23
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A get_array() 0 32 3
1
<?php
2
/**
3
 * Order Request.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2021 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet;
12
13
/**
14
 * Title: ING Kassa Compleet order request
15
 * Description:
16
 * Copyright: 2005-2021 Pronamic
17
 * Company: Pronamic
18
 *
19
 * @author  Reüel van der Steege
20
 * @version 2.0.3
21
 * @since   1.0.0
22
 */
23
class OrderRequest {
24
	/**
25
	 * Amount in cents
26
	 *
27
	 * @var string
28
	 */
29
	public $amount;
30
31
	/**
32
	 * ISO 4217 currency code
33
	 *
34
	 * @link https://en.wikipedia.org/wiki/ISO_4217
35
	 *
36
	 * @var string
37
	 */
38
	public $currency;
39
40
	/**
41
	 * Issuer.
42
	 *
43
	 * @var string
44
	 */
45
	public $issuer;
46
47
	/**
48
	 * Method.
49
	 *
50
	 * @var string
51
	 */
52
	public $method;
53
54
	/**
55
	 * Merchant order ID.
56
	 *
57
	 * @var string
58
	 */
59
	public $merchant_order_id;
60
61
	/**
62
	 * Description.
63
	 *
64
	 * @var string
65
	 */
66
	public $description;
67
68
	/**
69
	 * Return URL.
70
	 *
71
	 * @var string
72
	 */
73
	public $return_url;
74
75
	/**
76
	 * Get array.
77
	 *
78
	 * @return array
79
	 */
80
	public function get_array() {
81
		$array = array(
82
			'amount'       => $this->amount,
83
			'currency'     => $this->currency,
84
			'description'  => $this->description,
85
			'return_url'   => $this->return_url,
86
			'transactions' => array(),
87
		);
88
89
		// Array filter will remove values NULL, FALSE and empty strings ('').
90
		$array = array_filter( $array );
91
92
		if ( null !== $this->method ) {
93
			// Add payment method.
94
			$payment_method = array(
95
				'payment_method' => $this->method,
96
			);
97
98
			// Add payment method details.
99
			switch ( $this->method ) {
100
				case PaymentMethods::IDEAL:
101
					$payment_method['payment_method_details'] = array(
102
						'issuer_id' => $this->issuer,
103
					);
104
105
					break;
106
			}
107
108
			$array['transactions'] = array( $payment_method );
109
		}
110
111
		return $array;
112
	}
113
}
114