Passed
Branch master (29aa47)
by Chris
05:48
created

monsterinsights_refresh_reports_data()   F

Complexity

Conditions 22
Paths > 20000

Size

Total Lines 66
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 22
eloc 38
nc 20480
nop 0
dl 0
loc 66
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Reports class.
4
 *
5
 * @since 6.0.0
6
 *
7
 * @package MonsterInsights
8
 * @subpackage Reports
9
 * @author  Chris Christoff
10
 */
11
12
// Exit if accessed directly
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
function monsterinsights_reports_page_body_class( $classes ) {
18
	if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] === 'monsterinsights_reports' ) {
19
		$classes .= ' monsterinsights-reporting-page ';
20
	}
21
	return $classes;
22
}
23
add_filter( 'admin_body_class', 'monsterinsights_reports_page_body_class' );
24
25
/**
26
 * Callback for getting all of the reports tabs for MonsterInsights.
27
 *
28
 * @since 6.0.0
29
 * @access public
30
 *
31
 * @return array Array of tab information.
32
 */
33
function monsterinsights_get_reports() {
34
	/**
35
	 * Developer Alert:
36
	 *
37
	 * Per the README, this is considered an internal hook and should
38
	 * not be used by other developers. This hook's behavior may be modified
39
	 * or the hook may be removed at any time, without warning.
40
	 */
41
	$reports =  apply_filters( 'monsterinsights_get_reports', array() );
42
	return $reports;
43
}
44
45
/**
46
 * Callback to output the MonsterInsights reports page.
47
 *
48
 * @since 6.0.0
49
 * @access public
50
 *
51
 * @return void
52
 */
53
function monsterinsights_reports_page() {
54
	/**
55
	 * Developer Alert:
56
	 *
57
	 * Per the README, this is considered an internal hook and should
58
	 * not be used by other developers. This hook's behavior may be modified
59
	 * or the hook may be removed at any time, without warning.
60
	 */
61
	do_action( 'monsterinsights_head' );
62
	echo monsterinsights_ublock_notice();
63
	monsterinsights_settings_error_page( 'monsterinsights-reports');
64
}
65