Failed Conditions
Push — develop ( d8a3d8...6f0895 )
by Remco
03:41
created

Integration::get_settings_fields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 70
Code Lines 48

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 48
nc 1
nop 0
dl 0
loc 70
ccs 0
cts 59
cp 0
crap 2
rs 9.1344
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\EMS\ECommerce;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: EMS e-Commerce integration
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author Reüel van der Steege
14
 * @version 2.0.0
15
 * @since 1.0.0
16
 */
17
class Integration extends AbstractIntegration {
18
	public function __construct() {
19
		$this->id            = 'ems-ecommerce';
20
		$this->name          = 'EMS e-Commerce';
21
		$this->product_url   = '';
22
		$this->dashboard_url = array(
23
			__( 'test', 'pronamic_ideal' ) => 'https://test.ipg-online.com/vt/login',
24
			__( 'live', 'pronamic_ideal' ) => 'https://www.ipg-online.com/vt/login',
25
		);
26
		$this->provider      = 'ems';
27
28
		// Actions
29
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
30
31
		if ( ! has_action( 'wp_loaded', $function ) ) {
32
			add_action( 'wp_loaded', $function );
33
		}
34
	}
35
36
	public function get_config_factory_class() {
37
		return __NAMESPACE__ . '\ConfigFactory';
38
	}
39
40
	public function get_settings_fields() {
41
		$fields = array();
42
43
		// Storename.
44
		$fields[] = array(
45
			'section'  => 'general',
46
			'filter'   => FILTER_UNSAFE_RAW,
47
			'meta_key' => '_pronamic_gateway_ems_ecommerce_storename',
48
			'title'    => _x( 'Storename', 'ems', 'pronamic_ideal' ),
49
			'type'     => 'text',
50
			'classes'  => array( 'code' ),
51
		);
52
53
		// Shared secret.
54
		$fields[] = array(
55
			'section'  => 'general',
56
			'filter'   => FILTER_UNSAFE_RAW,
57
			'meta_key' => '_pronamic_gateway_ems_ecommerce_secret',
58
			'title'    => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ),
59
			'type'     => 'text',
60
			'classes'  => array( 'large-text', 'code' ),
61
		);
62
63
		// Purchase ID.
64
		$fields[] = array(
65
			'section'  => 'advanced',
66
			'filter'      => array(
67
				'filter' => FILTER_SANITIZE_STRING,
68
				'flags'  => FILTER_FLAG_NO_ENCODE_QUOTES,
69
			),
70
			'meta_key'    => '_pronamic_gateway_ems_ecommerce_order_id',
71
			'title'       => __( 'Order ID', 'pronamic_ideal' ),
72
			'type'        => 'text',
73
			'classes'     => array( 'regular-text', 'code' ),
74
			'tooltip'     => sprintf(
75
				/* translators: %s: <code>{orderId}</code> */
76
				__( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ),
77
				sprintf( '<code>%s</code>', 'orderId' )
78
			),
79
			'description' => sprintf(
80
				'%s %s<br />%s',
81
				__( 'Available tags:', 'pronamic_ideal' ),
82
				sprintf(
83
					'<code>%s</code> <code>%s</code>',
84
					'{order_id}',
85
					'{payment_id}'
86
				),
87
				sprintf(
88
					/* translators: %s: {order_id} */
89
					__( 'Default: <code>%s</code>', 'pronamic_ideal' ),
90
					'{order_id}'
91
				)
92
			),
93
		);
94
95
		// Notification URL.
96
		$fields[] = array(
97
			'section'  => 'feedback',
98
			'title'    => __( 'Notification URL', 'pronamic_ideal' ),
99
			'type'     => 'text',
100
			'classes'  => array( 'large-text', 'code' ),
101
			'value'    => home_url( '/' ),
102
			'readonly' => true,
103
			'tooltip'  => __(
104
				'The Notification URL as sent with each transaction to receive automatic payment status updates on.',
105
				'pronamic_ideal'
106
			),
107
		);
108
109
		return $fields;
110
	}
111
}
112