Give_Settings_System_Info::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Give Settings Page/Tab
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_Settings_System_Info
7
 * @copyright   Copyright (c) 2016, GiveWP
8
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
 * @since       1.8
10
 */
11
12
if ( ! defined( 'ABSPATH' ) ) {
13
	exit; // Exit if accessed directly
14
}
15
16
if ( ! class_exists( 'Give_Settings_System_Info' ) ) :
17
18
	/**
19
	 * Give_Settings_System_Info.
20
	 *
21
	 * @sine 1.8
22
	 */
23
	class Give_Settings_System_Info extends Give_Settings_Page {
24
		/**
25
		 * Flag to check if enable saving option for setting page or not
26
		 *
27
		 * @since 1.8.17
28
		 * @var bool
29
		 */
30
		protected $enable_save = false;
31
32
		/**
33
		 * Constructor.
34
		 */
35 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...
36
			$this->id    = 'system-info';
37
			$this->label = esc_html__( 'System Info', 'give' );
38
39
			parent::__construct();
40
41
			// Do not use main form for this tab.
42
			if ( give_get_current_setting_tab() === $this->id ) {
43
				add_action( "give-tools_open_form", '__return_empty_string' );
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal give-tools_open_form does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
44
				add_action( "give-tools_close_form", '__return_empty_string' );
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal give-tools_close_form does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
45
			}
46
		}
47
48
		/**
49
		 * Output the settings.
50
		 *
51
		 * @since  1.8
52
		 * @return void
53
		 */
54
		public function output() {
55
			$GLOBALS['give_hide_save_button'] = true;
56
			include_once( 'views/html-admin-page-system-info.php' );
57
		}
58
	}
59
60
endif;
61
62
return new Give_Settings_System_Info();
63