Completed
Push — master ( 4ff74f...939158 )
by Askupa
02:11
created

Page   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 12
loc 36
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A add_menu_page() 12 12 1
A default_args() 0 11 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
namespace Amarkal\Settings;
4
5
class Page
6
{   
0 ignored issues
show
Coding Style introduced by
The opening class brace should be on a newline by itself.
Loading history...
7
    private $config;
8
    
9
    public function __construct( array $args = array() ) 
10
    {
11
        $this->config = array_merge($this->default_args(), $args);
12
        
13
        \add_action('admin_menu', array($this,'add_menu_page'));
14
    }
15
    
16 View Code Duplication
    public function add_menu_page()
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...
17
    {
18
        \add_menu_page(
19
            $this->config['title'], 
20
            $this->config['menu_title'], 
21
            $this->config['capability'], 
22
            $this->config['slug'], 
23
            null, // Create a child page with the parent_slug set to this page's slug
24
            $this->config['icon'],
25
            $this->config['position']
26
        );
27
    }
28
    
29
    private function default_args()
30
    {
31
        return array(
32
            'slug'       => '',
33
            'title'      => '',
34
            'menu_title' => '',
35
            'icon'       => '',
36
            'position'   => 10,
37
            'capability' => 'manage_options'
38
        );
39
    }
40
}