Failed Conditions
Push — develop ( 75aa09...33c4e4 )
by Remco
03:30
created

Integration::get_settings_fields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 74
Code Lines 50

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 50
nc 1
nop 0
dl 0
loc 74
ccs 0
cts 59
cp 0
crap 2
rs 9.0909
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\Buckaroo;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: Buckaroo 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            = 'buckaroo';
20
		$this->name          = 'Buckaroo - HTML';
21
		$this->url           = 'https://plaza.buckaroo.nl/';
22
		$this->product_url   = __( 'http://www.buckaroo-payments.com', 'pronamic_ideal' );
23
		$this->dashboard_url = 'https://plaza.buckaroo.nl/';
24
		$this->provider      = 'buckaroo';
25
26
		// Actions
27
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
28
29
		if ( ! has_action( 'wp_loaded', $function ) ) {
30
			add_action( 'wp_loaded', $function );
31
		}
32
	}
33
34
	public function get_config_factory_class() {
35
		return __NAMESPACE__ . '\ConfigFactory';
36
	}
37
38
	public function get_settings_class() {
39
		return __NAMESPACE__ . '\Settings';
40
	}
41
42
	/**
43
	 * Get required settings for this integration.
44
	 *
45
	 * @link https://github.com/wp-premium/gravityforms/blob/1.9.16/includes/fields/class-gf-field-multiselect.php#L21-L42
46
	 * @since 1.2.2
47
	 * @return array
48
	 */
49
	public function get_settings() {
50
		$settings = parent::get_settings();
51
52
		$settings[] = 'buckaroo';
53
54
		return $settings;
55
	}
56
57
	public function get_settings_fields() {
58
		$fields = array();
59
60
		// Website Key.
61
		$fields[] = array(
62
			'section'  => 'general',
63
			'filter'   => FILTER_SANITIZE_STRING,
64
			'meta_key' => '_pronamic_gateway_buckaroo_website_key',
65
			'title'    => __( 'Website Key', 'pronamic_ideal' ),
66
			'type'     => 'text',
67
			'classes'  => array( 'code' ),
68
			'tooltip'  => __( 'Website key as mentioned in the Buckaroo dashboard on the page "Profile » Website".', 'pronamic_ideal' ),
69
		);
70
71
		// Secret Key.
72
		$fields[] = array(
73
			'section'  => 'general',
74
			'filter'   => FILTER_SANITIZE_STRING,
75
			'meta_key' => '_pronamic_gateway_buckaroo_secret_key',
76
			'title'    => __( 'Secret Key', 'pronamic_ideal' ),
77
			'type'     => 'text',
78
			'classes'  => array( 'regular-text', 'code' ),
79
			'tooltip'  => __( 'Secret key as mentioned in the Buckaroo dashboardb on the page "Configuration » Secret Key for Digital Signature".', 'pronamic_ideal' ),
80
		);
81
82
		// Excluded services.
83
		$fields[] = array(
84
			'section'  => 'advanced',
85
			'filter'   => FILTER_SANITIZE_STRING,
86
			'meta_key' => '_pronamic_gateway_buckaroo_excluded_services',
87
			'title'    => __( 'Excluded services', 'pronamic_ideal' ),
88
			'type'     => 'text',
89
			'classes'  => array( 'regular-text', 'code' ),
90
			'tooltip'  => sprintf(
91
				/* translators: %s: <code>brq_exludedservices</code> */
92
				__( 'This controls the Buckaroo %s parameter.', 'pronamic_ideal' ),
93
				sprintf( '<code>%s</code>', 'brq_exludedservices' )
94
			),
95
		);
96
97
		// Invoice number.
98
		$fields[] = array(
99
			'section'     => 'advanced',
100
			'filter'      => FILTER_SANITIZE_STRING,
101
			'meta_key'    => '_pronamic_gateway_buckaroo_invoice_number',
102
			'title'       => __( 'Invoice number', 'pronamic_ideal' ),
103
			'type'        => 'text',
104
			'classes'     => array( 'regular-text', 'code' ),
105
			'tooltip'     => sprintf(
106
				/* translators: %s: <code>brq_invoicenumber</code> */
107
				__( 'This controls the Buckaroo %s parameter.', 'pronamic_ideal' ),
108
				sprintf( '<code>%s</code>', 'brq_invoicenumber' )
109
			),
110
			'description' => sprintf(
111
				'%s<br />%s',
112
				/* translators: %s: <code>{order_id}</code> <code>{payment_id}</code> */
113
				sprintf( __( 'Available tags: %s', 'pronamic_ideal' ), sprintf( '<code>%s</code> <code>%s</code>', '{order_id}', '{payment_id}' ) ),
114
				/* translators: %s: <code>{payment_id}</code> */
115
				sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), '{payment_id}' )
116
			),
117
		);
118
119
		// Push URL.
120
		$fields[] = array(
121
			'section'  => 'feedback',
122
			'title'    => __( 'Push URL', 'pronamic_ideal' ),
123
			'type'     => 'text',
124
			'classes'  => array( 'large-text', 'code' ),
125
			'value'    => add_query_arg( 'buckaroo_push', '', home_url( '/' ) ),
126
			'readonly' => true,
127
			'tooltip'  => __( 'The Push URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ),
128
		);
129
130
		return $fields;
131
	}
132
}
133