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

main_module   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 25
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() 18 18 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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