Passed
Push — develop ( 06c5d6...cefaa3 )
by Remco
04:17
created
src/Gateway.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 		// Set the name of this gateway.
57 57
 		// @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L12-13.
58
-		$this->name = __( 'Pronamic', 'pronamic_ideal' );
58
+		$this->name = __('Pronamic', 'pronamic_ideal');
59 59
 
60
-		if ( ! empty( $this->payment_method ) ) {
61
-			$this->name = PaymentMethods::get_name( $this->payment_method );
60
+		if ( ! empty($this->payment_method)) {
61
+			$this->name = PaymentMethods::get_name($this->payment_method);
62 62
 		}
63 63
 
64 64
 		// Set the default settings.
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $settings MemberPress gateway settings array.
82 82
 	 */
83
-	public function load( $settings ) {
83
+	public function load($settings) {
84 84
 		$this->settings = (object) $settings;
85 85
 
86 86
 		$this->set_defaults();
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return mixed
99 99
 	 */
100
-	public function send_transaction_notices( $transaction, $method ) {
100
+	public function send_transaction_notices($transaction, $method) {
101 101
 		$class = 'MeprUtils';
102 102
 
103
-		if ( ! Core_Util::class_method_exists( $class, $method ) ) {
103
+		if ( ! Core_Util::class_method_exists($class, $method)) {
104 104
 			$class = $this;
105 105
 		}
106 106
 
107
-		if ( 'MeprUtils' === $class && 'send_product_welcome_notices' === $method ) {
107
+		if ('MeprUtils' === $class && 'send_product_welcome_notices' === $method) {
108 108
 			// `send_product_welcome_notices` is called from `send_signup_notices` in newer versions.
109 109
 			return;
110 110
 		}
111 111
 
112
-		return call_user_func( array( $class, $method ), $transaction );
112
+		return call_user_func(array($class, $method), $transaction);
113 113
 	}
114 114
 
115 115
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L72-73
138 138
 	 */
139 139
 	protected function set_defaults() {
140
-		if ( ! isset( $this->settings ) ) {
140
+		if ( ! isset($this->settings)) {
141 141
 			$this->settings = array();
142 142
 		}
143 143
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L119-122
177 177
 	 */
178
-	public function process_payment( $txn ) {
178
+	public function process_payment($txn) {
179 179
 
180 180
 	}
181 181
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$subscription = $transaction->subscription();
194 194
 
195
-		if ( $subscription ) {
196
-			if ( MeprSubscription::$active_str !== $subscription->status ) {
195
+		if ($subscription) {
196
+			if (MeprSubscription::$active_str !== $subscription->status) {
197 197
 				$subscription->status = MeprSubscription::$active_str;
198 198
 				$subscription->store();
199 199
 			}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			$subscription->limit_payment_cycles();
202 202
 		}
203 203
 
204
-		$this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' );
204
+		$this->send_transaction_notices($transaction, 'send_transaction_receipt_notices');
205 205
 
206 206
 		return $transaction;
207 207
 	}
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 		// Expire associated transactions for subscription.
222 222
 		$subscription = $transaction->subscription();
223 223
 
224
-		if ( $subscription ) {
224
+		if ($subscription) {
225 225
 			$subscription->expire_txns();
226 226
 			$subscription->store();
227 227
 		}
228 228
 
229
-		$this->send_transaction_notices( $transaction, 'send_failed_txn_notices' );
229
+		$this->send_transaction_notices($transaction, 'send_failed_txn_notices');
230 230
 
231 231
 		return $transaction;
232 232
 	}
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
 
251 251
 		$subscription = $transaction->subscription();
252 252
 
253
-		if ( $subscription ) {
253
+		if ($subscription) {
254 254
 			$subscription->status     = MeprSubscription::$active_str;
255 255
 			$subscription->created_at = $transaction->created_at;
256 256
 			$subscription->store();
257 257
 
258 258
 			// Set subscription first transaction id meta.
259
-			$pronamic_subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $subscription->first_txn_id );
259
+			$pronamic_subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $subscription->first_txn_id);
260 260
 
261
-			if ( $pronamic_subscription ) {
261
+			if ($pronamic_subscription) {
262 262
 				// Store MemberPress subscription id to be able to cancel subscription on delete.
263
-				$pronamic_subscription->set_meta( 'memberpress_subscription_id', $subscription->id );
263
+				$pronamic_subscription->set_meta('memberpress_subscription_id', $subscription->id);
264 264
 			}
265 265
 		}
266 266
 
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
 		 * @see https://github.com/wp-premium/memberpress-business/blob/1.2.7/app/lib/MeprBaseGateway.php#L609-L619
273 273
 		 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprTransaction.php#L51
274 274
 		 */
275
-		$reflection = new ReflectionClass( 'MeprBaseRealGateway' );
275
+		$reflection = new ReflectionClass('MeprBaseRealGateway');
276 276
 
277
-		if ( $reflection->hasMethod( 'send_product_welcome_notices' ) && 3 === $reflection->getMethod( 'send_product_welcome_notices' )->getNumberOfParameters() ) {
277
+		if ($reflection->hasMethod('send_product_welcome_notices') && 3 === $reflection->getMethod('send_product_welcome_notices')->getNumberOfParameters()) {
278 278
 			$uemail = MeprEmailFactory::fetch(
279 279
 				'MeprUserProductWelcomeEmail',
280 280
 				'MeprBaseProductEmail',
@@ -288,24 +288,24 @@  discard block
 block discarded – undo
288 288
 			/** @scrutinizer ignore-call */
289 289
 			$this->send_product_welcome_notices(
290 290
 				$uemail,
291
-				MeprTransactionsHelper::get_email_params( $transaction ),
291
+				MeprTransactionsHelper::get_email_params($transaction),
292 292
 				$transaction->user()
293 293
 			);
294 294
 		} else {
295
-			$this->send_transaction_notices( $transaction, 'send_product_welcome_notices' );
295
+			$this->send_transaction_notices($transaction, 'send_product_welcome_notices');
296 296
 		}
297 297
 
298 298
 		// Send upgrade/downgrade notices.
299
-		if ( $upgrade ) {
300
-			$this->upgraded_sub( $transaction );
301
-			$this->send_transaction_notices( $transaction, 'send_upgraded_txn_notices' );
302
-		} elseif ( $downgrade ) {
303
-			$this->downgraded_sub( $transaction );
304
-			$this->send_transaction_notices( $transaction, 'send_downgraded_txn_notices' );
299
+		if ($upgrade) {
300
+			$this->upgraded_sub($transaction);
301
+			$this->send_transaction_notices($transaction, 'send_upgraded_txn_notices');
302
+		} elseif ($downgrade) {
303
+			$this->downgraded_sub($transaction);
304
+			$this->send_transaction_notices($transaction, 'send_downgraded_txn_notices');
305 305
 		}
306 306
 
307
-		$this->send_transaction_notices( $transaction, 'send_signup_notices' );
308
-		$this->send_transaction_notices( $transaction, 'send_transaction_receipt_notices' );
307
+		$this->send_transaction_notices($transaction, 'send_signup_notices');
308
+		$this->send_transaction_notices($transaction, 'send_transaction_receipt_notices');
309 309
 
310 310
 		return $transaction;
311 311
 	}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L131-133
319 319
 	 */
320
-	public function process_refund( MeprTransaction $txn ) {
320
+	public function process_refund(MeprTransaction $txn) {
321 321
 
322 322
 	}
323 323
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @param MeprTransaction $transaction MemberPress transaction object.
339 339
 	 */
340
-	public function process_trial_payment( $transaction ) {
340
+	public function process_trial_payment($transaction) {
341 341
 
342 342
 	}
343 343
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 *
349 349
 	 * @param MeprTransaction $transaction MemberPress transaction object.
350 350
 	 */
351
-	public function record_trial_payment( $transaction ) {
351
+	public function record_trial_payment($transaction) {
352 352
 
353 353
 	}
354 354
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @param MeprTransaction $txn MemberPress transaction object.
361 361
 	 */
362
-	public function process_create_subscription( $txn ) {
362
+	public function process_create_subscription($txn) {
363 363
 
364 364
 	}
365 365
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @param int $sub_id Subscription ID.
382 382
 	 */
383
-	public function process_update_subscription( $sub_id ) {
383
+	public function process_update_subscription($sub_id) {
384 384
 
385 385
 	}
386 386
 
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L184-186
402 402
 	 */
403
-	public function process_suspend_subscription( $sub_id ) {
404
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
403
+	public function process_suspend_subscription($sub_id) {
404
+		if ( ! MeprSubscription::exists($sub_id)) {
405 405
 			return;
406 406
 		}
407 407
 
408
-		$sub = new MeprSubscription( $sub_id );
408
+		$sub = new MeprSubscription($sub_id);
409 409
 
410
-		if ( MeprSubscription::$suspended_str === $sub->status ) {
410
+		if (MeprSubscription::$suspended_str === $sub->status) {
411 411
 			// Subscription is already suspended.
412 412
 			return;
413 413
 		}
414 414
 
415
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id );
415
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id);
416 416
 
417
-		if ( ! $subscription ) {
417
+		if ( ! $subscription) {
418 418
 			return;
419 419
 		}
420 420
 
@@ -423,19 +423,19 @@  discard block
 block discarded – undo
423 423
 		$sub->store();
424 424
 
425 425
 		// Send suspended subscription notices.
426
-		MeprUtils::send_suspended_sub_notices( $sub );
426
+		MeprUtils::send_suspended_sub_notices($sub);
427 427
 
428 428
 		$note = sprintf(
429 429
 			/* translators: %s: MemberPress */
430
-			__( '%s subscription on hold.', 'pronamic_ideal' ),
431
-			__( 'MemberPress', 'pronamic_ideal' )
430
+			__('%s subscription on hold.', 'pronamic_ideal'),
431
+			__('MemberPress', 'pronamic_ideal')
432 432
 		);
433 433
 
434
-		$subscription->add_note( $note );
434
+		$subscription->add_note($note);
435 435
 
436 436
 		// The status of canceled or completed subscriptions will not be changed automatically.
437
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
438
-			$subscription->set_status( Statuses::OPEN );
437
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
438
+			$subscription->set_status(Statuses::OPEN);
439 439
 
440 440
 			$subscription->save();
441 441
 		}
@@ -457,21 +457,21 @@  discard block
 block discarded – undo
457 457
 	 *
458 458
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L193-195
459 459
 	 */
460
-	public function process_resume_subscription( $sub_id ) {
461
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
460
+	public function process_resume_subscription($sub_id) {
461
+		if ( ! MeprSubscription::exists($sub_id)) {
462 462
 			return;
463 463
 		}
464 464
 
465
-		$sub = new MeprSubscription( $sub_id );
465
+		$sub = new MeprSubscription($sub_id);
466 466
 
467
-		if ( MeprSubscription::$active_str === $sub->status ) {
467
+		if (MeprSubscription::$active_str === $sub->status) {
468 468
 			// Subscription is already active.
469 469
 			return;
470 470
 		}
471 471
 
472
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id );
472
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id);
473 473
 
474
-		if ( ! $subscription ) {
474
+		if ( ! $subscription) {
475 475
 			return;
476 476
 		}
477 477
 
@@ -482,35 +482,35 @@  discard block
 block discarded – undo
482 482
 		// Check if prior txn is expired yet or not, if so create a temporary txn so the user can access the content immediately.
483 483
 		$prior_txn = $sub->latest_txn();
484 484
 
485
-		if ( false === $prior_txn || ! ( $prior_txn instanceof MeprTransaction ) || strtotime( $prior_txn->expires_at ) < time() ) {
485
+		if (false === $prior_txn || ! ($prior_txn instanceof MeprTransaction) || strtotime($prior_txn->expires_at) < time()) {
486 486
 			$txn                  = new MeprTransaction();
487 487
 			$txn->subscription_id = $sub->id;
488 488
 			$txn->trans_num       = $sub->subscr_id . '-' . uniqid();
489 489
 			$txn->status          = MeprTransaction::$confirmed_str;
490 490
 			$txn->txn_type        = MeprTransaction::$subscription_confirmation_str;
491 491
 			$txn->response        = (string) $sub;
492
-			$txn->expires_at      = MeprUtils::ts_to_mysql_date( time() + MeprUtils::days( 1 ), 'Y-m-d 23:59:59' );
492
+			$txn->expires_at      = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days(1), 'Y-m-d 23:59:59');
493 493
 
494
-			$txn->set_subtotal( 0.00 ); // Just a confirmation txn.
494
+			$txn->set_subtotal(0.00); // Just a confirmation txn.
495 495
 
496 496
 			$txn->store();
497 497
 		}
498 498
 
499 499
 		// Send resumed subscription notices.
500
-		MeprUtils::send_resumed_sub_notices( $sub );
500
+		MeprUtils::send_resumed_sub_notices($sub);
501 501
 
502 502
 		// Add note.
503 503
 		$note = sprintf(
504 504
 			/* translators: %s: MemberPress */
505
-			__( '%s subscription reactivated.', 'pronamic_ideal' ),
506
-			__( 'MemberPress', 'pronamic_ideal' )
505
+			__('%s subscription reactivated.', 'pronamic_ideal'),
506
+			__('MemberPress', 'pronamic_ideal')
507 507
 		);
508 508
 
509
-		$subscription->add_note( $note );
509
+		$subscription->add_note($note);
510 510
 
511 511
 		// The status of canceled or completed subscriptions will not be changed automatically.
512
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
513
-			$subscription->set_status( Statuses::ACTIVE );
512
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
513
+			$subscription->set_status(Statuses::ACTIVE);
514 514
 
515 515
 			$subscription->save();
516 516
 		}
@@ -532,21 +532,21 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L202-206
534 534
 	 */
535
-	public function process_cancel_subscription( $sub_id ) {
536
-		if ( ! MeprSubscription::exists( $sub_id ) ) {
535
+	public function process_cancel_subscription($sub_id) {
536
+		if ( ! MeprSubscription::exists($sub_id)) {
537 537
 			return;
538 538
 		}
539 539
 
540
-		$sub = new MeprSubscription( $sub_id );
540
+		$sub = new MeprSubscription($sub_id);
541 541
 
542
-		if ( MeprSubscription::$cancelled_str === $sub->status ) {
542
+		if (MeprSubscription::$cancelled_str === $sub->status) {
543 543
 			// Subscription is already cancelled.
544 544
 			return;
545 545
 		}
546 546
 
547
-		$subscription = get_pronamic_subscription_by_meta( '_pronamic_subscription_source_id', $sub->first_txn_id );
547
+		$subscription = get_pronamic_subscription_by_meta('_pronamic_subscription_source_id', $sub->first_txn_id);
548 548
 
549
-		if ( ! $subscription ) {
549
+		if ( ! $subscription) {
550 550
 			return;
551 551
 		}
552 552
 
@@ -555,27 +555,27 @@  discard block
 block discarded – undo
555 555
 		$sub->store();
556 556
 
557 557
 		// Expire the grace period (confirmation) if no completed payments have come through.
558
-		if ( (int) $sub->txn_count <= 0 ) {
558
+		if ((int) $sub->txn_count <= 0) {
559 559
 			$sub->expire_txns();
560 560
 		}
561 561
 
562 562
 		$sub->limit_reached_actions();
563 563
 
564 564
 		// Send cancelled subscription notices.
565
-		MeprUtils::send_cancelled_sub_notices( $sub );
565
+		MeprUtils::send_cancelled_sub_notices($sub);
566 566
 
567 567
 		// Add note.
568 568
 		$note = sprintf(
569 569
 			/* translators: %s: MemberPress */
570
-			__( '%s subscription cancelled.', 'pronamic_ideal' ),
571
-			__( 'MemberPress', 'pronamic_ideal' )
570
+			__('%s subscription cancelled.', 'pronamic_ideal'),
571
+			__('MemberPress', 'pronamic_ideal')
572 572
 		);
573 573
 
574
-		$subscription->add_note( $note );
574
+		$subscription->add_note($note);
575 575
 
576 576
 		// The status of canceled or completed subscriptions will not be changed automatically.
577
-		if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) {
578
-			$subscription->set_status( Statuses::CANCELLED );
577
+		if ( ! in_array($subscription->get_status(), array(Statuses::CANCELLED, Statuses::COMPLETED), true)) {
578
+			$subscription->set_status(Statuses::CANCELLED);
579 579
 
580 580
 			$subscription->save();
581 581
 		}
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 *
603 603
 	 * @param MeprTransaction $txn MemberPress transaction object.
604 604
 	 */
605
-	public function process_signup_form( $txn ) {
605
+	public function process_signup_form($txn) {
606 606
 
607 607
 	}
608 608
 
@@ -613,28 +613,28 @@  discard block
 block discarded – undo
613 613
 	 *
614 614
 	 * @param MeprTransaction $txn MemberPress transaction object.
615 615
 	 */
616
-	public function payment_redirect( $txn ) {
617
-		$txn = new MeprTransaction( $txn->id );
616
+	public function payment_redirect($txn) {
617
+		$txn = new MeprTransaction($txn->id);
618 618
 
619 619
 		// Gateway.
620 620
 		$config_id = $this->settings->config_id;
621 621
 
622
-		$gateway = Plugin::get_gateway( $config_id );
622
+		$gateway = Plugin::get_gateway($config_id);
623 623
 
624
-		if ( ! $gateway ) {
624
+		if ( ! $gateway) {
625 625
 			return;
626 626
 		}
627 627
 
628 628
 		// Data.
629
-		$data = new PaymentData( $txn );
629
+		$data = new PaymentData($txn);
630 630
 
631
-		$payment = Plugin::start( $config_id, $gateway, $data, $this->payment_method );
631
+		$payment = Plugin::start($config_id, $gateway, $data, $this->payment_method);
632 632
 
633 633
 		$error = $gateway->get_error();
634 634
 
635
-		if ( ! is_wp_error( $error ) ) {
635
+		if ( ! is_wp_error($error)) {
636 636
 			// Redirect.
637
-			$gateway->redirect( $payment );
637
+			$gateway->redirect($payment);
638 638
 		}
639 639
 	}
640 640
 
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 	 *
648 648
 	 * @param MeprTransaction $txn MemberPress transaction object.
649 649
 	 */
650
-	public function display_payment_page( $txn ) {
650
+	public function display_payment_page($txn) {
651 651
 		// Gateway.
652 652
 		$config_id = $this->settings->config_id;
653 653
 
654
-		$gateway = Plugin::get_gateway( $config_id );
654
+		$gateway = Plugin::get_gateway($config_id);
655 655
 
656
-		if ( $gateway && '' === $gateway->get_input_html() ) {
657
-			$this->payment_redirect( $txn );
656
+		if ($gateway && '' === $gateway->get_input_html()) {
657
+			$this->payment_redirect($txn);
658 658
 		}
659 659
 	}
660 660
 
@@ -668,18 +668,18 @@  discard block
 block discarded – undo
668 668
 	 * @param  MeprTransaction $txn MemberPress transaction object.
669 669
 	 * @return bool
670 670
 	 */
671
-	public function process_payment_form( $txn ) {
672
-		if ( ! filter_has_var( INPUT_POST, 'pronamic_pay_memberpress_pay' ) ) {
671
+	public function process_payment_form($txn) {
672
+		if ( ! filter_has_var(INPUT_POST, 'pronamic_pay_memberpress_pay')) {
673 673
 			return false;
674 674
 		}
675 675
 
676 676
 		// Gateway.
677 677
 		$config_id = $this->settings->config_id;
678 678
 
679
-		$gateway = Plugin::get_gateway( $config_id );
679
+		$gateway = Plugin::get_gateway($config_id);
680 680
 
681
-		if ( $gateway ) {
682
-			$this->payment_redirect( $txn );
681
+		if ($gateway) {
682
+			$this->payment_redirect($txn);
683 683
 		}
684 684
 	}
685 685
 
@@ -707,20 +707,20 @@  discard block
 block discarded – undo
707 707
 	 * @param int      $product_id Product ID.
708 708
 	 * @param int      $txn_id     Transaction ID.
709 709
 	 */
710
-	public function display_payment_form( $amount, $user, $product_id, $txn_id ) {
711
-		$product = new MeprProduct( $product_id );
710
+	public function display_payment_form($amount, $user, $product_id, $txn_id) {
711
+		$product = new MeprProduct($product_id);
712 712
 
713 713
 		$coupon = false;
714 714
 
715
-		$txn = new MeprTransaction( $txn_id );
715
+		$txn = new MeprTransaction($txn_id);
716 716
 
717 717
 		// Artifically set the price of the $prd in case a coupon was used.
718
-		if ( $product->price !== $amount ) {
718
+		if ($product->price !== $amount) {
719 719
 			$coupon         = true;
720 720
 			$product->price = $amount;
721 721
 		}
722 722
 
723
-		$invoice = MeprTransactionsHelper::get_invoice( $txn );
723
+		$invoice = MeprTransactionsHelper::get_invoice($txn);
724 724
 
725 725
 		echo $invoice; // WPCS: XSS ok.
726 726
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 		<div class="mp_wrapper mp_payment_form_wrapper">
729 729
 			<form action="" method="post" id="payment-form" class="mepr-form" novalidate>
730 730
 				<input type="hidden" name="mepr_process_payment_form" value="Y"/>
731
-				<input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr( $txn_id ); ?>"/>
731
+				<input type="hidden" name="mepr_transaction_id" value="<?php echo esc_attr($txn_id); ?>"/>
732 732
 				<input type="hidden" name="pronamic_pay_memberpress_pay" value="1"/>
733 733
 
734 734
 				<div class="mepr_spacer">&nbsp;</div>
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 				// Gateway.
739 739
 				$config_id = $this->settings->config_id;
740 740
 
741
-				$gateway = Plugin::get_gateway( $config_id );
741
+				$gateway = Plugin::get_gateway($config_id);
742 742
 
743
-				if ( $gateway ) {
743
+				if ($gateway) {
744 744
 					echo $gateway->get_input_html(); // WPCS: XSS ok.
745 745
 				}
746 746
 
@@ -748,13 +748,13 @@  discard block
 block discarded – undo
748 748
 
749 749
 				<div class="mepr_spacer">&nbsp;</div>
750 750
 
751
-				<input type="submit" class="mepr-submit" value="<?php esc_attr_e( 'Pay', 'pronamic_ideal' ); ?>"/>
752
-				<img src="<?php echo esc_attr( admin_url( 'images/loading.gif' ) ); ?>" style="display: none;" class="mepr-loading-gif"/>
753
-				<?php MeprView::render( '/shared/has_errors', get_defined_vars() ); ?>
751
+				<input type="submit" class="mepr-submit" value="<?php esc_attr_e('Pay', 'pronamic_ideal'); ?>"/>
752
+				<img src="<?php echo esc_attr(admin_url('images/loading.gif')); ?>" style="display: none;" class="mepr-loading-gif"/>
753
+				<?php MeprView::render('/shared/has_errors', get_defined_vars()); ?>
754 754
 
755 755
 				<noscript>
756 756
 					<p class="mepr_nojs">
757
-						<?php esc_html_e( 'JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal' ); ?>
757
+						<?php esc_html_e('JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal'); ?>
758 758
 					</p>
759 759
 				</noscript>
760 760
 			</form>
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	 * @param array $errors Array with errors.
773 773
 	 * @return array
774 774
 	 */
775
-	public function validate_payment_form( $errors ) {
775
+	public function validate_payment_form($errors) {
776 776
 		return $errors;
777 777
 	}
778 778
 
@@ -799,18 +799,18 @@  discard block
 block discarded – undo
799 799
 
800 800
 				?>
801 801
 				<td>
802
-					<?php esc_html_e( 'Configuration', 'pronamic_ideal' ); ?>
802
+					<?php esc_html_e('Configuration', 'pronamic_ideal'); ?>
803 803
 				</td>
804 804
 				<td>
805
-					<select name="<?php echo esc_attr( $name ); ?>">
805
+					<select name="<?php echo esc_attr($name); ?>">
806 806
 						<?php
807 807
 
808
-						foreach ( Plugin::get_config_select_options( $this->payment_method ) as $value => $label ) {
808
+						foreach (Plugin::get_config_select_options($this->payment_method) as $value => $label) {
809 809
 							printf(
810 810
 								'<option value="%s" %s>%s</option>',
811
-								esc_attr( $value ),
812
-								selected( $value, $this->settings->config_id, false ),
813
-								esc_html( $label )
811
+								esc_attr($value),
812
+								selected($value, $this->settings->config_id, false),
813
+								esc_html($label)
814 814
 							);
815 815
 						}
816 816
 
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 	 * @param array $errors Array with errors.
833 833
 	 * @return array
834 834
 	 */
835
-	public function validate_options_form( $errors ) {
835
+	public function validate_options_form($errors) {
836 836
 		return $errors;
837 837
 	}
838 838
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 	 * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/gateways/MeprStripeGateway.php#L1108-L1168
858 858
 	 * @see https://github.com/wp-premium/memberpress-basic/blob/1.3.18/app/controllers/MeprAccountCtrl.php#L388
859 859
 	 */
860
-	public function display_update_account_form( $sub_id, $errors = array(), $message = '' ) {
860
+	public function display_update_account_form($sub_id, $errors = array(), $message = '') {
861 861
 
862 862
 	}
863 863
 
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 	 * @param  array $errors Array with errors.
871 871
 	 * @return array
872 872
 	 */
873
-	public function validate_update_account_form( $errors = array() ) {
873
+	public function validate_update_account_form($errors = array()) {
874 874
 		return $errors;
875 875
 	}
876 876
 
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 	 *
883 883
 	 * @param int $sub_id Subscription ID.
884 884
 	 */
885
-	public function process_update_account_form( $sub_id ) {
885
+	public function process_update_account_form($sub_id) {
886 886
 
887 887
 	}
888 888
 
Please login to merge, or discard this patch.
src/PaymentData.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @param MeprTransaction $txn MemberPress transaction object.
56 56
 	 */
57
-	public function __construct( MeprTransaction $txn ) {
57
+	public function __construct(MeprTransaction $txn) {
58 58
 		parent::__construct();
59 59
 
60 60
 		$this->txn       = $txn;
61 61
 		$this->member    = $this->txn->user();
62
-		$this->recurring = ( $txn->subscription() && $txn->subscription()->txn_count > 1 );
62
+		$this->recurring = ($txn->subscription() && $txn->subscription()->txn_count > 1);
63 63
 	}
64 64
 
65 65
 	/**
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		$items = new Items();
118 118
 
119 119
 		$item = new Item();
120
-		$item->setNumber( $this->get_order_id() );
121
-		$item->setDescription( $this->get_description() );
122
-		$item->setPrice( $this->txn->total );
123
-		$item->setQuantity( 1 );
120
+		$item->setNumber($this->get_order_id());
121
+		$item->setDescription($this->get_description());
122
+		$item->setPrice($this->txn->total);
123
+		$item->setQuantity(1);
124 124
 
125
-		$items->addItem( $item );
125
+		$items->addItem($item);
126 126
 
127 127
 		return $items;
128 128
 	}
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 * @return string|null
199 199
 	 */
200 200
 	public function get_address() {
201
-		$value = $this->member->address( 'one' );
201
+		$value = $this->member->address('one');
202 202
 
203
-		if ( false === $value ) {
203
+		if (false === $value) {
204 204
 			return null;
205 205
 		}
206 206
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 	 * @return string
216 216
 	 */
217 217
 	public function get_city() {
218
-		$value = $this->member->address( 'city' );
218
+		$value = $this->member->address('city');
219 219
 
220
-		if ( false === $value ) {
220
+		if (false === $value) {
221 221
 			return null;
222 222
 		}
223 223
 
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 	 * @return string
233 233
 	 */
234 234
 	public function get_zip() {
235
-		$value = $this->member->address( 'zip' );
235
+		$value = $this->member->address('zip');
236 236
 
237
-		if ( false === $value ) {
237
+		if (false === $value) {
238 238
 			return null;
239 239
 		}
240 240
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		$mepr_options = MeprOptions::fetch();
253 253
 
254 254
 		// @link https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/models/MeprOptions.php#L768-782
255
-		return $mepr_options->thankyou_page_url( 'trans_num=' . $this->txn->id );
255
+		return $mepr_options->thankyou_page_url('trans_num=' . $this->txn->id);
256 256
 	}
257 257
 
258 258
 	/**
@@ -292,36 +292,36 @@  discard block
 block discarded – undo
292 292
 	public function get_subscription() {
293 293
 		$product = $this->txn->product();
294 294
 
295
-		if ( $product->is_one_time_payment() ) {
295
+		if ($product->is_one_time_payment()) {
296 296
 			return false;
297 297
 		}
298 298
 
299 299
 		$mp_subscription = $this->txn->subscription();
300 300
 
301
-		if ( ! $mp_subscription ) {
301
+		if ( ! $mp_subscription) {
302 302
 			return false;
303 303
 		}
304 304
 
305 305
 		$frequency = '';
306 306
 
307
-		if ( $mp_subscription->limit_cycles ) {
307
+		if ($mp_subscription->limit_cycles) {
308 308
 			$frequency = $mp_subscription->limit_cycles;
309 309
 		}
310 310
 
311 311
 		$subscription                  = new Subscription();
312 312
 		$subscription->frequency       = $frequency;
313 313
 		$subscription->interval        = $product->period;
314
-		$subscription->interval_period = Core_Util::to_period( $product->period_type );
314
+		$subscription->interval_period = Core_Util::to_period($product->period_type);
315 315
 		$subscription->description     = sprintf(
316 316
 			'Order #%s - %s',
317 317
 			$this->get_source_id(),
318 318
 			$this->get_description()
319 319
 		);
320 320
 
321
-		$subscription->set_amount( new Money(
321
+		$subscription->set_amount(new Money(
322 322
 			$this->txn->total,
323 323
 			$this->get_currency_alphabetic_code()
324
-		) );
324
+		));
325 325
 
326 326
 		return $subscription;
327 327
 	}
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	public function get_subscription_source_id() {
336 336
 		$subscription = $this->get_subscription();
337 337
 
338
-		if ( ! $subscription ) {
338
+		if ( ! $subscription) {
339 339
 			return false;
340 340
 		}
341 341
 
Please login to merge, or discard this patch.