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...
9
{
10
11
/** @var ConnectionLocator */
12
protected $connections;
13
14
/**
15
* @param ConnectonLocator $connections
16
*/
17
public function __construct(ConnectionLocator $connections)
18
{
19
$this->connections = $connections;
20
}
21
22
/**
23
* @param integer $id
24
*
25
* @return array|false
26
*/
27
public function getDistanceById($id)
28
{
29
$query = "
30
SELECT *
31
FROM `jpemeric_stream`.`distance`
32
WHERE `id` = :id
33
LIMIT 1";
34
$bindings = [
35
'id' => $id,
36
];
37
38
return $this
39
->connections
40
->getRead()
41
->fetchOne($query, $bindings);
42
}
43
44
/**
45
* @param DateTimeInterface $date
46
* @param string $type
47
* @param double $mileage
48
*
49
* @return array|false
50
*/
51
public function getDistanceByFields(DateTimeInterface $date, $type, $mileage)
52
{
53
$query = "
54
SELECT *
55
FROM `jpemeric_stream`.`distance`
56
WHERE `date` = :date AND `type` = :type AND `mileage` = :mileage
57
LIMIT 1";
58
$bindings = [
59
'date' => $date->format('Y-m-d H:i:s'),
60
'type' => $type,
61
'mileage' => $mileage,
62
];
63
64
return $this
65
->connections
66
->getRead()
67
->fetchOne($query, $bindings);
68
}
69
70
/**
71
* @return array|false
72
*/
73
public function getUnmappedDistances()
74
{
75
$query = "
76
SELECT `id`, `date`
77
FROM `jpemeric_stream`.`distance`
78
LEFT JOIN `jpemeric_stream`.`post`
79
ON `post`.`type_id` = `distance`.`id` AND `post`.`id` IS NULL";
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.