QueryManagerMysqlMonocleAlternate   F
last analyzed

Complexity

Total Complexity 120

Size/Duplication

Total Lines 813
Duplicated Lines 67.77 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 551
loc 813
rs 1.787
c 0
b 0
f 0
wmc 120
lcom 1
cbo 1

48 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __destruct() 0 4 1
A testTotalPokemon() 15 17 3
A testTotalGyms() 15 17 3
A testTotalPokestops() 15 17 3
A getTotalPokemon() 0 8 1
A getTotalLures() 0 6 1
A getTotalGyms() 0 8 1
A getTotalRaids() 0 8 1
A getTotalGymsForTeam() 0 11 1
A getGymsProtectedByPokemon() 6 11 1
A getPokemonLastSeen() 10 12 1
A getTop50Trainers() 21 22 3
A getPokemonGraph() 15 17 3
B getPokemonLive() 35 36 11
A getPokemonSliderMinMax() 0 8 1
A getMapsCoords() 0 8 1
A getRecentAll() 17 17 3
A getRecentMythic() 18 18 3
A getTop50Pokemon() 18 18 2
A getPokemonHeatmap() 13 13 2
A getPokemonCount() 10 10 1
A getPokemonCountAll() 13 13 2
A getRaidCount() 10 10 1
A getRaidCountAll() 13 13 2
A getTotalPokestops() 0 8 1
A getAllPokestops() 11 11 2
A getTeamGuardians() 15 15 2
A getOwnedAndPoints() 11 11 1
A getAllGyms() 13 13 2
A getGymData() 11 11 1
A getGymDefenders() 14 14 2
A getAllRaids() 17 17 2
B getGymHistories() 13 34 9
A getGymHistoriesPokemon() 14 14 2
B getHistoryForGym() 20 39 8
A getHistoryForGymPokemon() 15 15 2
B getTrainers() 26 53 9
A getTrainerLevelRanking() 22 22 5
A getActivePokemon() 14 14 2
A getInactivePokemon() 14 14 2
A getTrainerLevelCount() 22 22 5
A getPokemonCountsActive() 11 11 2
A getTotalPokemonIV() 0 8 1
A getPokemonCountsLastDay() 15 15 2
A getCaptchaCount() 0 8 1
A getNestData() 21 23 3
A getSpawnpointCount() 8 10 1

How to fix   Duplicated Code    Complexity   

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:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like QueryManagerMysqlMonocleAlternate often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use QueryManagerMysqlMonocleAlternate, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Worldopole;
4
5
class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql
6
{
7
    public function __construct()
8
    {
9
        parent::__construct();
10
    }
11
12
    public function __destruct()
13
    {
14
        parent::__destruct();
15
    }
16
17
    ///////////
18
    // Tester
19
    ///////////
20
21 View Code Duplication
    public function testTotalPokemon()
0 ignored issues
show
Duplication introduced by
This method 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...
22
    {
23
        $req = 'SELECT COUNT(*) as total FROM sightings';
24
        $result = $this->mysqli->query($req);
25
        if (!is_object($result)) {
26
            return 1;
27
        } else {
28
            $data = $result->fetch_object();
29
            $total = $data->total;
30
31
            if (0 == $total) {
32
                return 2;
33
            }
34
        }
35
36
        return 0;
37
    }
38
39 View Code Duplication
    public function testTotalGyms()
0 ignored issues
show
Duplication introduced by
This method 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...
40
    {
41
        $req = 'SELECT COUNT(*) as total FROM forts';
42
        $result = $this->mysqli->query($req);
43
        if (!is_object($result)) {
44
            return 1;
45
        } else {
46
            $data = $result->fetch_object();
47
            $total = $data->total;
48
49
            if (0 == $total) {
50
                return 2;
51
            }
52
        }
53
54
        return 0;
55
    }
56
57 View Code Duplication
    public function testTotalPokestops()
0 ignored issues
show
Duplication introduced by
This method 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...
58
    {
59
        $req = 'SELECT COUNT(*) as total FROM pokestops';
60
        $result = $this->mysqli->query($req);
61
        if (!is_object($result)) {
62
            return 1;
63
        } else {
64
            $data = $result->fetch_object();
65
            $total = $data->total;
66
67
            if (0 == $total) {
68
                return 2;
69
            }
70
        }
71
72
        return 0;
73
    }
74
75
    /////////////
76
    // Homepage
77
    /////////////
78
79
    public function getTotalPokemon()
80
    {
81
        $req = 'SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP()';
82
        $result = $this->mysqli->query($req);
83
        $data = $result->fetch_object();
84
85
        return $data;
86
    }
87
88
    public function getTotalLures()
89
    {
90
        $data = (object) array('total' => 0);
91
92
        return $data;
93
    }
94
95
    public function getTotalGyms()
96
    {
97
        $req = 'SELECT COUNT(*) AS total FROM forts';
98
        $result = $this->mysqli->query($req);
99
        $data = $result->fetch_object();
100
101
        return $data;
102
    }
103
104
    public function getTotalRaids()
105
    {
106
        $req = 'SELECT COUNT(*) AS total FROM raids WHERE time_battle <= UNIX_TIMESTAMP() AND time_end >= UNIX_TIMESTAMP()';
107
        $result = $this->mysqli->query($req);
108
        $data = $result->fetch_object();
109
110
        return $data;
111
    }
112
113
    public function getTotalGymsForTeam($team_id)
114
    {
115
        $req = "SELECT COUNT(*) AS total
116
					FROM forts f
117
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
118
					WHERE team = '$team_id'";
119
        $result = $this->mysqli->query($req);
120
        $data = $result->fetch_object();
121
122
        return $data;
123
    }
124
125 View Code Duplication
    public function getRecentAll()
0 ignored issues
show
Duplication introduced by
This method 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...
126
    {
127
        $req = 'SELECT DISTINCT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
128
              lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
129
              FROM sightings
130
              ORDER BY updated DESC
131
              LIMIT 0,12';
132
        $result = $this->mysqli->query($req);
133
        $data = array();
134
        if ($result->num_rows > 0) {
135
            while ($row = $result->fetch_object()) {
136
                $data[] = $row;
137
            }
138
        }
139
140
        return $data;
141
    }
142
143 View Code Duplication
    public function getRecentMythic($mythic_pokemon)
0 ignored issues
show
Duplication introduced by
This method 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...
144
    {
145
        $req = 'SELECT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
146
                lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina
147
                FROM sightings
148
                WHERE pokemon_id IN ('.implode(',', $mythic_pokemon).')
149
                ORDER BY updated DESC
150
                LIMIT 0,12';
151
        $result = $this->mysqli->query($req);
152
        $data = array();
153
        if ($result->num_rows > 0) {
154
            while ($row = $result->fetch_object()) {
155
                $data[] = $row;
156
            }
157
        }
158
159
        return $data;
160
    }
161
162
    ///////////////////
163
    // Single Pokemon
164
    ///////////////////
165
166 View Code Duplication
    public function getGymsProtectedByPokemon($pokemon_id)
0 ignored issues
show
Duplication introduced by
This method 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...
167
    {
168
        $req = "SELECT COUNT(f.id) AS total
169
					FROM forts f
170
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
171
					WHERE guard_pokemon_id = '".$pokemon_id."'";
172
        $result = $this->mysqli->query($req);
173
        $data = $result->fetch_object();
174
175
        return $data;
176
    }
177
178 View Code Duplication
    public function getPokemonLastSeen($pokemon_id)
0 ignored issues
show
Duplication introduced by
This method 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...
179
    {
180
        $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude
181
                FROM sightings
182
                WHERE pokemon_id = '".$pokemon_id."'
183
                ORDER BY expire_timestamp DESC
184
                LIMIT 0,1";
185
        $result = $this->mysqli->query($req);
186
        $data = $result->fetch_object();
187
188
        return $data;
189
    }
190
191 View Code Duplication
    public function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction)
0 ignored issues
show
Duplication introduced by
This method 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...
192
    {
193
        $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS distime, pokemon_id as pokemon_id, FROM_UNIXTIME(expire_timestamp) as disappear_time, lat as latitude, lon as longitude,
194
                cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina,
195
                ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form
196
                FROM sightings
197
	            WHERE pokemon_id = '".$pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0'
198
	            ORDER BY $top_order_by $top_direction, expire_timestamp DESC
199
	            LIMIT 0,50";
200
201
        $result = $this->mysqli->query($req);
202
        $top = array();
203
        while ($data = $result->fetch_object()) {
204
            $top[] = $data;
205
        }
206
207
        return $top;
208
    }
209
210 View Code Duplication
    public function getTop50Trainers($pokemon_id, $best_order_by, $best_direction)
0 ignored issues
show
Duplication introduced by
This method 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...
211
    {
212
        $trainer_blacklist = '';
213
        if (!empty(self::$config->system->trainer_blacklist)) {
214
            $trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
215
        }
216
217
        $req = "SELECT owner_name as trainer_name, ROUND((100*((atk_iv)+(def_iv)+(sta_iv))/45),1) AS IV, move_1, move_2, cp as cp,
218
                FROM_UNIXTIME(last_modified) AS lasttime, last_modified as last_seen
219
                FROM gym_defenders
220
				WHERE pokemon_id = '".$pokemon_id."'".$trainer_blacklist."
221
				ORDER BY $best_order_by $best_direction, owner_name ASC
222
				LIMIT 0,50";
223
224
        $result = $this->mysqli->query($req);
225
        $toptrainer = array();
226
        while ($data = $result->fetch_object()) {
227
            $toptrainer[] = $data;
228
        }
229
230
        return $toptrainer;
231
    }
232
233 View Code Duplication
    public function getPokemonHeatmap($pokemon_id, $start, $end)
0 ignored issues
show
Duplication introduced by
This method 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...
234
    {
235
        $where = ' WHERE pokemon_id = '.$pokemon_id.' '
236
            ."AND FROM_UNIXTIME(expire_timestamp) BETWEEN '".$start."' AND '".$end."'";
237
        $req = 'SELECT lat AS latitude, lon AS longitude FROM sightings'.$where.' LIMIT 100000';
238
        $result = $this->mysqli->query($req);
239
        $points = array();
240
        while ($data = $result->fetch_object()) {
241
            $points[] = $data;
242
        }
243
244
        return $points;
245
    }
246
247 View Code Duplication
    public function getPokemonGraph($pokemon_id)
0 ignored issues
show
Duplication introduced by
This method 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...
248
    {
249
        $req = "SELECT COUNT(*) AS total, HOUR(disappear_time) AS disappear_hour
250
					FROM (SELECT FROM_UNIXTIME(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered
251
				GROUP BY disappear_hour
252
				ORDER BY disappear_hour";
253
        $result = $this->mysqli->query($req);
254
        $array = array_fill(0, 24, 0);
255
        while ($result && $data = $result->fetch_object()) {
256
            $array[$data->disappear_hour] = $data->total;
257
        }
258
        // shift array because AM/PM starts at 1AM not 0:00
259
        $array[] = $array[0];
260
        array_shift($array);
261
262
        return $array;
263
    }
264
265 View Code Duplication
    public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons)
0 ignored issues
show
Duplication introduced by
This method 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...
266
    {
267
        $inmap_pkms_filter = '';
268
        $where = ' WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = '.$pokemon_id;
269
270
        $reqTestIv = 'SELECT MAX(atk_iv) AS iv FROM sightings '.$where;
271
        $resultTestIv = $this->mysqli->query($reqTestIv);
272
        $testIv = $resultTestIv->fetch_object();
273
        if (!is_null($inmap_pokemons) && ('' != $inmap_pokemons)) {
274
            foreach ($inmap_pokemons as $inmap) {
275
                $inmap_pkms_filter .= "'".$inmap."',";
276
            }
277
            $inmap_pkms_filter = rtrim($inmap_pkms_filter, ',');
278
            $where .= ' AND encounter_id NOT IN ('.$inmap_pkms_filter.') ';
279
        }
280
        if (null != $testIv->iv && !is_null($ivMin) && ('' != $ivMin)) {
281
            $where .= ' AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= ('.$ivMin.') ';
282
        }
283
        if (null != $testIv->iv && !is_null($ivMax) && ('' != $ivMax)) {
284
            $where .= ' AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= ('.$ivMax.') ';
285
        }
286
        $req = 'SELECT pokemon_id, lat AS latitude, lon AS longitude,
287
    					FROM_UNIXTIME(expire_timestamp) AS disappear_time,
288
    					FROM_UNIXTIME(expire_timestamp) AS disappear_time_real,
289
    					atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina,
290
   						move_1, move_2
291
					FROM sightings '.$where.'
292
					LIMIT 5000';
293
        $result = $this->mysqli->query($req);
294
        $spawns = array();
295
        while ($data = $result->fetch_object()) {
296
            $spawns[] = $data;
297
        }
298
299
        return $spawns;
300
    }
301
302
    public function getPokemonSliderMinMax()
303
    {
304
        $req = 'SELECT FROM_UNIXTIME(MIN(expire_timestamp)) AS min, FROM_UNIXTIME(MAX(expire_timestamp)) AS max FROM sightings';
305
        $result = $this->mysqli->query($req);
306
        $data = $result->fetch_object();
307
308
        return $data;
309
    }
310
311
    public function getMapsCoords()
312
    {
313
        $req = 'SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints';
314
        $result = $this->mysqli->query($req);
315
        $data = $result->fetch_object();
316
317
        return $data;
318
    }
319
320 View Code Duplication
    public function getPokemonCount($pokemon_id)
0 ignored issues
show
Duplication introduced by
This method 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...
321
    {
322
        $req = 'SELECT count, last_seen, latitude, longitude
323
					FROM pokemon_stats
324
					WHERE pid = '.$pokemon_id;
325
        $result = $this->mysqli->query($req);
326
        $data = $result->fetch_object();
327
328
        return $data;
329
    }
330
331 View Code Duplication
    public function getPokemonCountAll()
0 ignored issues
show
Duplication introduced by
This method 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...
332
    {
333
        $req = 'SELECT pid as pokemon_id, count, last_seen, latitude, longitude
334
					FROM pokemon_stats
335
					GROUP BY pid';
336
        $result = $this->mysqli->query($req);
337
        $array = array();
338
        while ($data = $result->fetch_object()) {
339
            $array[] = $data;
340
        }
341
342
        return $array;
343
    }
344
345 View Code Duplication
    public function getRaidCount($pokemon_id)
0 ignored issues
show
Duplication introduced by
This method 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...
346
    {
347
        $req = 'SELECT count, last_seen, latitude, longitude
348
					FROM raid_stats
349
					WHERE pid = '.$pokemon_id;
350
        $result = $this->mysqli->query($req);
351
        $data = $result->fetch_object();
352
353
        return $data;
354
    }
355
356 View Code Duplication
    public function getRaidCountAll()
0 ignored issues
show
Duplication introduced by
This method 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...
357
    {
358
        $req = 'SELECT pid as pokemon_id, count, last_seen, latitude, longitude
359
					FROM raid_stats
360
					GROUP BY pid';
361
        $result = $this->mysqli->query($req);
362
        $array = array();
363
        while ($data = $result->fetch_object()) {
364
            $array[] = $data;
365
        }
366
367
        return $array;
368
    }
369
370
    ///////////////
371
    // Pokestops
372
    //////////////
373
374
    public function getTotalPokestops()
375
    {
376
        $req = 'SELECT COUNT(*) as total FROM pokestops';
377
        $result = $this->mysqli->query($req);
378
        $data = $result->fetch_object();
379
380
        return $data;
381
    }
382
383 View Code Duplication
    public function getAllPokestops()
0 ignored issues
show
Duplication introduced by
This method 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...
384
    {
385
        $req = 'SELECT lat as latitude, lon as longitude, null AS lure_expiration, UNIX_TIMESTAMP() AS now, null AS lure_expiration_real FROM pokestops';
386
        $result = $this->mysqli->query($req);
387
        $pokestops = array();
388
        while ($data = $result->fetch_object()) {
389
            $pokestops[] = $data;
390
        }
391
392
        return $pokestops;
393
    }
394
395
    /////////
396
    // Gyms
397
    /////////
398
399 View Code Duplication
    public function getTeamGuardians($team_id)
0 ignored issues
show
Duplication introduced by
This method 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...
400
    {
401
        $req = "SELECT COUNT(*) AS total, guard_pokemon_id
402
					FROM forts f
403
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
404
					WHERE team = '".$team_id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3";
405
        $result = $this->mysqli->query($req);
406
407
        $datas = array();
408
        while ($data = $result->fetch_object()) {
409
            $datas[] = $data;
410
        }
411
412
        return $datas;
413
    }
414
415 View Code Duplication
    public function getOwnedAndPoints($team_id)
0 ignored issues
show
Duplication introduced by
This method 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...
416
    {
417
        $req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points
418
        			FROM forts f
419
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
420
        			WHERE fs.team = '".$team_id."'";
421
        $result = $this->mysqli->query($req);
422
        $data = $result->fetch_object();
423
424
        return $data;
425
    }
426
427 View Code Duplication
    public function getAllGyms()
0 ignored issues
show
Duplication introduced by
This method 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...
428
    {
429
        $req = 'SELECT f.id as gym_id, team as team_id, f.lat as latitude, f.lon as longitude, updated as last_scanned, (6 - fs.slots_available) AS level
430
					FROM forts f
431
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id));';
432
        $result = $this->mysqli->query($req);
433
        $gyms = array();
434
        while ($data = $result->fetch_object()) {
435
            $gyms[] = $data;
436
        }
437
438
        return $gyms;
439
    }
440
441 View Code Duplication
    public function getGymData($gym_id)
0 ignored issues
show
Duplication introduced by
This method 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...
442
    {
443
        $req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, FROM_UNIXTIME(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp
444
			FROM forts f
445
			LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
446
			WHERE f.id ='".$gym_id."'";
447
        $result = $this->mysqli->query($req);
448
        $data = $result->fetch_object();
449
450
        return $data;
451
    }
452
453 View Code Duplication
    public function getGymDefenders($gym_id)
0 ignored issues
show
Duplication introduced by
This method 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...
454
    {
455
        $req = "SELECT external_id as pokemon_uid, pokemon_id, atk_iv as iv_attack, def_iv as iv_defense, sta_iv as iv_stamina, cp, fort_id as gym_id
456
			FROM gym_defenders
457
			WHERE fort_id='".$gym_id."'
458
			ORDER BY deployment_time";
459
        $result = $this->mysqli->query($req);
460
        $defenders = array();
461
        while ($data = $result->fetch_object()) {
462
            $defenders[] = $data;
463
        }
464
465
        return $defenders;
466
    }
467
468
    ///////////
469
    // Raids
470
    ///////////
471
472 View Code Duplication
    public function getAllRaids($page)
0 ignored issues
show
Duplication introduced by
This method 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...
473
    {
474
        $limit = ' LIMIT '.($page * 10).',10';
475
        $req = 'SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, FROM_UNIXTIME(r.time_spawn) AS spawn, FROM_UNIXTIME(r.time_battle) AS start, FROM_UNIXTIME(r.time_end) AS end, FROM_UNIXTIME(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude
476
					FROM forts f
477
					LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
478
				 	LEFT JOIN raids r ON (r.fort_id = f.id AND r.time_end >= UNIX_TIMESTAMP())
479
					WHERE r.time_end > UNIX_TIMESTAMP()
480
					ORDER BY r.level DESC, r.time_battle'.$limit;
481
        $result = $this->mysqli->query($req);
482
        $raids = array();
483
        while ($data = $result->fetch_object()) {
484
            $raids[] = $data;
485
        }
486
487
        return $raids;
488
    }
489
490
    ////////////////
491
    // Gym History
492
    ////////////////
493
494
    public function getGymHistories($gym_name, $team, $page, $ranking)
495
    {
496
        $where = '';
497
        if (isset($gym_name) && '' != $gym_name) {
498
            $where = " WHERE name LIKE '%".$gym_name."%'";
499
        }
500 View Code Duplication
        if (isset($team) && '' != $team) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
501
            $where .= ('' === $where ? ' WHERE' : ' AND').' fs.team = '.$team;
502
        }
503 View Code Duplication
        switch ($ranking) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
504
            case 1:
505
                $order = ' ORDER BY name, last_modified DESC';
506
                break;
507
            case 2:
508
                $order = ' ORDER BY total_cp DESC, last_modified DESC';
509
                break;
510
            default:
511
                $order = ' ORDER BY last_modified DESC, name';
512
        }
513
514
        $limit = ' LIMIT '.($page * 10).',10';
515
516
        $req = 'SELECT f.id as gym_id, fs.total_cp, f.name, fs.team as team_id, (6 - slots_available) as pokemon_count, FROM_UNIXTIME(last_modified) AS last_modified
517
			FROM forts f
518
			LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))
519
			'.$where.$order.$limit;
520
        $result = $this->mysqli->query($req);
521
        $gym_history = array();
522
        while ($data = $result->fetch_object()) {
523
            $gym_history[] = $data;
524
        }
525
526
        return $gym_history;
527
    }
528
529 View Code Duplication
    public function getGymHistoriesPokemon($gym_id)
0 ignored issues
show
Duplication introduced by
This method 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...
530
    {
531
        $req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name
532
					FROM gym_defenders
533
					WHERE fort_id = '".$gym_id."'
534
					ORDER BY deployment_time";
535
        $result = $this->mysqli->query($req);
536
        $pokemons = array();
537
        while ($data = $result->fetch_object()) {
538
            $pokemons[] = $data;
539
        }
540
541
        return $pokemons;
542
    }
543
544
    public function getHistoryForGym($page, $gym_id)
545
    {
546 View Code Duplication
        if (isset(self::$config->system->gymhistory_hide_cp_changes) && true === self::$config->system->gymhistory_hide_cp_changes) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
547
            $pageSize = 25;
548
        } else {
549
            $pageSize = 10;
550
        }
551
        $req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, FROM_UNIXTIME(fs.last_modified) as last_modified, last_modified as last_modified_real
552
					FROM fort_sightings fs
553
					LEFT JOIN forts f ON f.id = fs.fort_id
554
					WHERE f.id = '".$gym_id."'
555
					ORDER BY fs.last_modified DESC
556
					LIMIT ".($page * $pageSize).','.($pageSize + 1);
557
        $result = $this->mysqli->query($req);
558
        $history = array();
559
        $count = 0;
560 View Code Duplication
        while ($data = $result->fetch_object()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
561
            ++$count;
562
            if (0 == $data->total_cp) {
563
                $data->pokemon = array();
564
                $data->pokemon_count = 0;
565
                $data->pokemon_uids = '';
566
            } else {
567
                $data->pokemon = $this->getHistoryForGymPokemon($gym_id, $data->last_modified_real);
568
                $data->pokemon_count = count($data->pokemon);
569
                $data->pokemon_uids = implode(',', array_keys($data->pokemon));
570
            }
571
            if (0 === $data->total_cp || 0 !== $data->pokemon_count) {
572
                $history[] = $data;
573
            }
574
        }
575
        if ($count !== ($pageSize + 1)) {
576
            $last_page = true;
577
        } else {
578
            $last_page = false;
579
        }
580
581
        return array('last_page' => $last_page, 'data' => $history);
582
    }
583
584 View Code Duplication
    private function getHistoryForGymPokemon($gym_id, $last_modified)
0 ignored issues
show
Duplication introduced by
This method 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...
585
    {
586
        $req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name
587
					FROM gym_history_defenders ghd
588
					JOIN gym_defenders gd ON ghd.defender_id = gd.external_id
589
					WHERE ghd.fort_id = '".$gym_id."' AND date = '".$last_modified."'
590
					ORDER BY gd.deployment_time";
591
        $result = $this->mysqli->query($req);
592
        $pokemons = array();
593
        while ($data = $result->fetch_object()) {
594
            $pokemons[$data->defender_id] = $data;
595
        }
596
597
        return $pokemons;
598
    }
599
600
    //////////////
601
    // Trainers
602
    //////////////
603
604
    public function getTrainers($trainer_name, $team, $page, $rankingNumber)
605
    {
606
        $ranking = $this->getTrainerLevelRanking();
607
        $where = '';
608
        if (!empty(self::$config->system->trainer_blacklist)) {
609
            $where .= " AND gd.owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
610
        }
611
        if ('' != $trainer_name) {
612
            $where = " AND gd.owner_name LIKE '%".$trainer_name."%'";
613
        }
614 View Code Duplication
        if (0 != $team) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
615
            $where .= ('' == $where ? ' HAVING' : ' AND').' team = '.$team;
616
        }
617 View Code Duplication
        switch ($rankingNumber) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
618
            case 1:
619
                $order = ' ORDER BY active DESC, level DESC';
620
                break;
621
            case 2:
622
                $order = ' ORDER BY maxCp DESC, level DESC';
623
                break;
624
            default:
625
                $order = ' ORDER BY level DESC, active DESC';
626
        }
627
        $order .= ', last_seen DESC, name ';
628
        $limit = ' LIMIT '.($page * 10).',10 ';
629
        $req = 'SELECT gd.owner_name AS name, MAX(owner_level) AS level, MAX(cp) AS maxCp, MAX(active) AS active, MAX(team) AS team, FROM_UNIXTIME(MAX(last_modified)) as last_seen
630
				  	FROM gym_defenders gd
631
				  	LEFT JOIN (
632
				  		SELECT owner_name, COUNT(*) as active
633
				  		FROM gym_defenders gd2
634
						WHERE fort_id IS NOT NULL
635
				  		GROUP BY owner_name
636
				  	) active ON active.owner_name = gd.owner_name
637
				  	WHERE gd.owner_level IS NOT NULL '.$where.'
638
				  	GROUP BY gd.owner_name'.$order.$limit;
639
        $result = $this->mysqli->query($req);
640
        $trainers = array();
641 View Code Duplication
        while ($data = $result->fetch_object()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
642
            $data->last_seen = date('Y-m-d', strtotime($data->last_seen));
643
            if (is_null($data->active)) {
644
                $data->active = 0;
645
            }
646
            $trainers[$data->name] = $data;
647
648
            $pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name));
649
650
            $trainers[$data->name]->gyms = $data->active;
651
            $trainers[$data->name]->pokemons = $pokemon;
652
            $trainers[$data->name]->rank = $ranking[$data->level];
653
        }
654
655
        return $trainers;
656
    }
657
658 View Code Duplication
    public function getTrainerLevelRanking()
0 ignored issues
show
Duplication introduced by
This method 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...
659
    {
660
        $exclue = '';
661
        if (!empty(self::$config->system->trainer_blacklist)) {
662
            $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
663
        }
664
        $req = 'SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL '.$exclue.' GROUP BY owner_level, owner_name) x GROUP BY level';
665
        $result = $this->mysqli->query($req);
666
        $levelData = array();
667
        while ($data = $result->fetch_object()) {
668
            $levelData[$data->level] = $data->count;
669
        }
670
        for ($i = 5; $i <= 40; ++$i) {
671
            if (!isset($levelData[$i])) {
672
                $levelData[$i] = 0;
673
            }
674
        }
675
        // sort array again
676
        ksort($levelData);
677
678
        return $levelData;
679
    }
680
681 View Code Duplication
    public function getActivePokemon($trainer_name)
0 ignored issues
show
Duplication introduced by
This method 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...
682
    {
683
        $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, FROM_UNIXTIME(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned
684
						FROM gym_defenders
685
						WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL
686
						ORDER BY deployment_time";
687
        $result = $this->mysqli->query($req);
688
        $pokemon = array();
689
        while ($data = $result->fetch_object()) {
690
            $pokemon[] = $data;
691
        }
692
693
        return $pokemon;
694
    }
695
696 View Code Duplication
    public function getInactivePokemon($trainer_name)
0 ignored issues
show
Duplication introduced by
This method 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...
697
    {
698
        $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, NULL AS deployment_time, '0' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned
699
					FROM gym_defenders
700
					WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL
701
					ORDER BY last_scanned";
702
        $result = $this->mysqli->query($req);
703
        $pokemon = array();
704
        while ($data = $result->fetch_object()) {
705
            $pokemon[] = $data;
706
        }
707
708
        return $pokemon;
709
    }
710
711 View Code Duplication
    public function getTrainerLevelCount($team_id)
0 ignored issues
show
Duplication introduced by
This method 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...
712
    {
713
        $exclue = '';
714
        if (!empty(self::$config->system->trainer_blacklist)) {
715
            $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')";
716
        }
717
        $req = "SELECT COUNT(*) AS count, level FROM (SELECT MAX(owner_level) as level FROM gym_defenders WHERE owner_level IS NOT NULL AND team = '".$team_id."' ".$exclue.' GROUP BY owner_level, owner_name) x GROUP BY level';
718
        $result = $this->mysqli->query($req);
719
        $levelData = array();
720
        while ($data = $result->fetch_object()) {
721
            $levelData[$data->level] = $data->count;
722
        }
723
        for ($i = 5; $i <= 40; ++$i) {
724
            if (!isset($levelData[$i])) {
725
                $levelData[$i] = 0;
726
            }
727
        }
728
        // sort array again
729
        ksort($levelData);
730
731
        return $levelData;
732
    }
733
734
    /////////
735
    // Cron
736
    /////////
737
738 View Code Duplication
    public function getPokemonCountsActive()
0 ignored issues
show
Duplication introduced by
This method 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...
739
    {
740
        $req = 'SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() GROUP BY pokemon_id';
741
        $result = $this->mysqli->query($req);
742
        $counts = array();
743
        while ($data = $result->fetch_object()) {
744
            $counts[$data->pokemon_id] = $data->total;
745
        }
746
747
        return $counts;
748
    }
749
750
    public function getTotalPokemonIV()
751
    {
752
        $req = 'SELECT COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() AND cp IS NOT NULL';
753
        $result = $this->mysqli->query($req);
754
        $data = $result->fetch_object();
755
756
        return $data;
757
    }
758 View Code Duplication
    public function getPokemonCountsLastDay()
0 ignored issues
show
Duplication introduced by
This method 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...
759
    {
760
        $req = 'SELECT pokemon_id, COUNT(*) AS spawns_last_day
761
					FROM sightings
762
					WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings)
763
					GROUP BY pokemon_id
764
				  	ORDER BY pokemon_id ASC';
765
        $result = $this->mysqli->query($req);
766
        $counts = array();
767
        while ($data = $result->fetch_object()) {
768
            $counts[$data->pokemon_id] = $data->spawns_last_day;
769
        }
770
771
        return $counts;
772
    }
773
774
    public function getCaptchaCount()
775
    {
776
        $req = ' SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL';
777
        $result = $this->mysqli->query($req);
778
        $data = $result->fetch_object();
779
780
        return $data;
781
    }
782
783 View Code Duplication
    public function getNestData($time, $minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
0 ignored issues
show
Duplication introduced by
This method 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...
784
    {
785
        $pokemon_exclude_sql = '';
786
        if (!empty(self::$config->system->nest_exclude_pokemon)) {
787
            $pokemon_exclude_sql = 'AND p.pokemon_id NOT IN ('.implode(',', self::$config->system->nest_exclude_pokemon).')';
788
        }
789
        $req = 'SELECT p.pokemon_id, MAX(p.lat) AS latitude, MAX(p.lon) AS longitude, count(p.pokemon_id) AS total_pokemon, MAX(s.updated) as latest_seen, coalesce(CASE WHEN MAX(duration) = 0 THEN NULL ELSE MAX(duration) END ,30)*60 as duration
790
			          FROM sightings p
791
			          INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id)
792
			          WHERE p.expire_timestamp > UNIX_TIMESTAMP() - '.($time * 3600).'
793
			            AND p.lat >= '.$minLatitude.' AND p.lat < '.$maxLatitude.' AND p.lon >= '.$minLongitude.' AND p.lon < '.$maxLongitude.'
794
			          '.$pokemon_exclude_sql.'
795
			          GROUP BY p.spawn_id, p.pokemon_id
796
			          HAVING COUNT(p.pokemon_id) >= '.($time / 4).'
797
			          ORDER BY p.pokemon_id';
798
        $result = $this->mysqli->query($req);
799
        $nests = array();
800
        while ($data = $result->fetch_object()) {
801
            $nests[] = $data;
802
        }
803
804
        return $nests;
805
    }
806
807 View Code Duplication
    public function getSpawnpointCount($minLatitude, $maxLatitude, $minLongitude, $maxLongitude)
0 ignored issues
show
Duplication introduced by
This method 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...
808
    {
809
        $req = 'SELECT COUNT(*) as total 
810
					FROM spawnpoints 
811
 					WHERE lat >= '.$minLatitude.' AND lat < '.$maxLatitude.' AND lon >= '.$minLongitude.' AND lon < '.$maxLongitude;
812
        $result = $this->mysqli->query($req);
813
        $data = $result->fetch_object();
814
815
        return $data;
816
    }
817
}
818