Completed
Push — master ( 31de30...727b9d )
by Askupa
03:14
created

Page::add_menu_page()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
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 subpage 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
}