Completed
Push — master ( 503a39...ab5c01 )
by Chris
07:26
created

EduSveaWebPayBaseConfig::getSecret()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class EduSveaWebPayBaseConfig implements \Svea\WebPay\Config\ConfigurationProvider {
4
	/**
5
	 * @var EDU_SveaWebPay
6
	 */
7
	public $plugin;
8
9
	/**
10
	 * EduSveaWebPayProductionConfig constructor.
11
	 *
12
	 * @param EDU_SveaWebPay $_plugin
13
	 */
14
	public function __construct( $_plugin ) {
15
		$this->plugin = $_plugin;
16
	}
17
18
	/**
19
	 * fetch username, used with invoice or payment plan (i.e. Svea WebService Europe API)
20
	 *
21
	 * @return string
22
	 *
23
	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
24
	 * @param string $country iso3166 alpha-2 CountryCode, eg. SE, NO, DK, FI, NL, DE can be used if needed to match different configuration settings
25
	 *
26
	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
27
	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
28
	 */
29
	public function getUsername( $type, $country ) {
0 ignored issues
show
Coding Style introduced by
The function name getUsername is in camel caps, but expected get_username instead as per the coding standard.
Loading history...
30
		echo 'username';
31
	}
32
33
	/**
34
	 * fetch password, used with invoice or payment plan (i.e. Svea WebService Europe API)
35
	 *
36
	 * @return string
37
	 *
38
	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
39
	 * @param string $country iso3166 alpha-2 CountryCode, eg. SE, NO, DK, FI, NL, DE can be used if needed to match different configuration settings
40
	 *
41
	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
42
	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
43
	 */
44
	public function getPassword( $type, $country ) {
0 ignored issues
show
Coding Style introduced by
The function name getPassword is in camel caps, but expected get_password instead as per the coding standard.
Loading history...
45
		echo 'password';
46
	}
47
48
	/**
49
	 * fetch client number, used with invoice or payment plan (i.e. Svea WebService Europe API)
50
	 *
51
	 * @return \Svea\WebPay\Config\ClientNumber
52
	 *
53
	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
54
	 * @param string $country iso3166 alpha-2 CountryCode, eg. SE, NO, DK, FI, NL, DE can be used if needed to match different configuration settings
55
	 *
56
	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
57
	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
58
	 */
59
	public function getClientNumber( $type, $country ) {
0 ignored issues
show
Coding Style introduced by
The function name getClientNumber is in camel caps, but expected get_client_number instead as per the coding standard.
Loading history...
60
		echo 'client';
61
	}
62
63
	/**
64
	 * fetch merchant id, used with card or direct bank payments (i.e. Svea Hosted Web Service API)
65
	 *
66
	 * @return string
67
	 *
68
	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
69
	 * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE
70
	 */
71
	public function getMerchantId( $type, $country ) {
0 ignored issues
show
Coding Style introduced by
The function name getMerchantId is in camel caps, but expected get_merchant_id instead as per the coding standard.
Loading history...
72
		$merchantId = $this->plugin->get_option( 'merchant_key', '' );
73
74
		return $merchantId;
75
	}
76
77
	/**
78
	 * fetch secret word, used with card or direct bank payments (i.e. Svea Hosted Web Service API)
79
	 *
80
	 * @return string
81
	 *
82
	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
83
	 * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE
84
	 */
85
	public function getSecret( $type, $country ) {
0 ignored issues
show
Coding Style introduced by
The function name getSecret is in camel caps, but expected get_secret instead as per the coding standard.
Loading history...
86
		$secret = $this->plugin->get_option( 'merchant_secret', '' );
87
88
		return $secret;
89
	}
90
91
	/**
92
	 * Constants for the endpoint url found in the class ConfigurationService.php
93
	 * getEndPoint() should return an url corresponding to $type.
94
	 *
95
	 * @param string $type one of Svea\WebPay\Config\ConfigurationProvider::HOSTED_TYPE, ::INVOICE_TYPE, ::PAYMENTPLAN_TYPE, ::HOSTED_ADMIN_TYPE, ::ADMIN_TYPE
96
	 *
97
	 * @throws Exception
98
	 * @return string
99
	 */
100
101
	public function getEndPoint( $type ) { /* Defined in subclasses */
0 ignored issues
show
Coding Style introduced by
The function name getEndPoint is in camel caps, but expected get_end_point instead as per the coding standard.
Loading history...
102
	}
103
104
	/**
105
	 * fetch Checkout Merchant id, used for Checkout order type
106
	 *
107
	 * @return string
108
	 */
109
	public function getCheckoutMerchantId() {
0 ignored issues
show
Coding Style introduced by
The function name getCheckoutMerchantId is in camel caps, but expected get_checkout_merchant_id instead as per the coding standard.
Loading history...
110
		$merchantId = $this->plugin->get_option( 'merchant_key', '' );
111
112
		return $merchantId;
113
	}
114
115
	/**
116
	 * fetch Checkout Secret word, used for Checkout order type
117
	 *
118
	 * @return string
119
	 */
120
	public function getCheckoutSecret() {
0 ignored issues
show
Coding Style introduced by
The function name getCheckoutSecret is in camel caps, but expected get_checkout_secret instead as per the coding standard.
Loading history...
121
		$secret = $this->plugin->get_option( 'merchant_secret', '' );
122
123
		return $secret;
124
	}
125
126
	public function getIntegrationCompany() {
0 ignored issues
show
Coding Style introduced by
The function name getIntegrationCompany is in camel caps, but expected get_integration_company instead as per the coding standard.
Loading history...
127
		return 'MultiNet Interactive AB : EduAdmin WordPress-plugin';
128
	}
129
130
	public function getIntegrationPlatform() {
0 ignored issues
show
Coding Style introduced by
The function name getIntegrationPlatform is in camel caps, but expected get_integration_platform instead as per the coding standard.
Loading history...
131
		return 'EduAdmin WordPress';
132
	}
133
}
134
135 View Code Duplication
class EduSveaWebPayProductionConfig extends EduSveaWebPayBaseConfig {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
137
	/**
138
	 * Constants for the endpoint url found in the class ConfigurationService.php
139
	 * getEndPoint() should return an url corresponding to $type.
140
	 *
141
	 * @param string $type one of Svea\WebPay\Config\ConfigurationProvider::HOSTED_TYPE, ::INVOICE_TYPE, ::PAYMENTPLAN_TYPE, ::HOSTED_ADMIN_TYPE, ::ADMIN_TYPE
142
	 *
143
	 * @throws Exception
144
	 * @return string
145
	 */
146
147
	public function getEndPoint( $type ) {
0 ignored issues
show
Coding Style introduced by
The function name getEndPoint is in camel caps, but expected get_end_point instead as per the coding standard.
Loading history...
148
		switch ( strtoupper( $type ) ) {
149
			case 'HOSTED':
150
				return Svea\WebPay\Config\ConfigurationService::SWP_PROD_URL;
151
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
152
			case 'INVOICE':
153
			case 'PAYMENTPLAN':
154
				return Svea\WebPay\Config\ConfigurationService::SWP_PROD_WS_URL;
155
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
156
			case 'HOSTED_ADMIN':
157
				return Svea\WebPay\Config\ConfigurationService::SWP_PROD_HOSTED_ADMIN_URL;
158
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
159
			case 'ADMIN':
160
				return Svea\WebPay\Config\ConfigurationService::SWP_PROD_ADMIN_URL;
161
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
162
			case 'CHECKOUT':
163
				return Svea\WebPay\Config\ConfigurationService::CHECKOUT_PROD_BASE_URL;
164
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
165
			default:
166
				throw new Exception( 'Invalid type. Accepted values: INVOICE, PAYMENTPLAN, HOSTED, HOSTED_ADMIN, CHECKOUT' );
167
				break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
168
		}
169
	}
170
}
171
172 View Code Duplication
class EduSveaWebPayTestConfig extends EduSveaWebPayBaseConfig {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
173
174
	/**
175
	 * Constants for the endpoint url found in the class ConfigurationService.php
176
	 * getEndPoint() should return an url corresponding to $type.
177
	 *
178
	 * @param string $type one of Svea\WebPay\Config\ConfigurationProvider::HOSTED_TYPE, ::INVOICE_TYPE, ::PAYMENTPLAN_TYPE, ::HOSTED_ADMIN_TYPE, ::ADMIN_TYPE
179
	 *
180
	 * @throws Exception
181
	 * @return string
182
	 */
183
	public function getEndPoint( $type ) {
0 ignored issues
show
Coding Style introduced by
The function name getEndPoint is in camel caps, but expected get_end_point instead as per the coding standard.
Loading history...
184
		switch ( strtoupper( $type ) ) {
185
			case 'HOSTED':
186
				return Svea\WebPay\Config\ConfigurationService::SWP_TEST_URL;
187
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
188
			case 'INVOICE':
189
			case 'PAYMENTPLAN':
190
				return Svea\WebPay\Config\ConfigurationService::SWP_TEST_WS_URL;
191
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
192
			case 'HOSTED_ADMIN':
193
				return Svea\WebPay\Config\ConfigurationService::SWP_TEST_HOSTED_ADMIN_URL;
194
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
195
			case 'ADMIN':
196
				return Svea\WebPay\Config\ConfigurationService::SWP_TEST_ADMIN_URL;
197
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
198
			case 'CHECKOUT':
199
				return Svea\WebPay\Config\ConfigurationService::CHECKOUT_TEST_BASE_URL;
200
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
201
			default:
202
				throw new Exception( 'Invalid type. Accepted values: INVOICE, PAYMENTPLAN, HOSTED, HOSTED_ADMIN, CHECKOUT' );
203
				break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
204
		}
205
	}
206
207
}