RefundRequest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 100
ccs 0
cts 23
cp 0
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A set_description() 0 2 1
A get_array() 0 13 1
A get_metadata() 0 2 1
A set_metadata() 0 2 1
A get_description() 0 2 1
A __construct() 0 2 1
1
<?php
2
/**
3
 * Mollie refund request.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2022 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Mollie;
12
13
/**
14
 * Title: Mollie refund request
15
 * Description:
16
 * Copyright: 2005-2022 Pronamic
17
 * Company: Pronamic
18
 *
19
 * @author  Reüel van der Steege
20
 * @version 2.3.0
21
 * @since   2.3.0
22
 */
23
class RefundRequest {
24
	/**
25
	 * The amount to refund. For some payments, it can be up to €25.00 more
26
	 * than the original transaction amount.
27
	 *
28
	 * @link https://docs.mollie.com/reference/v2/refunds-api/create-refund
29
	 * @var Amount
30
	 */
31
	public $amount;
32
33
	/**
34
	 * The description of the refund you are creating. This will be shown to the consumer
35
	 * on their card or bank statement when possible. Max. 140 characters.
36
	 *
37
	 * @link https://docs.mollie.com/reference/v2/refunds-api/create-refund
38
	 * @var string|null
39
	 */
40
	public $description;
41
42
	/**
43
	 * Provide any data you like in JSON notation, and we will save the data alongside the payment.
44
	 * Whenever you fetch the refund with our API, we'll also include the metadata. You can use up
45
	 * to 1kB of JSON.
46
	 *
47
	 * @link https://www.mollie.com/nl/docs/reference/payments/create
48
	 * @link https://en.wikipedia.org/wiki/Metadata
49
	 * @var mixed|null
50
	 */
51
	private $metadata;
52
53
	/**
54
	 * Construct Mollie refund request object.
55
	 *
56
	 * @param Amount $amount The amount that you want to refund.
57
	 * @retrun void
58
	 */
59
	public function __construct( $amount ) {
60
		$this->amount = $amount;
61
	}
62
63
	/**
64
	 * Get description.
65
	 *
66
	 * @return string|null
67
	 */
68
	public function get_description() {
69
		return $this->description;
70
	}
71
72
	/**
73
	 * Set description.
74
	 *
75
	 * @param string|null $description Description.
76
	 * @return void
77
	 */
78
	public function set_description( $description ) {
79
		$this->description = $description;
80
	}
81
82
	/**
83
	 * Get metadata.
84
	 *
85
	 * @link https://docs.mollie.com/reference/v2/payments-api/create-payment
86
	 * @link https://en.wikipedia.org/wiki/Metadata
87
	 * @return mixed
88
	 */
89
	public function get_metadata() {
90
		return $this->metadata;
91
	}
92
93
	/**
94
	 * Set metadata.
95
	 *
96
	 * @link https://docs.mollie.com/reference/v2/payments-api/create-payment
97
	 * @link https://en.wikipedia.org/wiki/Metadata
98
	 * @param mixed $metadata Metadata.
99
	 * @return void
100
	 */
101
	public function set_metadata( $metadata = null ) {
102
		$this->metadata = $metadata;
103
	}
104
105
	/**
106
	 * Get array of this Mollie refund request object.
107
	 *
108
	 * @return array<string,null|string|object>
109
	 */
110
	public function get_array() {
111
		$array = array(
112
			'amount'      => $this->amount->get_json(),
113
			'description' => $this->description,
114
			'metadata'    => $this->metadata,
115
		);
116
117
		/*
118
		 * Array filter will remove values NULL, FALSE and empty strings ('')
119
		 */
120
		$array = array_filter( $array );
121
122
		return $array;
123
	}
124
}
125