Test Failed
Push — develop ( 7dad48...0b6870 )
by Reüel
09:40
created

Config   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
c 2
b 0
f 0
dl 0
loc 112
ccs 10
cts 12
cp 0.8333
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get_merchant_account() 0 2 1
A get_apple_pay_merchant_id_private_key_password() 0 2 1
A get_api_url() 0 10 3
A get_google_pay_merchant_identifier() 0 2 1
A get_api_key() 0 2 1
A get_apple_pay_merchant_id() 0 2 1
1
<?php
2
/**
3
 * Config
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2020 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Adyen
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
14
use Pronamic\WordPress\Pay\Core\GatewayConfig;
15
16
/**
17
 * Config
18
 *
19
 * @author  Remco Tolsma
20
 * @version 1.0.4
21
 * @since   1.0.0
22
 */
23
class Config extends GatewayConfig {
24
	/**
25
	 * API Key.
26
	 *
27
	 * @var string|null
28
	 */
29
	public $api_key;
30
31
	/**
32
	 * API Live URL Prefix.
33
	 *
34
	 * @var string|null
35
	 */
36
	public $api_live_url_prefix;
37
38
	/**
39
	 * Merchant Account.
40
	 *
41
	 * @var string|null
42
	 */
43
	public $merchant_account;
44
45
	/**
46
	 * Origin key.
47
	 *
48
	 * @var string|null
49
	 */
50
	public $origin_key;
51
52
	/**
53
	 * Apple Pay merchant identifier.
54
	 *
55
	 * @var string|null
56
	 */
57
	public $apple_pay_merchant_id;
58
59
	/**
60
	 * Apple Pay merchant identity private key password.
61
	 *
62
	 * @var string|null
63
	 */
64 11
	public $apple_pay_merchant_id_private_key_password;
65 11
66
	/**
67
	 * Google Pay merchant identifier.
68
	 *
69
	 * @var string|null
70
	 */
71
	public $google_pay_merchant_identifier;
72
73 1
	/**
74 1
	 * Get API key.
75
	 *
76
	 * @return string|null
77
	 */
78
	public function get_api_key() {
79
		return $this->api_key;
80
	}
81
82
	/**
83
	 * Get merchant account.
84
	 *
85
	 * @return string
86
	 */
87
	public function get_merchant_account() {
88
		return strval( $this->merchant_account );
89
	}
90
91
	/**
92
	 * Get Apple Pay merchant identifier.
93 12
	 *
94 12
	 * @return string|null
95 11
	 */
96
	public function get_apple_pay_merchant_id() {
97
		return $this->apple_pay_merchant_id;
98 2
	}
99 1
100
	/**
101
	 * Get Apple Pay merchant identity certificate private key password.
102 1
	 *
103
	 * @return string|null
104
	 */
105
	public function get_apple_pay_merchant_id_private_key_password() {
106
		return $this->apple_pay_merchant_id_private_key_password;
107
	}
108
109
	/**
110
	 * Get Google Pay merchant identifier.
111
	 *
112
	 * @return string|null
113
	 */
114
	public function get_google_pay_merchant_identifier() {
115
		return $this->google_pay_merchant_identifier;
116
	}
117
118
	/**
119
	 * Get API URL.
120
	 *
121
	 * @param string $method API method.
122
	 * @return string
123
	 * @throws \Exception Throws exception when mode is live and API live URL prefix is empty.
124
	 */
125
	public function get_api_url( $method ) {
126
		if ( Core_Gateway::MODE_TEST === $this->mode ) {
127
			return sprintf( Endpoint::API_URL_TEST, $method );
128
		}
129
130
		if ( empty( $this->api_live_url_prefix ) ) {
131
			throw new \Exception( 'Adyen API Live URL prefix is required for live configurations.' );
132
		}
133
134
		return sprintf( Endpoint::API_URL_LIVE, $this->api_live_url_prefix, $method );
135
	}
136
}
137