Completed
Pull Request — master (#526)
by Michael
11:09 queued 01:05
created

StatsReservedRequests   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 41
loc 41
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 17 1
A getPageName() 0 3 1
A requiresWikiDatabase() 0 3 1
A getPageTitle() 0 3 1
A isProtected() 0 3 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
**********      English Wikipedia Account Request Interface      **********
4
***************************************************************************
5
** Wikipedia Account Request Graphic Design by Charles Melbye,           **
6
** which is licensed under a Creative Commons                            **
7
** Attribution-Noncommercial-Share Alike 3.0 United States License.      **
8
**                                                                       **
9
** All other code are released under the Public Domain                   **
10
** by the ACC Development Team.                                          **
11
**                                                                       **
12
** See CREDITS for the list of developers.                               **
13
***************************************************************************/
14
15
class StatsReservedRequests extends StatisticsPage
16
{
17
	protected function execute()
18
	{
19
		global $baseurl;
20
21
		$query = <<<sql
22
SELECT
23
    CONCAT('<a href="', '$baseurl', '/acc.php?action=zoom&amp;id=', p.id, '">', p.id, '</a>') AS '#',
24
    p.name AS 'Requested Name',
25
    p.status AS 'Status',
26
    u.username AS 'Reserved by'
27
FROM request p
28
    INNER JOIN user u ON u.id = p.reserved
29
WHERE reserved != 0;
30
sql;
31
32
		$qb = new QueryBrowser();
33
		return $qb->executeQueryToTable($query);
34
	}
35
36
	public function getPageName()
37
	{
38
		return "ReservedRequests";
39
	}
40
41
	public function getPageTitle()
42
	{
43
		return "All currently reserved requests";
44
	}
45
46
	public function isProtected()
47
	{
48
		return true;
49
	}
50
51
	public function requiresWikiDatabase()
52
	{
53
		return false;
54
	}
55
}
56