Passed
Push — master ( 3a59d9...4cac9e )
by Chris
01:49
created

EDU_KlarnaCheckout::init_form_fields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 21
nc 1
nop 0
1
<?php
2
defined( 'ABSPATH' ) || die( 'This plugin must be run within the scope of WordPress.' );
3
4
if ( ! class_exists( 'EDU_KlarnaCheckout' ) ) {
5
	class EDU_KlarnaCheckout extends EDU_Integration {
0 ignored issues
show
Bug introduced by
The type EDU_Integration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
		public function __construct() {
7
			$this->id          = 'eduadmin-klarnacheckout';
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
8
			$this->displayName = __( 'Klarna Checkout', 'eduadmin-wp-klarna-checkout' );
0 ignored issues
show
Bug Best Practice introduced by
The property displayName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

8
			$this->displayName = /** @scrutinizer ignore-call */ __( 'Klarna Checkout', 'eduadmin-wp-klarna-checkout' );
Loading history...
9
			$this->description = '';
0 ignored issues
show
Bug Best Practice introduced by
The property description does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
10
11
			$this->init_form_fields();
12
			$this->init_settings();
13
14
			add_action( 'eduadmin-checkpaymentplugins', array( $this, 'intercept_booking' ) );
0 ignored issues
show
Bug introduced by
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

14
			/** @scrutinizer ignore-call */ 
15
   add_action( 'eduadmin-checkpaymentplugins', array( $this, 'intercept_booking' ) );
Loading history...
15
			add_action( 'eduadmin-processbooking', array( $this, 'process_booking' ) );
16
			add_action( 'wp_loaded', array( $this, 'process_klarnaresponse' ) );
17
		}
18
19
		public function intercept_booking() {
20
			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
21
				return;
22
			}
23
		}
24
25
		public function process_booking() {
26
			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
27
				return;
28
			}
29
		}
30
31
		public function process_klarnaresponse() {
32
			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
33
				return;
34
			}
35
		}
36
37
		public function init_form_fields() {
38
			$this->setting_fields = array(
0 ignored issues
show
Bug Best Practice introduced by
The property setting_fields does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
				'enabled'  => array(
40
					'title'       => __( 'Enabled', 'edauadmin-wp-klarna-checkout' ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

40
					'title'       => /** @scrutinizer ignore-call */ __( 'Enabled', 'edauadmin-wp-klarna-checkout' ),
Loading history...
41
					'type'        => 'checkbox',
42
					'description' => __( 'Enables/Disabled the integration with Klarna Checkout', 'eduadmin-wp-klarna-checkout' ),
43
					'default'     => 'no',
44
				),
45
				'username' => array(
46
					'title'       => __( 'Username (UID)', 'eduadmin-wp-klarna-checkout' ),
47
					'type'        => 'text',
48
					'description' => __( 'The API credential username from Klarna', 'eduadmin-wp-klarna-checkout' ),
49
					'default'     => '',
50
				),
51
				'password' => array(
52
					'title'       => __( 'Password', 'eduadmin-wp-klarna-checkout' ),
53
					'type'        => 'password',
54
					'description' => __( 'Password for the API credentials from Klarna', 'eduadmin-wp-klarna-checkout' ),
55
					'default'     => '',
56
				),
57
				'termsurl' => array(
58
					'title'       => __( 'Terms and Conditions URL', 'eduadmin-wp-klarna-checkout' ),
59
					'type'        => 'text',
60
					'description' => __( 'This URL is required for Klarna Checkout', 'eduadmin-wp-klarna-checkout' ),
61
					'default'     => '',
62
				),
63
			);
64
		}
65
	}
66
}
67