Failed Conditions
Pull Request — master (#353)
by Florian
03:58
created

QueryManager::current()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 3
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 6 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
include_once __DIR__ . '/../../../config.php';
4
include_once __DIR__ . '/QueryManagerMysql.php';
5
6
abstract class QueryManager {
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...
7
8
	protected static $time_offset;
9
	protected static $config;
10
11
	private static $current;
12
	public static function current() {
13
		global $time_offset;
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...
14
15
		if (self::$current == null) {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
16
17
			$variables = realpath(dirname(__FILE__)) . '/../../json/variables.json';
18
			self::$config = json_decode(file_get_contents($variables));
19
20
			include_once(SYS_PATH.'/core/process/timezone.loader.php');
21
			self::$time_offset = $time_offset;
22
23
			switch (self::$config->system->db_type) {
24
				case "monocle-hydro":
25
					self::$current = new QueryManagerMonocleHydro();
26
					break;
27
28
				default:
29
					self::$current = new QueryManagerRocketmap();
30
					break;
31
			}
32
		}
33
		return self::$current;
34
	}
35
	private function __construct(){}
0 ignored issues
show
introduced by
Something seems to be off here. Are you sure you want to declare the constructor as private, and the class as abstract?
Loading history...
36
37
	// Misc
38
	public abstract function getEcapedString($string);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
39
40
	// Tester
41
	public abstract function testTotalPokemon();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
42
	public abstract function testTotalGyms();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
43
	public abstract function testTotalPokestops();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
44
45
	// Homepage
46
	public abstract function getTotalPokemon();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
47
	public abstract function getTotalLures();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
48
	public abstract function getTotalGyms();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
49
	public abstract function getTotalRaids();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
50
	public abstract function getTotalGymsForTeam($team_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
51
	public abstract function getRecentAll();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
52
	public abstract function getRecentMythic($mythic_pokemon);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
53
54
	// Single Pokemon
55
	public abstract function getGymsProtectedByPokemon($pokemon_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
56
	public abstract function getPokemonLastSeen($pokemon_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
57
	public abstract function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
58
	public abstract function getTop50Trainers($pokemon_id, $best_order_by, $best_direction);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
59
	public abstract function getPokemonHeatmap($pokemon_id, $start, $end);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
60
	public abstract function getPokemonGraph($pokemon_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
61
	public abstract function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
62
	public abstract function getPokemonSliederMinMax();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
63
	public abstract function getMapsCoords();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
64
65
	// Pokestops
66
	public abstract function getTotalPokestops();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
67
	public abstract function getAllPokestops();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
68
69
	// Gyms
70
	public abstract function getTeamGuardians($team_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
71
	public abstract function getOwnedAndPoints($team_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
72
	public abstract function getAllGyms();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
73
	public abstract function getGymData($gym_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
74
	public abstract function getGymDefenders($gym_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
75
76
	// Raids
77
	public abstract function getAllRaids($page);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
78
79
	// Trainers
80
	public abstract function getTrainers($trainer_name, $team, $page, $ranking);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
81
	public abstract function getTrainerLevelCount($team_id);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
82
83
	// Cron
84
	public abstract function getPokemonCountsActive();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
85
	public abstract function getPoekmonCountsLastDay();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
86
	public abstract function getPokemonSinceLastUpdate($pokemon_id, $last_update);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
87
	public abstract function getRaidsSinceLastUpdate($pokemon_id, $last_update);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
88
	public abstract function getCaptchaCount();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
89
	public abstract function getNestData();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
90
}