Failed Conditions
Push — develop ( dbc9be...4ef903 )
by Reüel
03:15
created

Integration::__construct()   A

Complexity

Conditions 5
Paths 10

Size

Total Lines 28
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5.6359

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 28
ccs 12
cts 17
cp 0.7059
rs 9.4222
c 0
b 0
f 0
cc 5
nc 10
nop 0
crap 5.6359
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Mollie;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: Mollie integration
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.0
15
 * @since   1.0.0
16
 */
17
class Integration extends AbstractIntegration {
18
	/**
19
	 * Construct and intialize Mollie integration.
20
	 */
21 6
	public function __construct() {
22 6
		$this->id            = 'mollie';
23 6
		$this->name          = 'Mollie';
24 6
		$this->url           = 'http://www.mollie.com/en/';
25 6
		$this->product_url   = __( 'https://www.mollie.com/en/pricing', 'pronamic_ideal' );
26 6
		$this->dashboard_url = 'http://www.mollie.nl/beheer/';
27 6
		$this->provider      = 'mollie';
28
29
		// Actions.
30 6
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
31
32 6
		if ( ! has_action( 'wp_loaded', $function ) ) {
33 6
			add_action( 'wp_loaded', $function );
34
		}
35
36 6
		if ( is_admin() ) {
37
			$function = array( __CLASS__, 'user_profile' );
38
39
			if ( ! has_action( 'show_user_profile', $function ) ) {
40
				add_action( 'show_user_profile', $function );
41
			}
42
43
			if ( ! has_action( 'edit_user_profile', $function ) ) {
44
				add_action( 'edit_user_profile', $function );
45
			}
46
		}
47
48 6
		add_filter( 'pronamic_payment_provider_url_mollie', array( $this, 'payment_provider_url' ), 10, 2 );
49 6
	}
50
51
	/**
52
	 * Config factory class name.
53
	 *
54
	 * @return string
55
	 */
56 1
	public function get_config_factory_class() {
57 1
		return __NAMESPACE__ . '\ConfigFactory';
58
	}
59
60
	/**
61
	 * Settings class name.
62
	 *
63
	 * @return string
64
	 */
65 1
	public function get_settings_class() {
66 1
		return __NAMESPACE__ . '\Settings';
67
	}
68
69
	/**
70
	 * Get required settings for this integration.
71
	 *
72
	 * @link https://github.com/wp-premium/gravityforms/blob/1.9.16/includes/fields/class-gf-field-multiselect.php#L21-L42
73
	 * @since 1.1.3
74
	 * @return array
75
	 */
76 1
	public function get_settings() {
77 1
		$settings = parent::get_settings();
78
79 1
		$settings[] = 'mollie';
80
81 1
		return $settings;
82
	}
83
84
	/**
85
	 * User profile.
86
	 *
87
	 * @since 1.1.6
88
	 * @link https://github.com/WordPress/WordPress/blob/4.5.2/wp-admin/user-edit.php#L578-L600
89
	 */
90
	public static function user_profile( $user ) {
91
		include dirname( __FILE__ ) . '/../views/html-admin-user-profile.php';
92
	}
93
94
	/**
95
	 * Payment provider URL.
96
	 *
97
	 * @param string  $url
98
	 * @param Payment $payment
99
	 * @return string
100
	 */
101 1
	public function payment_provider_url( $url, $payment ) {
102 1
		return sprintf(
103 1
			'https://www.mollie.com/dashboard/payments/%s',
104 1
			$payment->get_transaction_id()
105
		);
106
	}
107
}
108