Completed
Pull Request — master (#2)
by Jakub
04:32
created

main_module::main()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 22
ccs 0
cts 12
cp 0
rs 9.2
cc 1
eloc 8
nc 1
nop 2
crap 2
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\admanagement\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
	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...
Unused Code introduced by
The parameter $mode 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
		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\admanagement\controller\admin_controller $admin_controller */
27
		$admin_controller = $phpbb_container->get('phpbb.admanagement.admin.controller');
28
29
		// Make the $u_action url available in the admin controller
30
		$admin_controller->set_page_url($this->u_action);
31
32
		// Load a template from adm/style for our ACP page
33
		$this->tpl_name = 'manage_ads';
34
35
		// Set the page title for our ACP page
36
		$this->page_title = $admin_controller->get_page_title();
37
38
		switch ($admin_controller->get_action())
0 ignored issues
show
Unused Code introduced by
This switch statement is empty, and could be removed.

This check looks for switch statements that have no cases or where all cases have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the switch.

Loading history...
39
		{
40
		}
41
42
		$admin_controller->list_ads();
43
	}
44
}
45