Passed
Push — develop ( 0af596...d28ea2 )
by Reüel
03:27
created
src/Client.php 1 patch
Spacing   +67 added lines, -67 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,7 +84,7 @@  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
 
@@ -100,26 +100,26 @@  discard block
 block discarded – undo
100 100
 		);
101 101
 
102 102
 		// Response code
103
-		$response_code = wp_remote_retrieve_response_code( $response );
103
+		$response_code = wp_remote_retrieve_response_code($response);
104 104
 
105
-		if ( $expected_response_code != $response_code ) { // WPCS: loose comparison ok.
106
-			$this->error = new WP_Error( 'mollie_error', 'Unexpected response code.' );
105
+		if ($expected_response_code != $response_code) { // WPCS: loose comparison ok.
106
+			$this->error = new WP_Error('mollie_error', 'Unexpected response code.');
107 107
 		}
108 108
 
109 109
 		// Body
110
-		$body = wp_remote_retrieve_body( $response );
110
+		$body = wp_remote_retrieve_body($response);
111 111
 
112
-		$data = json_decode( $body );
112
+		$data = json_decode($body);
113 113
 
114
-		if ( ! is_object( $data ) ) {
115
-			$this->error = new WP_Error( 'mollie_error', 'Could not parse response.' );
114
+		if ( ! is_object($data)) {
115
+			$this->error = new WP_Error('mollie_error', 'Could not parse response.');
116 116
 
117 117
 			return false;
118 118
 		}
119 119
 
120 120
 		// Mollie error
121
-		if ( isset( $data->error, $data->error->message ) ) {
122
-			$this->error = new \WP_Error( 'mollie_error', $data->error->message, $data->error );
121
+		if (isset($data->error, $data->error->message)) {
122
+			$this->error = new \WP_Error('mollie_error', $data->error->message, $data->error);
123 123
 
124 124
 			return false;
125 125
 		}
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 		return $data;
128 128
 	}
129 129
 
130
-	public function create_payment( PaymentRequest $request ) {
131
-		return $this->send_request( 'payments/', 'POST', $request->get_array(), 201 );
130
+	public function create_payment(PaymentRequest $request) {
131
+		return $this->send_request('payments/', 'POST', $request->get_array(), 201);
132 132
 	}
133 133
 
134 134
 	public function get_payments() {
135
-		return $this->send_request( 'payments/', 'GET' );
135
+		return $this->send_request('payments/', 'GET');
136 136
 	}
137 137
 
138
-	public function get_payment( $payment_id ) {
139
-		if ( empty( $payment_id ) ) {
138
+	public function get_payment($payment_id) {
139
+		if (empty($payment_id)) {
140 140
 			return false;
141 141
 		}
142 142
 
143
-		return $this->send_request( 'payments/' . $payment_id, 'GET' );
143
+		return $this->send_request('payments/' . $payment_id, 'GET');
144 144
 	}
145 145
 
146 146
 	/**
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 	 * @return array
150 150
 	 */
151 151
 	public function get_issuers() {
152
-		$response = $this->send_request( 'issuers/', 'GET' );
152
+		$response = $this->send_request('issuers/', 'GET');
153 153
 
154
-		if ( false === $response ) {
154
+		if (false === $response) {
155 155
 			return false;
156 156
 		}
157 157
 
158 158
 		$issuers = array();
159 159
 
160
-		if ( isset( $response->data ) ) {
161
-			foreach ( $response->data as $issuer ) {
162
-				if ( Methods::IDEAL === $issuer->method ) {
163
-					$id   = Security::filter( $issuer->id );
164
-					$name = Security::filter( $issuer->name );
160
+		if (isset($response->data)) {
161
+			foreach ($response->data as $issuer) {
162
+				if (Methods::IDEAL === $issuer->method) {
163
+					$id   = Security::filter($issuer->id);
164
+					$name = Security::filter($issuer->name);
165 165
 
166
-					$issuers[ $id ] = $name;
166
+					$issuers[$id] = $name;
167 167
 				}
168 168
 			}
169 169
 		}
@@ -178,27 +178,27 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @return array
180 180
 	 */
181
-	public function get_payment_methods( $recurring_type = '' ) {
181
+	public function get_payment_methods($recurring_type = '') {
182 182
 		$data = array();
183 183
 
184
-		if ( '' !== $recurring_type ) {
184
+		if ('' !== $recurring_type) {
185 185
 			$data['recurringType'] = $recurring_type;
186 186
 		}
187 187
 
188
-		$response = $this->send_request( 'methods/', 'GET', $data );
188
+		$response = $this->send_request('methods/', 'GET', $data);
189 189
 
190
-		if ( false === $response ) {
190
+		if (false === $response) {
191 191
 			return false;
192 192
 		}
193 193
 
194 194
 		$payment_methods = array();
195 195
 
196
-		if ( isset( $response->data ) ) {
197
-			foreach ( $response->data as $payment_method ) {
198
-				$id   = Security::filter( $payment_method->id );
199
-				$name = Security::filter( $payment_method->description );
196
+		if (isset($response->data)) {
197
+			foreach ($response->data as $payment_method) {
198
+				$id   = Security::filter($payment_method->id);
199
+				$name = Security::filter($payment_method->description);
200 200
 
201
-				$payment_methods[ $id ] = $name;
201
+				$payment_methods[$id] = $name;
202 202
 			}
203 203
 		}
204 204
 
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array|bool
217 217
 	 */
218
-	public function create_customer( $email, $name ) {
219
-		if ( empty( $email ) || empty( $name ) ) {
218
+	public function create_customer($email, $name) {
219
+		if (empty($email) || empty($name)) {
220 220
 			return false;
221 221
 		}
222 222
 
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 			201
231 231
 		);
232 232
 
233
-		if ( false === $response ) {
233
+		if (false === $response) {
234 234
 			return false;
235 235
 		}
236 236
 
237
-		if ( ! isset( $response->id ) ) {
237
+		if ( ! isset($response->id)) {
238 238
 			return false;
239 239
 		}
240 240
 
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return array
252 252
 	 */
253
-	public function get_customer( $customer_id ) {
254
-		if ( empty( $customer_id ) ) {
253
+	public function get_customer($customer_id) {
254
+		if (empty($customer_id)) {
255 255
 			return false;
256 256
 		}
257 257
 
258
-		$response = $this->send_request( 'customers/' . $customer_id, 'GET', array(), 200 );
258
+		$response = $this->send_request('customers/' . $customer_id, 'GET', array(), 200);
259 259
 
260
-		if ( false === $response ) {
260
+		if (false === $response) {
261 261
 			return false;
262 262
 		}
263 263
 
264
-		if ( is_wp_error( $this->error ) ) {
264
+		if (is_wp_error($this->error)) {
265 265
 			return false;
266 266
 		}
267 267
 
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return array
277 277
 	 */
278
-	public function get_mandates( $customer_id ) {
279
-		if ( '' === $customer_id ) {
278
+	public function get_mandates($customer_id) {
279
+		if ('' === $customer_id) {
280 280
 			return false;
281 281
 		}
282 282
 
283
-		return $this->send_request( 'customers/' . $customer_id . '/mandates?count=250', 'GET' );
283
+		return $this->send_request('customers/' . $customer_id . '/mandates?count=250', 'GET');
284 284
 	}
285 285
 
286 286
 	/**
@@ -290,21 +290,21 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return boolean
292 292
 	 */
293
-	public function has_valid_mandate( $customer_id, $payment_method = null ) {
294
-		$mandates = $this->get_mandates( $customer_id );
293
+	public function has_valid_mandate($customer_id, $payment_method = null) {
294
+		$mandates = $this->get_mandates($customer_id);
295 295
 
296
-		if ( ! $mandates ) {
296
+		if ( ! $mandates) {
297 297
 			return false;
298 298
 		}
299 299
 
300
-		$mollie_method = Methods::transform( $payment_method );
300
+		$mollie_method = Methods::transform($payment_method);
301 301
 
302
-		foreach ( $mandates->data as $mandate ) {
303
-			if ( $mollie_method !== $mandate->method ) {
302
+		foreach ($mandates->data as $mandate) {
303
+			if ($mollie_method !== $mandate->method) {
304 304
 				continue;
305 305
 			}
306 306
 
307
-			if ( 'valid' === $mandate->status ) {
307
+			if ('valid' === $mandate->status) {
308 308
 				return true;
309 309
 			}
310 310
 		}
@@ -320,37 +320,37 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @return string
322 322
 	 */
323
-	public function get_first_valid_mandate_datetime( $customer_id, $payment_method = null ) {
324
-		$mandates = $this->get_mandates( $customer_id );
323
+	public function get_first_valid_mandate_datetime($customer_id, $payment_method = null) {
324
+		$mandates = $this->get_mandates($customer_id);
325 325
 
326
-		if ( ! $mandates ) {
326
+		if ( ! $mandates) {
327 327
 			return null;
328 328
 		}
329 329
 
330
-		$mollie_method = Methods::transform( $payment_method );
330
+		$mollie_method = Methods::transform($payment_method);
331 331
 
332
-		foreach ( $mandates->data as $mandate ) {
333
-			if ( $mollie_method !== $mandate->method ) {
332
+		foreach ($mandates->data as $mandate) {
333
+			if ($mollie_method !== $mandate->method) {
334 334
 				continue;
335 335
 			}
336 336
 
337
-			if ( 'valid' !== $mandate->status ) {
337
+			if ('valid' !== $mandate->status) {
338 338
 				continue;
339 339
 			}
340 340
 
341
-			if ( ! isset( $valid_mandates ) ) {
341
+			if ( ! isset($valid_mandates)) {
342 342
 				$valid_mandates = array();
343 343
 			}
344 344
 
345
-			$valid_mandates[ $mandate->createdDatetime ] = $mandate;
345
+			$valid_mandates[$mandate->createdDatetime] = $mandate;
346 346
 		}
347 347
 
348
-		if ( isset( $valid_mandates ) ) {
349
-			ksort( $valid_mandates );
348
+		if (isset($valid_mandates)) {
349
+			ksort($valid_mandates);
350 350
 
351
-			$mandate = array_shift( $valid_mandates );
351
+			$mandate = array_shift($valid_mandates);
352 352
 
353
-			$create_date = new DateTime( $mandate->createdDatetime );
353
+			$create_date = new DateTime($mandate->createdDatetime);
354 354
 
355 355
 			return $create_date;
356 356
 		}
Please login to merge, or discard this patch.