These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Amarkal\Settings; |
||
4 | |||
5 | class Page |
||
6 | { |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
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
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. ![]() |
|||
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 | } |