Completed
Push — master ( 050438...0a0307 )
by Matt
19s
created

main_module   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A main() 0 18 1
1
<?php
2
/**
3
 *
4
 * Advertisement management. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ads\acp;
12
13
/**
14
 * Advertisement management ACP module.
15
 */
16
class main_module
17
{
18
	public $page_title;
19
	public $tpl_name;
20
	public $u_action;
21
22 2
	public function main($id, $mode)
1 ignored issue
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
	{
24 2
		global $phpbb_container;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
25
26
		/** @var \phpbb\ads\controller\admin_controller $admin_controller */
27 2
		$admin_controller = $phpbb_container->get('phpbb.ads.admin.controller');
28
29
		// Make the $u_action url available in the admin controller
30 2
		$admin_controller->set_page_url($this->u_action);
31
32
		// Load a template from adm/style for our ACP page
33 2
		$this->tpl_name = $mode . '_ads';
34
35
		// Set the page title for our ACP page
36 2
		$this->page_title = $admin_controller->get_page_title();
37
38 2
		$admin_controller->{'mode_' . $mode}();
39 2
	}
40
}
41