Completed
Pull Request — master (#48)
by Jakub
11:14 queued 02:07
created

main_module::main()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 7

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 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\ucp;
12
13
/**
14
 * Advertisement management ACP module.
15
 */
16 View Code Duplication
class main_module
1 ignored issue
show
Duplication introduced by
This class 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
	public $page_title;
19
	public $tpl_name;
20
	public $u_action;
21
22 1
	public function main()
23
	{
24 1
		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\ucp_controller $ucp_controller */
27 1
		$ucp_controller = $phpbb_container->get('phpbb.ads.ucp.controller');
28
29
		// Make the $u_action url available in the UCP controller
30 1
		$ucp_controller->set_page_url($this->u_action);
31
32
		// Load a template
33 1
		$this->tpl_name = 'ucp_ads_stats';
34
35
		// Set the page title for our UCP page
36 1
		$this->page_title = $ucp_controller->get_page_title();
37
38 1
		$ucp_controller->main();
39 1
	}
40
}
41