Completed
Push — master ( cf0c7a...520b04 )
by Jacob
03:43
created

DistanceCollector   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 24
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMissingDistances() 5 5 1
A getRow() 5 5 1
A getDistanceByFields() 7 7 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
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommend to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
3
Loader::load('collector', 'Collector');
4
5 View Code Duplication
final class DistanceCollector extends Collector
0 ignored issues
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...
6
{
7
8
	public static function getMissingDistances()
9
	{
10
		$query = "SELECT `id`, `date` FROM `jpemeric_stream`.`distance` WHERE `id` NOT IN (SELECT `type_id` FROM `jpemeric_stream`.`post` WHERE `type` = 'distance')";
11
		return self::run_query($query);
12
	}
13
14
	public static function getRow($id)
15
	{
16
		$query = "SELECT * FROM `jpemeric_stream`.`distance` WHERE `id` = '{$id}'";
17
		return self::run_row_query($query);
18
	}
19
20
	public static function getDistanceByFields($date, $type, $distance)
21
	{
22
		$type = self::escape($type);
23
		$distance = self::escape($distance);
24
		$query = "SELECT * FROM `jpemeric_stream`.`distance` WHERE `date` = '{$date}' && `type` = '{$type}' && `distance` = '{$distance}' LIMIT 1";
25
		return self::run_row_query($query);
26
	}
27
28
}