Passed
Pull Request — master (#47)
by Kiran
04:02
created

WPInv_Recurring_Admin   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A actions() 0 9 1
A filters() 0 2 1
A add_submenu() 0 12 1
A subscriptions_page() 0 3 1
A enqueue_styles() 0 2 1
A enqueue_scripts() 0 2 1
1
<?php
2
if ( ! defined( 'ABSPATH' ) ) {
3
    exit; // Exit if accessed directly
4
}
5
6
class WPInv_Recurring_Admin {
7
    
8
    /**
9
     * Get started
10
     */
11
    function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
12
        self::actions();
13
        self::filters();
0 ignored issues
show
Unused Code introduced by
The call to the method WPInv_Recurring_Admin::filters() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
14
    }
15
16
     /**
17
     * Add actions
18
     *
19
     * @since  1.0.0
20
     * @return void
21
     */
22
    private function actions() {
23
        add_action( 'admin_menu', array( $this, 'add_submenu' ), 11 );
24
25
        // Register styles
26
        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
27
28
        // Register scripts
29
        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
30
    }
31
32
    /**
33
     * Add filters
34
     *
35
     * @since  1.0.0
36
     * @return void
37
     */
38
    private function filters() {
39
    }
40
    
41
    public function add_submenu() {
42
        global $wpi_subscriptions_page;
43
        
44
        $wpi_subscriptions_page = add_submenu_page( 
45
            'wpinv', 
46
            __( 'Subscriptions', 'invoicing' ), 
47
            __( 'Subscriptions', 'invoicing' ), 
48
            'manage_options', 
49
            'wpinv-subscriptions', 
50
            array( $this, 'subscriptions_page' ) 
51
        );
52
    }
53
    
54
    public function subscriptions_page() {
55
        wpinv_recurring_subscriptions_list();
56
    }
57
58
    /**
59
     * Load frontend styles
60
     *
61
     * @since  1.0.0
62
     * @return bool
63
     */
64
    public function enqueue_styles() {
65
    }
66
67
    /**
68
     * Load frontend javascript files
69
     *
70
     * @since  1.0.0
71
     * @return bool
72
     */
73
    public function enqueue_scripts() {
74
    }
75
}
76
77
new WPInv_Recurring_Admin();