Test Failed
Push — main ( 28b955...362ef3 )
by Reüel
14:17 queued 10s
created

Config::get_purchase_id()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Config
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2021 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Payvision
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Payvision;
12
13
use Pronamic\WordPress\Pay\Core\GatewayConfig;
14
15
/**
16
 * Config
17
 *
18
 * @author  Remco Tolsma
19
 * @version 1.1.0
20
 * @since   1.0.0
21
 */
22
class Config extends GatewayConfig implements \JsonSerializable {
23
	/**
24
	 * Business Id.
25
	 *
26
	 * @var string
27
	 */
28
	private $business_id;
29
30
	/**
31
	 * User.
32
	 *
33
	 * @var string
34
	 */
35
	private $username;
36
37
	/**
38
	 * Password.
39
	 *
40
	 * @var string
41
	 */
42
	private $password;
43
44
	/**
45
	 * Store ID.
46
	 *
47
	 * @var string
48
	 */
49
	private $store_id;
50
51
	/**
52
	 * Purchase ID.
53
	 *
54
	 * @var string|null
55
	 */
56
	private $purchase_id;
57
58
	/**
59
	 * Construct config object.
60
	 *
61
	 * @param string $mode        Mode.
62
	 * @param string $business_id Business Id.
63
	 * @param string $username    Username.
64
	 * @param string $password    Password.
65
	 * @param string $store_id    Store ID.
66
	 */
67 11
	public function __construct( $mode, $business_id, $username, $password, $store_id ) {
68 11
		$this->mode        = $mode;
69 11
		$this->business_id = $business_id;
70 11
		$this->username    = $username;
71 11
		$this->password    = $password;
72 11
		$this->store_id    = $store_id;
73 11
	}
74
75
	/**
76
	 * Get business ID.
77
	 *
78
	 * @return string
79
	 */
80 3
	public function get_business_id() {
81 3
		return $this->business_id;
82
	}
83
84
	/**
85
	 * Get username.
86
	 *
87
	 * @return string
88
	 */
89 6
	public function get_username() {
90 6
		return $this->username;
91
	}
92
93
	/**
94
	 * Get password.
95
	 *
96
	 * @return string
97
	 */
98 6
	public function get_password() {
99 6
		return $this->password;
100
	}
101
102
	/**
103
	 * Get store ID.
104
	 *
105
	 * @return string
106
	 */
107 3
	public function get_store_id() {
108 3
		return $this->store_id;
109
	}
110
111
	/**
112
	 * Get endpoint URL.
113
	 *
114
	 * @link https://developers.acehubpaymentservices.com/docs/service-endpoints-and-headers
115
	 * @param string $path Path.
116
	 * @return string
117
	 */
118 7
	public function get_endpoint_url( $path ) {
119 7
		if ( Gateway::MODE_TEST === $this->mode ) {
120 6
			return SystemAddress::STAGING_SYSTEM . $path;
121
		}
122
123 1
		return SystemAddress::LIVE_SYSTEM . $path;
124
	}
125
126
	/**
127
	 * Get purchase ID.
128
	 *
129
	 * @return string|null
130
	 */
131 1
	public function get_purchase_id() {
132 1
		return $this->purchase_id;
133
	}
134
135
	/**
136
	 * Set purchase ID.
137
	 *
138
	 * @param string|null $purchase_id Purchase ID.
139
	 * @return void
140
	 */
141 1
	public function set_purchase_id( $purchase_id ) {
142 1
		$this->purchase_id = $purchase_id;
143 1
	}
144
145
	/**
146
	 * JSON serialize.
147
	 *
148
	 * @return object
149
	 */
150 2
	public function jsonSerialize() {
151
		return (object) array(
152 2
			'mode'        => $this->mode,
153 2
			'business_id' => $this->business_id,
154 2
			'username'    => $this->username,
155 2
			'password'    => $this->password,
156 2
			'store_id'    => $this->store_id,
157 2
			'purchase_id' => $this->purchase_id,
158
		);
159
	}
160
}
161