Passed
Pull Request — dev/2.3.0 (#160)
by
unknown
03:30
created

EmailLogSystemInfo::print_version()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EmailLog\Core\UI\Component;
4
5
use EmailLog\Core\DB\TableManager;
6
/**
7
 * Email Log System Info.
8
 *
9
 * @see \EmailLog\Core\UI\Component\SystemInfo
10
 * @since 2.3.0
11
 */
12
class EmailLogSystemInfo extends SystemInfo {
13
14
	/**
15
	 * Setup hooks and filters.
16
	 */
17
	public function load() {
18
		add_action( 'system_info_before', array( $this, 'print_email_log_config' ), 10, 2 );
19
	}
20
21
	/**
22
	 * ##RefactorMe
23
	 * Dummy method which should return license key or keys based on license type
24
	 *
25
	 * @return string
26
	 */
27
	public function get_license_key(){
28
		return '';
29
	}
30
31
	public function print_email_log_config() {
32
		$email_log = email_log();
33
		?>
34
-- Email Log Configuration
35
36
Email Log Version:                  <?php echo $this->get_plugin_version() . "\n"; ?>
37
Number of Logs:                     <?php echo $email_log->table_manager->get_logs_count() . "\n"; ?>
38
Email Log DB Version:               <?php echo get_option( TableManager::DB_OPTION_NAME ) . "\n"; ?>
0 ignored issues
show
Bug introduced by
Are you sure get_option(EmailLog\Core...anager::DB_OPTION_NAME) of type mixed|false can be used in concatenation? ( Ignorable by Annotation )

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

38
Email Log DB Version:               <?php echo /** @scrutinizer ignore-type */ get_option( TableManager::DB_OPTION_NAME ) . "\n"; ?>
Loading history...
39
<?php if ( $this->get_license_key() === '' ) : ?>
40
License Key:                        <?php echo $this->get_license_key() . "\n"; ?>
41
<?php endif; ?>
42
<?php $email_log_core = get_option('email-log-core'); ?>
43
<?php if ( $email_log_core ) : ?>
44
Allowed Roles for Email Log View:   <?php echo implode( ', ', $email_log_core['allowed_user_roles'] ) . "\n"; ?>
45
Remove All Data on Uninstallation:  <?php echo $email_log_core['remove_on_uninstall'] !== '' ? "Yes" : "No" . "\n"; ?>
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Yes 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...
Coding Style Comprehensibility introduced by
The string literal No 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...
46
Disable Dash Board Widget:          <?php echo $email_log_core['hide_dashboard_widget'] === 'true' ? "Yes" : "No" . "\n"; ?>
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Yes 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...
Coding Style Comprehensibility introduced by
The string literal No 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...
47
<?php endif; ?>
48
<?php
49
	}
50
51
	protected function get_default_config() {
52
		$config = parent::get_default_config();
53
54
		$config['show_posts']      = false;
55
		$config['show_taxonomies'] = false;
56
57
		return $config;
58
	}
59
60
	protected function get_plugin_version() {
61
		$plugin_path = WP_PLUGIN_DIR . '/email-log/email-log.php';
62
		$plugin_data = get_plugin_data( $plugin_path );
63
64
		return $plugin_data['Version'];
65
	}
66
}
67