Completed
Push — master ( 04d19a...743d3f )
by Simon
02:19
created

StatsInactiveUsers   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
B execute() 0 29 2
A getPageName() 0 4 1
A getPageTitle() 0 4 1
A isProtected() 0 4 1
A requiresWikiDatabase() 0 4 1
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 StatsInactiveUsers extends StatisticsPage
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
16
{
17
	protected function execute()
0 ignored issues
show
Coding Style introduced by
execute uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
18
	{
19
		global $smarty;
0 ignored issues
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...
20
21
		// this is horrible.
22
		// yes, there is business logic in the templates
23
		// yes, there was some there before
24
		// yes, I have just added to it.
25
		//
26
		// I'm sorry.
27
		//
28
		// newinternal will fix this.
29
		$date = new DateTime();
30
		$date->modify("-90 days");
31
32
		$smarty->assign('datelimit', $date);
33
34
		$showImmune = false;
35
		if (isset($_GET['showimmune'])) {
36
			$showImmune = true;
37
		}
38
		$smarty->assign("showImmune", $showImmune);
39
40
		$inactiveUsers = User::getAllInactive(gGetDb());
41
42
		$smarty->assign("inactiveUsers", $inactiveUsers);
43
44
		return $smarty->fetch("statistics/inactiveusers.tpl");
45
	}
46
47
	public function getPageName()
48
	{
49
		return "InactiveUsers";
50
	}
51
52
	public function getPageTitle()
53
	{
54
		return "Inactive tool users";
55
	}
56
57
	public function isProtected()
58
	{
59
		return true;
60
	}
61
62
	public function requiresWikiDatabase()
63
	{
64
		return false;
65
	}
66
}
67