Passed
Push — master ( bba4c5...886ed1 )
by Remco
04:49 queued 02:31
created
src/Integration.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
 		$this->id          = 'mollie';
30 30
 		$this->name        = 'Mollie';
31 31
 		$this->url         = 'http://www.mollie.com/en/';
32
-		$this->product_url = __( 'https://www.mollie.com/en/pricing', 'pronamic_ideal' );
32
+		$this->product_url = __('https://www.mollie.com/en/pricing', 'pronamic_ideal');
33 33
 		$this->provider    = 'mollie';
34 34
 
35 35
 		// Actions
36
-		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
36
+		$function = array(__NAMESPACE__ . '\Listener', 'listen');
37 37
 
38
-		if ( ! has_action( 'wp_loaded', $function ) ) {
39
-			add_action( 'wp_loaded', $function );
38
+		if ( ! has_action('wp_loaded', $function)) {
39
+			add_action('wp_loaded', $function);
40 40
 		}
41 41
 
42
-		if ( is_admin() ) {
43
-			$function = array( __CLASS__, 'user_profile' );
42
+		if (is_admin()) {
43
+			$function = array(__CLASS__, 'user_profile');
44 44
 
45
-			if ( ! has_action( 'show_user_profile', $function ) ) {
46
-				add_action( 'show_user_profile', $function );
45
+			if ( ! has_action('show_user_profile', $function)) {
46
+				add_action('show_user_profile', $function);
47 47
 			}
48 48
 
49
-			if ( ! has_action( 'edit_user_profile', $function ) ) {
50
-				add_action( 'edit_user_profile', $function );
49
+			if ( ! has_action('edit_user_profile', $function)) {
50
+				add_action('edit_user_profile', $function);
51 51
 			}
52 52
 		}
53 53
 
54
-		add_filter( 'pronamic_payment_provider_url_mollie', array( $this, 'payment_provider_url' ), 10, 2 );
54
+		add_filter('pronamic_payment_provider_url_mollie', array($this, 'payment_provider_url'), 10, 2);
55 55
 	}
56 56
 
57 57
 	public function get_config_factory_class() {
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * @since 1.1.6
84 84
 	 * @see https://github.com/WordPress/WordPress/blob/4.5.2/wp-admin/user-edit.php#L578-L600
85 85
 	 */
86
-	public static function user_profile( $user ) {
87
-		include dirname( __FILE__ ) . '/../views/html-admin-user-profile.php';
86
+	public static function user_profile($user) {
87
+		include dirname(__FILE__) . '/../views/html-admin-user-profile.php';
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @param Payment $payment
95 95
 	 * @return string
96 96
 	 */
97
-	public function payment_provider_url( $url, $payment ) {
97
+	public function payment_provider_url($url, $payment) {
98 98
 		return sprintf(
99 99
 			'https://www.mollie.com/dashboard/payments/%s',
100 100
 			$payment->get_transaction_id()
Please login to merge, or discard this patch.
src/Statuses.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,8 +70,8 @@
 block discarded – undo
70 70
 	 *
71 71
 	 * @param string $status
72 72
 	 */
73
-	public static function transform( $status ) {
74
-		switch ( $status ) {
73
+	public static function transform($status) {
74
+		switch ($status) {
75 75
 			case self::PENDING:
76 76
 			case self::OPEN:
77 77
 				return Core_Statuses::OPEN;
Please login to merge, or discard this patch.
src/LocaleHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @return string|null
19 19
 	 */
20
-	public static function transform( $locale ) {
20
+	public static function transform($locale) {
21 21
 		// Supported locales
22 22
 		$supported = array(
23 23
 			Locales::DE,
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 		);
29 29
 
30 30
 		// Sub string
31
-		$locale = substr( $locale, 0, 2 );
31
+		$locale = substr($locale, 0, 2);
32 32
 
33 33
 		// Lower case
34
-		$locale = strtolower( $locale );
34
+		$locale = strtolower($locale);
35 35
 
36 36
 		// Is supported?
37
-		if ( in_array( $locale, $supported, true ) ) {
37
+		if (in_array($locale, $supported, true)) {
38 38
 			return $locale;
39 39
 		}
40 40
 
Please login to merge, or discard this patch.
src/Methods.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return string
139 139
 	 */
140
-	public static function transform( $payment_method, $default = null ) {
141
-		if ( ! is_scalar( $payment_method ) ) {
140
+	public static function transform($payment_method, $default = null) {
141
+		if ( ! is_scalar($payment_method)) {
142 142
 			return null;
143 143
 		}
144 144
 
145
-		if ( isset( self::$map[ $payment_method ] ) ) {
146
-			return self::$map[ $payment_method ];
145
+		if (isset(self::$map[$payment_method])) {
146
+			return self::$map[$payment_method];
147 147
 		}
148 148
 
149 149
 		return $default;
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return string
160 160
 	 */
161
-	public static function transform_gateway_method( $method ) {
162
-		if ( ! is_scalar( $method ) ) {
161
+	public static function transform_gateway_method($method) {
162
+		if ( ! is_scalar($method)) {
163 163
 			return null;
164 164
 		}
165 165
 
166
-		$payment_method = array_search( $method, self::$map, true );
166
+		$payment_method = array_search($method, self::$map, true);
167 167
 
168
-		if ( ! $payment_method ) {
168
+		if ( ! $payment_method) {
169 169
 			return null;
170 170
 		}
171 171
 
Please login to merge, or discard this patch.
src/Settings.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	 * Settings constructor.
20 20
 	 */
21 21
 	public function __construct() {
22
-		add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) );
23
-		add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) );
22
+		add_filter('pronamic_pay_gateway_sections', array($this, 'sections'));
23
+		add_filter('pronamic_pay_gateway_fields', array($this, 'fields'));
24 24
 	}
25 25
 
26 26
 	/**
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return array
32 32
 	 */
33
-	public function sections( array $sections ) {
33
+	public function sections(array $sections) {
34 34
 		// General.
35 35
 		$sections['mollie'] = array(
36
-			'title'       => __( 'Mollie', 'pronamic_ideal' ),
37
-			'methods'     => array( 'mollie' ),
38
-			'description' => __( 'Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal' ),
36
+			'title'       => __('Mollie', 'pronamic_ideal'),
37
+			'methods'     => array('mollie'),
38
+			'description' => __('Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal'),
39 39
 		);
40 40
 
41 41
 		// Transaction feedback.
42 42
 		$sections['mollie_feedback'] = array(
43
-			'title'       => __( 'Transaction feedback', 'pronamic_ideal' ),
44
-			'methods'     => array( 'mollie' ),
45
-			'description' => __( 'Payment status updates will be processed without any additional configuration. The <em>Webhook URL</em> is being used to receive the status updates.', 'pronamic_ideal' ),
43
+			'title'       => __('Transaction feedback', 'pronamic_ideal'),
44
+			'methods'     => array('mollie'),
45
+			'description' => __('Payment status updates will be processed without any additional configuration. The <em>Webhook URL</em> is being used to receive the status updates.', 'pronamic_ideal'),
46 46
 		);
47 47
 
48 48
 		return $sections;
@@ -55,40 +55,40 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array
57 57
 	 */
58
-	public function fields( array $fields ) {
58
+	public function fields(array $fields) {
59 59
 		// API Key.
60 60
 		$fields[] = array(
61 61
 			'filter'   => FILTER_SANITIZE_STRING,
62 62
 			'section'  => 'mollie',
63 63
 			'meta_key' => '_pronamic_gateway_mollie_api_key',
64
-			'title'    => _x( 'API Key', 'mollie', 'pronamic_ideal' ),
64
+			'title'    => _x('API Key', 'mollie', 'pronamic_ideal'),
65 65
 			'type'     => 'text',
66
-			'classes'  => array( 'regular-text', 'code' ),
67
-			'methods'  => array( 'mollie' ),
68
-			'tooltip'  => __( 'API key as mentioned in the payment provider dashboard', 'pronamic_ideal' ),
66
+			'classes'  => array('regular-text', 'code'),
67
+			'methods'  => array('mollie'),
68
+			'tooltip'  => __('API key as mentioned in the payment provider dashboard', 'pronamic_ideal'),
69 69
 		);
70 70
 
71 71
 		// Transaction feedback.
72 72
 		$fields[] = array(
73 73
 			'section' => 'mollie',
74
-			'title'   => __( 'Transaction feedback', 'pronamic_ideal' ),
74
+			'title'   => __('Transaction feedback', 'pronamic_ideal'),
75 75
 			'type'    => 'description',
76 76
 			'html'    => sprintf(
77 77
 				'<span class="dashicons dashicons-yes"></span> %s',
78
-				__( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' )
78
+				__('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal')
79 79
 			),
80 80
 		);
81 81
 
82 82
 		// Webhook.
83 83
 		$fields[] = array(
84 84
 			'section'  => 'mollie_feedback',
85
-			'title'    => __( 'Webhook URL', 'pronamic_ideal' ),
85
+			'title'    => __('Webhook URL', 'pronamic_ideal'),
86 86
 			'type'     => 'text',
87
-			'classes'  => array( 'large-text', 'code' ),
88
-			'value'    => add_query_arg( 'mollie_webhook', '', home_url( '/' ) ),
87
+			'classes'  => array('large-text', 'code'),
88
+			'value'    => add_query_arg('mollie_webhook', '', home_url('/')),
89 89
 			'readonly' => true,
90
-			'methods'  => array( 'mollie' ),
91
-			'tooltip'  => __( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ),
90
+			'methods'  => array('mollie'),
91
+			'tooltip'  => __('The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal'),
92 92
 		);
93 93
 
94 94
 		return $fields;
Please login to merge, or discard this patch.
src/Listener.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 class Listener {
17 17
 	public static function listen() {
18
-		if ( ! filter_has_var( INPUT_GET, 'mollie_webhook' ) || ! filter_has_var( INPUT_POST, 'id' ) ) {
18
+		if ( ! filter_has_var(INPUT_GET, 'mollie_webhook') || ! filter_has_var(INPUT_POST, 'id')) {
19 19
 			return;
20 20
 		}
21 21
 
22
-		$transaction_id = filter_input( INPUT_POST, 'id', FILTER_SANITIZE_STRING );
22
+		$transaction_id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_STRING);
23 23
 
24
-		$payment = get_pronamic_payment_by_transaction_id( $transaction_id );
24
+		$payment = get_pronamic_payment_by_transaction_id($transaction_id);
25 25
 
26
-		if ( null === $payment ) {
26
+		if (null === $payment) {
27 27
 			return;
28 28
 		}
29 29
 
30 30
 		// Add note.
31 31
 		$note = sprintf(
32 32
 			/* translators: %s: Mollie */
33
-			__( 'Webhook requested by %s.', 'pronamic_ideal' ),
34
-			__( 'Mollie', 'pronamic_ideal' )
33
+			__('Webhook requested by %s.', 'pronamic_ideal'),
34
+			__('Mollie', 'pronamic_ideal')
35 35
 		);
36 36
 
37
-		$payment->add_note( $note );
37
+		$payment->add_note($note);
38 38
 
39 39
 		// Update payment.
40
-		Plugin::update_payment( $payment, false );
40
+		Plugin::update_payment($payment, false);
41 41
 	}
42 42
 }
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @param string $api_key
53 53
 	 */
54
-	public function __construct( $api_key ) {
54
+	public function __construct($api_key) {
55 55
 		$this->api_key = $api_key;
56 56
 	}
57 57
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @since 1.1.9
62 62
 	 * @param string $mode
63 63
 	 */
64
-	public function set_mode( $mode ) {
64
+	public function set_mode($mode) {
65 65
 		$this->mode = $mode;
66 66
 	}
67 67
 
@@ -84,39 +84,39 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return bool|object
86 86
 	 */
87
-	private function send_request( $end_point, $method = 'GET', array $data = array(), $expected_response_code = 200 ) {
87
+	private function send_request($end_point, $method = 'GET', array $data = array(), $expected_response_code = 200) {
88 88
 		// Request
89 89
 		$url = self::API_URL . $end_point;
90 90
 
91
-		$response = wp_remote_request( $url, array(
91
+		$response = wp_remote_request($url, array(
92 92
 			'method'  => $method,
93 93
 			'headers' => array(
94 94
 				'Authorization' => 'Bearer ' . $this->api_key,
95 95
 			),
96 96
 			'body'    => $data,
97
-		) );
97
+		));
98 98
 
99 99
 		// Response code
100
-		$response_code = wp_remote_retrieve_response_code( $response );
100
+		$response_code = wp_remote_retrieve_response_code($response);
101 101
 
102
-		if ( $expected_response_code != $response_code ) { // WPCS: loose comparison ok.
103
-			$this->error = new WP_Error( 'mollie_error', 'Unexpected response code.' );
102
+		if ($expected_response_code != $response_code) { // WPCS: loose comparison ok.
103
+			$this->error = new WP_Error('mollie_error', 'Unexpected response code.');
104 104
 		}
105 105
 
106 106
 		// Body
107
-		$body = wp_remote_retrieve_body( $response );
107
+		$body = wp_remote_retrieve_body($response);
108 108
 
109
-		$data = json_decode( $body );
109
+		$data = json_decode($body);
110 110
 
111
-		if ( ! is_object( $data ) ) {
112
-			$this->error = new WP_Error( 'mollie_error', 'Could not parse response.' );
111
+		if ( ! is_object($data)) {
112
+			$this->error = new WP_Error('mollie_error', 'Could not parse response.');
113 113
 
114 114
 			return false;
115 115
 		}
116 116
 
117 117
 		// Mollie error
118
-		if ( isset( $data->error, $data->error->message ) ) {
119
-			$this->error = new \WP_Error( 'mollie_error', $data->error->message, $data->error );
118
+		if (isset($data->error, $data->error->message)) {
119
+			$this->error = new \WP_Error('mollie_error', $data->error->message, $data->error);
120 120
 
121 121
 			return false;
122 122
 		}
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 		return $data;
125 125
 	}
126 126
 
127
-	public function create_payment( PaymentRequest $request ) {
128
-		return $this->send_request( 'payments/', 'POST', $request->get_array(), 201 );
127
+	public function create_payment(PaymentRequest $request) {
128
+		return $this->send_request('payments/', 'POST', $request->get_array(), 201);
129 129
 	}
130 130
 
131 131
 	public function get_payments() {
132
-		return $this->send_request( 'payments/', 'GET' );
132
+		return $this->send_request('payments/', 'GET');
133 133
 	}
134 134
 
135
-	public function get_payment( $payment_id ) {
136
-		if ( empty( $payment_id ) ) {
135
+	public function get_payment($payment_id) {
136
+		if (empty($payment_id)) {
137 137
 			return false;
138 138
 		}
139 139
 
140
-		return $this->send_request( 'payments/' . $payment_id, 'GET' );
140
+		return $this->send_request('payments/' . $payment_id, 'GET');
141 141
 	}
142 142
 
143 143
 	/**
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 	 * @return array
147 147
 	 */
148 148
 	public function get_issuers() {
149
-		$response = $this->send_request( 'issuers/', 'GET' );
149
+		$response = $this->send_request('issuers/', 'GET');
150 150
 
151
-		if ( false === $response ) {
151
+		if (false === $response) {
152 152
 			return false;
153 153
 		}
154 154
 
155 155
 		$issuers = array();
156 156
 
157
-		if ( isset( $response->data ) ) {
158
-			foreach ( $response->data as $issuer ) {
159
-				if ( Methods::IDEAL === $issuer->method ) {
160
-					$id   = Security::filter( $issuer->id );
161
-					$name = Security::filter( $issuer->name );
157
+		if (isset($response->data)) {
158
+			foreach ($response->data as $issuer) {
159
+				if (Methods::IDEAL === $issuer->method) {
160
+					$id   = Security::filter($issuer->id);
161
+					$name = Security::filter($issuer->name);
162 162
 
163
-					$issuers[ $id ] = $name;
163
+					$issuers[$id] = $name;
164 164
 				}
165 165
 			}
166 166
 		}
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return array
177 177
 	 */
178
-	public function get_payment_methods( $recurring_type = '' ) {
178
+	public function get_payment_methods($recurring_type = '') {
179 179
 		$data = array();
180 180
 
181
-		if ( '' !== $recurring_type ) {
181
+		if ('' !== $recurring_type) {
182 182
 			$data['recurringType'] = $recurring_type;
183 183
 		}
184 184
 
185
-		$response = $this->send_request( 'methods/', 'GET', $data );
185
+		$response = $this->send_request('methods/', 'GET', $data);
186 186
 
187
-		if ( false === $response ) {
187
+		if (false === $response) {
188 188
 			return false;
189 189
 		}
190 190
 
191 191
 		$payment_methods = array();
192 192
 
193
-		if ( isset( $response->data ) ) {
194
-			foreach ( $response->data as $payment_method ) {
195
-				$id   = Security::filter( $payment_method->id );
196
-				$name = Security::filter( $payment_method->description );
193
+		if (isset($response->data)) {
194
+			foreach ($response->data as $payment_method) {
195
+				$id   = Security::filter($payment_method->id);
196
+				$name = Security::filter($payment_method->description);
197 197
 
198
-				$payment_methods[ $id ] = $name;
198
+				$payment_methods[$id] = $name;
199 199
 			}
200 200
 		}
201 201
 
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return array|bool
214 214
 	 */
215
-	public function create_customer( $email, $name ) {
216
-		if ( empty( $email ) || empty( $name ) ) {
215
+	public function create_customer($email, $name) {
216
+		if (empty($email) || empty($name)) {
217 217
 			return false;
218 218
 		}
219 219
 
220
-		$response = $this->send_request( 'customers/', 'POST', array(
220
+		$response = $this->send_request('customers/', 'POST', array(
221 221
 			'name'  => $name,
222 222
 			'email' => $email,
223
-		), 201 );
223
+		), 201);
224 224
 
225
-		if ( false === $response ) {
225
+		if (false === $response) {
226 226
 			return false;
227 227
 		}
228 228
 
229
-		if ( ! isset( $response->id ) ) {
229
+		if ( ! isset($response->id)) {
230 230
 			return false;
231 231
 		}
232 232
 
@@ -242,18 +242,18 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return array
244 244
 	 */
245
-	public function get_customer( $customer_id ) {
246
-		if ( empty( $customer_id ) ) {
245
+	public function get_customer($customer_id) {
246
+		if (empty($customer_id)) {
247 247
 			return false;
248 248
 		}
249 249
 
250
-		$response = $this->send_request( 'customers/' . $customer_id, 'GET', array(), 200 );
250
+		$response = $this->send_request('customers/' . $customer_id, 'GET', array(), 200);
251 251
 
252
-		if ( false === $response ) {
252
+		if (false === $response) {
253 253
 			return false;
254 254
 		}
255 255
 
256
-		if ( is_wp_error( $this->error ) ) {
256
+		if (is_wp_error($this->error)) {
257 257
 			return false;
258 258
 		}
259 259
 
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @return array
269 269
 	 */
270
-	public function get_mandates( $customer_id ) {
271
-		if ( '' === $customer_id ) {
270
+	public function get_mandates($customer_id) {
271
+		if ('' === $customer_id) {
272 272
 			return false;
273 273
 		}
274 274
 
275
-		return $this->send_request( 'customers/' . $customer_id . '/mandates?count=250', 'GET' );
275
+		return $this->send_request('customers/' . $customer_id . '/mandates?count=250', 'GET');
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,21 +282,21 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * @return boolean
284 284
 	 */
285
-	public function has_valid_mandate( $customer_id, $payment_method = null ) {
286
-		$mandates = $this->get_mandates( $customer_id );
285
+	public function has_valid_mandate($customer_id, $payment_method = null) {
286
+		$mandates = $this->get_mandates($customer_id);
287 287
 
288
-		if ( ! $mandates ) {
288
+		if ( ! $mandates) {
289 289
 			return false;
290 290
 		}
291 291
 
292
-		$mollie_method = Methods::transform( $payment_method );
292
+		$mollie_method = Methods::transform($payment_method);
293 293
 
294
-		foreach ( $mandates->data as $mandate ) {
295
-			if ( $mollie_method !== $mandate->method ) {
294
+		foreach ($mandates->data as $mandate) {
295
+			if ($mollie_method !== $mandate->method) {
296 296
 				continue;
297 297
 			}
298 298
 
299
-			if ( 'valid' === $mandate->status ) {
299
+			if ('valid' === $mandate->status) {
300 300
 				return true;
301 301
 			}
302 302
 		}
@@ -312,37 +312,37 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return string
314 314
 	 */
315
-	public function get_first_valid_mandate_datetime( $customer_id, $payment_method = null ) {
316
-		$mandates = $this->get_mandates( $customer_id );
315
+	public function get_first_valid_mandate_datetime($customer_id, $payment_method = null) {
316
+		$mandates = $this->get_mandates($customer_id);
317 317
 
318
-		if ( ! $mandates ) {
318
+		if ( ! $mandates) {
319 319
 			return null;
320 320
 		}
321 321
 
322
-		$mollie_method = Methods::transform( $payment_method );
322
+		$mollie_method = Methods::transform($payment_method);
323 323
 
324
-		foreach ( $mandates->data as $mandate ) {
325
-			if ( $mollie_method !== $mandate->method ) {
324
+		foreach ($mandates->data as $mandate) {
325
+			if ($mollie_method !== $mandate->method) {
326 326
 				continue;
327 327
 			}
328 328
 
329
-			if ( 'valid' !== $mandate->status ) {
329
+			if ('valid' !== $mandate->status) {
330 330
 				continue;
331 331
 			}
332 332
 
333
-			if ( ! isset( $valid_mandates ) ) {
333
+			if ( ! isset($valid_mandates)) {
334 334
 				$valid_mandates = array();
335 335
 			}
336 336
 
337
-			$valid_mandates[ $mandate->createdDatetime ] = $mandate;
337
+			$valid_mandates[$mandate->createdDatetime] = $mandate;
338 338
 		}
339 339
 
340
-		if ( isset( $valid_mandates ) ) {
341
-			ksort( $valid_mandates );
340
+		if (isset($valid_mandates)) {
341
+			ksort($valid_mandates);
342 342
 
343
-			$mandate = array_shift( $valid_mandates );
343
+			$mandate = array_shift($valid_mandates);
344 344
 
345
-			$create_date = new DateTime( $mandate->createdDatetime );
345
+			$create_date = new DateTime($mandate->createdDatetime);
346 346
 
347 347
 			return $create_date;
348 348
 		}
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param Config $config
40 40
 	 */
41
-	public function __construct( Config $config ) {
42
-		parent::__construct( $config );
41
+	public function __construct(Config $config) {
42
+		parent::__construct($config);
43 43
 
44 44
 		$this->supports = array(
45 45
 			'payment_status_request',
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 			'recurring',
49 49
 		);
50 50
 
51
-		$this->set_method( Core_Gateway::METHOD_HTTP_REDIRECT );
52
-		$this->set_has_feedback( true );
53
-		$this->set_amount_minimum( 1.20 );
54
-		$this->set_slug( self::SLUG );
51
+		$this->set_method(Core_Gateway::METHOD_HTTP_REDIRECT);
52
+		$this->set_has_feedback(true);
53
+		$this->set_amount_minimum(1.20);
54
+		$this->set_slug(self::SLUG);
55 55
 
56
-		$this->client = new Client( $config->api_key );
57
-		$this->client->set_mode( $config->mode );
56
+		$this->client = new Client($config->api_key);
57
+		$this->client->set_mode($config->mode);
58 58
 
59
-		if ( 'test' === $config->mode ) {
59
+		if ('test' === $config->mode) {
60 60
 			$this->meta_key_customer_id = '_pronamic_pay_mollie_customer_id_test';
61 61
 		}
62 62
 
63 63
 		// Actions.
64
-		add_action( 'pronamic_payment_status_update', array( $this, 'move_customer_id_to_wp_user' ), 99, 1 );
64
+		add_action('pronamic_payment_status_update', array($this, 'move_customer_id_to_wp_user'), 99, 1);
65 65
 	}
66 66
 
67 67
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
 		$result = $this->client->get_issuers();
76 76
 
77
-		if ( ! $result ) {
77
+		if ( ! $result) {
78 78
 			$this->error = $this->client->get_error();
79 79
 
80 80
 			return $groups;
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	public function get_issuer_field() {
91
-		if ( PaymentMethods::IDEAL === $this->get_payment_method() ) {
91
+		if (PaymentMethods::IDEAL === $this->get_payment_method()) {
92 92
 			return array(
93 93
 				'id'       => 'pronamic_ideal_issuer_id',
94 94
 				'name'     => 'pronamic_ideal_issuer_id',
95
-				'label'    => __( 'Choose your bank', 'pronamic_ideal' ),
95
+				'label'    => __('Choose your bank', 'pronamic_ideal'),
96 96
 				'required' => true,
97 97
 				'type'     => 'select',
98 98
 				'choices'  => $this->get_transient_issuers(),
@@ -109,51 +109,51 @@  discard block
 block discarded – undo
109 109
 		$payment_methods = array();
110 110
 
111 111
 		// Set recurring types to get payment methods for.
112
-		$recurring_types = array( null, Recurring::RECURRING, Recurring::FIRST );
112
+		$recurring_types = array(null, Recurring::RECURRING, Recurring::FIRST);
113 113
 
114 114
 		$results = array();
115 115
 
116
-		foreach ( $recurring_types as $recurring_type ) {
116
+		foreach ($recurring_types as $recurring_type) {
117 117
 			// Get active payment methods for Mollie account.
118
-			$result = $this->client->get_payment_methods( $recurring_type );
118
+			$result = $this->client->get_payment_methods($recurring_type);
119 119
 
120
-			if ( ! $result ) {
120
+			if ( ! $result) {
121 121
 				$this->error = $this->client->get_error();
122 122
 
123 123
 				break;
124 124
 			}
125 125
 
126
-			if ( Recurring::FIRST === $recurring_type ) {
127
-				foreach ( $result as $method => $title ) {
128
-					unset( $result[ $method ] );
126
+			if (Recurring::FIRST === $recurring_type) {
127
+				foreach ($result as $method => $title) {
128
+					unset($result[$method]);
129 129
 
130 130
 					// Get WordPress payment method for direct debit method.
131
-					$method         = Methods::transform_gateway_method( $method );
132
-					$payment_method = array_search( $method, PaymentMethods::get_recurring_methods(), true );
131
+					$method         = Methods::transform_gateway_method($method);
132
+					$payment_method = array_search($method, PaymentMethods::get_recurring_methods(), true);
133 133
 
134
-					if ( $payment_method ) {
135
-						$results[ $payment_method ] = $title;
134
+					if ($payment_method) {
135
+						$results[$payment_method] = $title;
136 136
 					}
137 137
 				}
138 138
 			}
139 139
 
140
-			$results = array_merge( $results, $result );
140
+			$results = array_merge($results, $result);
141 141
 		}
142 142
 
143 143
 		// Transform to WordPress payment methods.
144
-		foreach ( $results as $method => $title ) {
145
-			if ( PaymentMethods::is_recurring_method( $method ) ) {
144
+		foreach ($results as $method => $title) {
145
+			if (PaymentMethods::is_recurring_method($method)) {
146 146
 				$payment_method = $method;
147 147
 			} else {
148
-				$payment_method = Methods::transform_gateway_method( $method );
148
+				$payment_method = Methods::transform_gateway_method($method);
149 149
 			}
150 150
 
151
-			if ( $payment_method ) {
151
+			if ($payment_method) {
152 152
 				$payment_methods[] = $payment_method;
153 153
 			}
154 154
 		}
155 155
 
156
-		$payment_methods = array_unique( $payment_methods );
156
+		$payment_methods = array_unique($payment_methods);
157 157
 
158 158
 		return $payment_methods;
159 159
 	}
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	private function get_webhook_url() {
190
-		$url = home_url( '/' );
190
+		$url = home_url('/');
191 191
 
192
-		$host = wp_parse_url( $url, PHP_URL_HOST );
192
+		$host = wp_parse_url($url, PHP_URL_HOST);
193 193
 
194
-		if ( 'localhost' === $host ) {
194
+		if ('localhost' === $host) {
195 195
 			// Mollie doesn't allow localhost
196 196
 			return null;
197
-		} elseif ( '.dev' === substr( $host, -4 ) ) {
197
+		} elseif ('.dev' === substr($host, -4)) {
198 198
 			// Mollie doesn't allow the TLD .dev
199 199
 			return null;
200 200
 		}
201 201
 
202
-		$url = add_query_arg( 'mollie_webhook', '', $url );
202
+		$url = add_query_arg('mollie_webhook', '', $url);
203 203
 
204 204
 		return $url;
205 205
 	}
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @see Pronamic_WP_Pay_Gateway::start()
211 211
 	 */
212
-	public function start( Payment $payment ) {
212
+	public function start(Payment $payment) {
213 213
 		$request = new PaymentRequest();
214 214
 
215 215
 		$request->amount       = $payment->get_amount()->get_amount();
216 216
 		$request->description  = $payment->get_description();
217 217
 		$request->redirect_url = $payment->get_return_url();
218 218
 		$request->webhook_url  = $this->get_webhook_url();
219
-		$request->locale       = LocaleHelper::transform( $payment->get_language() );
219
+		$request->locale       = LocaleHelper::transform($payment->get_language());
220 220
 
221 221
 		// Issuer.
222
-		if ( Methods::IDEAL === $request->method ) {
222
+		if (Methods::IDEAL === $request->method) {
223 223
 			// If payment method is iDEAL we set the user chosen issuer ID.
224 224
 			$request->issuer = $payment->get_issuer();
225 225
 		}
226 226
 
227 227
 		// Customer ID.
228
-		$customer_id = $this->get_customer_id_for_payment( $payment );
228
+		$customer_id = $this->get_customer_id_for_payment($payment);
229 229
 
230
-		if ( ! empty( $customer_id ) ) {
230
+		if ( ! empty($customer_id)) {
231 231
 			$request->customer_id = $customer_id;
232 232
 		}
233 233
 
@@ -237,43 +237,43 @@  discard block
 block discarded – undo
237 237
 		// Subscription.
238 238
 		$subscription = $payment->get_subscription();
239 239
 
240
-		if ( $subscription && PaymentMethods::is_recurring_method( $payment_method ) ) {
240
+		if ($subscription && PaymentMethods::is_recurring_method($payment_method)) {
241 241
 			$request->recurring_type = $payment->get_recurring() ? Recurring::RECURRING : Recurring::FIRST;
242 242
 
243
-			if ( Recurring::FIRST === $request->recurring_type ) {
244
-				$payment_method = PaymentMethods::get_first_payment_method( $payment_method );
243
+			if (Recurring::FIRST === $request->recurring_type) {
244
+				$payment_method = PaymentMethods::get_first_payment_method($payment_method);
245 245
 			}
246 246
 
247
-			if ( Recurring::RECURRING === $request->recurring_type ) {
248
-				$payment->set_action_url( $payment->get_return_url() );
247
+			if (Recurring::RECURRING === $request->recurring_type) {
248
+				$payment->set_action_url($payment->get_return_url());
249 249
 			}
250 250
 		}
251 251
 
252 252
 		// Leap of faith if the WordPress payment method could not transform to a Mollie method?
253
-		$request->method = Methods::transform( $payment_method, $payment_method );
253
+		$request->method = Methods::transform($payment_method, $payment_method);
254 254
 
255 255
 		// Create payment.
256
-		$result = $this->client->create_payment( $request );
256
+		$result = $this->client->create_payment($request);
257 257
 
258
-		if ( ! $result ) {
258
+		if ( ! $result) {
259 259
 			$this->error = $this->client->get_error();
260 260
 
261 261
 			return false;
262 262
 		}
263 263
 
264 264
 		// Set transaction ID.
265
-		if ( isset( $result->id ) ) {
266
-			$payment->set_transaction_id( $result->id );
265
+		if (isset($result->id)) {
266
+			$payment->set_transaction_id($result->id);
267 267
 		}
268 268
 
269 269
 		// Set status
270
-		if ( isset( $result->status ) ) {
271
-			$payment->set_status( Statuses::transform( $result->status ) );
270
+		if (isset($result->status)) {
271
+			$payment->set_status(Statuses::transform($result->status));
272 272
 		}
273 273
 
274 274
 		// Set action URL.
275
-		if ( isset( $result->links, $result->links->paymentUrl ) ) {
276
-			$payment->set_action_url( $result->links->paymentUrl );
275
+		if (isset($result->links, $result->links->paymentUrl)) {
276
+			$payment->set_action_url($result->links->paymentUrl);
277 277
 		}
278 278
 	}
279 279
 
@@ -282,36 +282,36 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * @param Payment $payment
284 284
 	 */
285
-	public function update_status( Payment $payment ) {
286
-		$mollie_payment = $this->client->get_payment( $payment->get_transaction_id() );
285
+	public function update_status(Payment $payment) {
286
+		$mollie_payment = $this->client->get_payment($payment->get_transaction_id());
287 287
 
288
-		if ( ! $mollie_payment ) {
289
-			$payment->set_status( Core_Statuses::FAILURE );
288
+		if ( ! $mollie_payment) {
289
+			$payment->set_status(Core_Statuses::FAILURE);
290 290
 
291 291
 			$this->error = $this->client->get_error();
292 292
 
293 293
 			return;
294 294
 		}
295 295
 
296
-		$payment->set_status( Statuses::transform( $mollie_payment->status ) );
296
+		$payment->set_status(Statuses::transform($mollie_payment->status));
297 297
 
298
-		if ( isset( $mollie_payment->details ) ) {
298
+		if (isset($mollie_payment->details)) {
299 299
 			$details = $mollie_payment->details;
300 300
 
301
-			if ( isset( $details->consumerName ) ) {
302
-				$payment->set_consumer_name( $details->consumerName );
301
+			if (isset($details->consumerName)) {
302
+				$payment->set_consumer_name($details->consumerName);
303 303
 			}
304 304
 
305
-			if ( isset( $details->cardHolder ) ) {
306
-				$payment->set_consumer_name( $details->cardHolder );
305
+			if (isset($details->cardHolder)) {
306
+				$payment->set_consumer_name($details->cardHolder);
307 307
 			}
308 308
 
309
-			if ( isset( $details->consumerAccount ) ) {
310
-				$payment->set_consumer_iban( $details->consumerAccount );
309
+			if (isset($details->consumerAccount)) {
310
+				$payment->set_consumer_iban($details->consumerAccount);
311 311
 			}
312 312
 
313
-			if ( isset( $details->consumerBic ) ) {
314
-				$payment->set_consumer_bic( $details->consumerBic );
313
+			if (isset($details->consumerBic)) {
314
+				$payment->set_consumer_bic($details->consumerBic);
315 315
 			}
316 316
 		}
317 317
 	}
@@ -323,35 +323,35 @@  discard block
 block discarded – undo
323 323
 	 *
324 324
 	 * @return bool|string
325 325
 	 */
326
-	private function get_customer_id_for_payment( Payment $payment ) {
326
+	private function get_customer_id_for_payment(Payment $payment) {
327 327
 		// Get Mollie customer ID from user meta.
328
-		$customer_id = $this->get_customer_id_by_wp_user_id( $payment->user_id );
328
+		$customer_id = $this->get_customer_id_by_wp_user_id($payment->user_id);
329 329
 
330
-		if ( Core_Recurring::FIRST === $payment->recurring_type ) {
330
+		if (Core_Recurring::FIRST === $payment->recurring_type) {
331 331
 			// Create new customer if the customer does not exist at Mollie.
332
-			if ( empty( $customer_id ) || ! $this->client->get_customer( $customer_id ) ) {
333
-				$customer_id = $this->client->create_customer( $payment->get_email(), $payment->get_customer_name() );
332
+			if (empty($customer_id) || ! $this->client->get_customer($customer_id)) {
333
+				$customer_id = $this->client->create_customer($payment->get_email(), $payment->get_customer_name());
334 334
 
335
-				$this->update_wp_user_customer_id( $payment->user_id, $customer_id );
335
+				$this->update_wp_user_customer_id($payment->user_id, $customer_id);
336 336
 			}
337 337
 
338 338
 			// Temporarily store customer ID in subscription meta for guest users.
339
-			if ( empty( $payment->user_id ) && ! empty( $customer_id ) ) {
339
+			if (empty($payment->user_id) && ! empty($customer_id)) {
340 340
 				$subscription = $payment->get_subscription();
341 341
 
342
-				if ( $subscription ) {
343
-					$subscription->set_meta( 'mollie_customer_id', $customer_id );
342
+				if ($subscription) {
343
+					$subscription->set_meta('mollie_customer_id', $customer_id);
344 344
 				}
345 345
 			}
346 346
 		}
347 347
 
348 348
 		// Try to get customer ID from subscription meta.
349
-		if ( empty( $customer_id ) ) {
349
+		if (empty($customer_id)) {
350 350
 			// Move customer ID from subscription meta to user meta.
351
-			$this->move_customer_id_to_wp_user( $payment );
351
+			$this->move_customer_id_to_wp_user($payment);
352 352
 
353 353
 			// Get customer ID from user meta, again.
354
-			$customer_id = $this->get_customer_id_by_wp_user_id( $payment->user_id );
354
+			$customer_id = $this->get_customer_id_by_wp_user_id($payment->user_id);
355 355
 		}
356 356
 
357 357
 		return $customer_id;
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
 	 *
365 365
 	 * @return string
366 366
 	 */
367
-	private function get_customer_id_by_wp_user_id( $user_id ) {
368
-		if ( empty( $user_id ) ) {
367
+	private function get_customer_id_by_wp_user_id($user_id) {
368
+		if (empty($user_id)) {
369 369
 			return false;
370 370
 		}
371 371
 
372
-		return get_user_meta( $user_id, $this->meta_key_customer_id, true );
372
+		return get_user_meta($user_id, $this->meta_key_customer_id, true);
373 373
 	}
374 374
 
375 375
 	/**
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @return bool
382 382
 	 */
383
-	private function update_wp_user_customer_id( $user_id, $customer_id ) {
384
-		if ( empty( $user_id ) || empty( $customer_id ) ) {
383
+	private function update_wp_user_customer_id($user_id, $customer_id) {
384
+		if (empty($user_id) || empty($customer_id)) {
385 385
 			return false;
386 386
 		}
387 387
 
388
-		update_user_meta( $user_id, $this->meta_key_customer_id, $customer_id );
388
+		update_user_meta($user_id, $this->meta_key_customer_id, $customer_id);
389 389
 	}
390 390
 
391 391
 	/**
@@ -395,26 +395,26 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return void
397 397
 	 */
398
-	public function move_customer_id_to_wp_user( Payment $payment ) {
399
-		if ( $this->config->id !== $payment->config_id ) {
398
+	public function move_customer_id_to_wp_user(Payment $payment) {
399
+		if ($this->config->id !== $payment->config_id) {
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		$subscription = $payment->get_subscription();
404 404
 
405
-		if ( ! $subscription || empty( $subscription->user_id ) ) {
405
+		if ( ! $subscription || empty($subscription->user_id)) {
406 406
 			return;
407 407
 		}
408 408
 
409 409
 		// Get customer ID from subscription meta.
410
-		$customer_id = $subscription->get_meta( 'mollie_customer_id' );
410
+		$customer_id = $subscription->get_meta('mollie_customer_id');
411 411
 
412
-		if ( ! empty( $customer_id ) && ! empty( $subscription->user_id ) ) {
412
+		if ( ! empty($customer_id) && ! empty($subscription->user_id)) {
413 413
 			// Set customer ID as user meta.
414
-			$this->update_wp_user_customer_id( $subscription->user_id, $customer_id );
414
+			$this->update_wp_user_customer_id($subscription->user_id, $customer_id);
415 415
 
416 416
 			// Delete customer ID from subscription meta.
417
-			$subscription->set_meta( 'mollie_customer_id', null );
417
+			$subscription->set_meta('mollie_customer_id', null);
418 418
 		}
419 419
 	}
420 420
 }
Please login to merge, or discard this patch.
src/ConfigFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
  * @since   1.0.0
16 16
  */
17 17
 class ConfigFactory extends GatewayConfigFactory {
18
-	public function get_config( $post_id ) {
18
+	public function get_config($post_id) {
19 19
 		$config = new Config();
20 20
 
21
-		$config->api_key = get_post_meta( $post_id, '_pronamic_gateway_mollie_api_key', true );
22
-		$config->mode    = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
21
+		$config->api_key = get_post_meta($post_id, '_pronamic_gateway_mollie_api_key', true);
22
+		$config->mode    = get_post_meta($post_id, '_pronamic_gateway_mode', true);
23 23
 
24 24
 		return $config;
25 25
 	}
Please login to merge, or discard this patch.