Failed Conditions
Push — develop ( 531a2b...d80767 )
by Remco
04:01
created

Integration::get_config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Integration.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet;
12
13
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
14
15
/**
16
 * Title: ING Kassa Compleet integration
17
 * Description:
18
 * Copyright: 2005-2019 Pronamic
19
 * Company: Pronamic
20
 *
21
 * @author  Reüel van der Steege
22
 * @version 2.0.0
23
 * @since   1.0.0
24
 */
25
class Integration extends AbstractIntegration {
26
	/**
27
	 * Integration constructor.
28
	 */
29
	public function __construct() {
30
		$this->id            = 'ing-kassa-compleet';
31
		$this->name          = 'ING - Kassa Compleet';
32
		$this->provider      = 'ing';
33
		$this->product_url   = 'https://www.ing.nl/zakelijk/betalen/geld-ontvangen/kassa-compleet/';
34
		$this->dashboard_url = 'https://portal.kassacompleet.nl/';
35
		$this->supports      = array(
0 ignored issues
show
Bug Best Practice introduced by Remco Tolsma
The property supports does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
			'payment_status_request',
37
			'webhook',
38
		);
39
40
		// Actions.
41
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
42
43
		if ( ! has_action( 'wp_loaded', $function ) ) {
44
			add_action( 'wp_loaded', $function );
45
		}
46
	}
47
48
	/**
49
	 * Get settings fields.
50
	 *
51
	 * @return array
52
	 */
53
	public function get_settings_fields() {
54
		$fields = array();
55
56
		// API Key.
57
		$fields[] = array(
58
			'section'  => 'general',
59
			'filter'   => FILTER_SANITIZE_STRING,
60
			'meta_key' => '_pronamic_gateway_ing_kassa_compleet_api_key',
61
			'title'    => _x( 'API Key', 'ing_kassa_compleet', 'pronamic_ideal' ),
62
			'type'     => 'text',
63
			'classes'  => array( 'regular-text', 'code' ),
64
			'tooltip'  => sprintf(
65
				'%s %s.',
66
				__( 'API key', 'pronamic_ideal' ),
67
				sprintf(
68
					/* translators: %s: ING Kassa Compleet */
69
					__( 'as mentioned in the %s dashboard', 'pronamic_ideal' ),
70
					__( 'ING Kassa Compleet', 'pronamic_ideal' )
71
				)
72
			),
73
		);
74
75
		// Webhook URL.
76
		$fields[] = array(
77
			'section'  => 'feedback',
78
			'title'    => __( 'Webhook URL', 'pronamic_ideal' ),
79
			'type'     => 'text',
80
			'classes'  => array( 'large-text', 'code' ),
81
			'value'    => add_query_arg( 'ing_kassa_compleet_webhook', '', home_url( '/' ) ),
82
			'readonly' => true,
83
			'tooltip'  => sprintf(
84
				/* translators: %s: ING Kassa Compleet */
85
				__( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
86
				__( 'ING Kassa Compleet', 'pronamic_ideal' )
87
			),
88
		);
89
90
		return $fields;
91
	}
92
	/**
93
	 * Get config with specified post ID.
94
	 *
95
	 * @param int $post_id Post ID.
96
	 *
97
	 * @return Config|null
98
	 */
99
	public function get_config( $post_id ) {
100
		$config = new Config();
101
102
		$config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' );
0 ignored issues
show
Bug introduced by Remco Tolsma
The method get_meta() does not exist on Pronamic\WordPress\Pay\G...ssaCompleet\Integration. Did you maybe mean get_name()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
		/** @scrutinizer ignore-call */ 
103
  $config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
103
		$config->mode    = $this->get_meta( $post_id, 'mode' );
104
105
		return $config;
106
	}
107
}
108