Add_Ons   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 25.81 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 16
loc 62
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A html() 0 9 1
A add_sections() 0 3 1
A add_fields() 0 3 1
A __construct() 16 16 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Add-ons Page
4
 *
5
 * @package SimpleCalendar/Admin
6
 */
7
namespace SimpleCalendar\Admin\Pages;
8
9
use SimpleCalendar\Abstracts\Admin_Page;
10
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit;
13
}
14
15
/**
16
 * Add-ons page.
17
 *
18
 * @since 3.0.0
19
 */
20
class Add_Ons extends Admin_Page {
21
22
	/**
23
	 * Constructor.
24
	 *
25
	 * @since 3.0.0
26
	 */
27 View Code Duplication
	public function __construct() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
29
		$this->id           = $tab = 'add-ons';
30
		$this->option_group = $page = 'add-ons';
31
		$this->label        = __( 'Add-ons', 'google-calendar-events' );
32
		$this->description  = '';
33
		$this->sections     = $this->add_sections();
34
		$this->fields       = $this->add_fields();
35
36
		// Disable the submit button for this page.
37
		add_filter( 'simcal_admin_page_' . $page . '_' . $tab . '_submit', function() { return false; } );
38
39
		// Add html.
40
		add_action( 'simcal_admin_page_' . $page . '_' . $tab . '_end', array( $this, 'html' ) );
41
42
	}
43
44
	/**
45
	 * Output page markup.
46
	 *
47
	 * @since 3.0.0
48
	 */
49
	public function html() {
50
51
		// @todo pull data from simplecalendar.io to showcase add-ons
52
		$js_redirect = '<script type="text/javascript">';
53
		$js_redirect .= 'window.location = "' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-submenu-link', true ) . '"';
54
		$js_redirect .= '</script>';
55
56
		echo $js_redirect;
57
	}
58
59
	/**
60
	 * Add sections.
61
	 *
62
	 * @since  3.0.0
63
	 *
64
	 * @return array
65
	 */
66
	public function add_sections() {
67
		return array();
68
	}
69
70
	/**
71
	 * Add fields.
72
	 *
73
	 * @since  3.0.0
74
	 *
75
	 * @return array
76
	 */
77
	public function add_fields() {
78
		return array();
79
	}
80
81
}
82