Completed
Pull Request — master (#68)
by De Cramer
03:16
created

LapsRecords   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 87
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 2
dl 87
loc 87
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onPlayerEndRace() 13 13 1
A onPlayerWayPoint() 16 16 1
A onPlayerEndLap() 17 17 2

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
<?php
2
3
namespace eXpansion\Bundle\LocalRecords\Plugins;
4
5
use eXpansion\Framework\GameTrackmania\DataProviders\Listener\BaseDataListenerInterface as TmBaseDataListenerInterface;
6
7
/**
8
 * Class RaceRecords
9
 *
10
 * @package eXpansion\Bundle\LocalRecords\Plugins;
11
 * @author  oliver de Cramer <[email protected]>
12
 */
13 View Code Duplication
class LapsRecords extends BaseRecords implements TmBaseDataListenerInterface
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...
14
{
15
    /**
16
     * @param string $login       Login of the player that crossed the CP point
17
     * @param int    $time        Server time when the event occured,
18
     * @param int    $raceTime    Total race time in milliseconds
19
     * @param int    $stuntsScore Stunts score
20
     * @param int    $cpInRace    Number of checkpoints crossed since the beginning of the race
21
     * @param int[]  $curCps      Checkpoints times since the beginning of the race
22
     * @param string $blockId     Id of the checkpoint block
23
     * @param string $speed       Speed of the player in km/h
24
     * @param string $distance    Distance traveled by the player
25
     */
26 1
    public function onPlayerEndRace(
27
        $login,
28
        $time,
29
        $raceTime,
30
        $stuntsScore,
31
        $cpInRace,
32
        $curCps,
33
        $blockId,
34
        $speed,
35
        $distance
36
    ) {
37
        // Nothing to do.
38 1
    }
39
40
    /**
41
     * @param string $login       Login of the player that crossed the CP point
42
     * @param int    $time        Server time when the event occured,
43
     * @param int    $lapTime     Lap time in milliseconds
44
     * @param int    $stuntsScore Stunts score
45
     * @param int    $cpInLap     Number of checkpoints crossed since the beginning of the lap
46
     * @param int[]  $curLapCps   Checkpoints time since the beginning of the lap
47
     * @param string $blockId     Id of the checkpoint block
48
     * @param string $speed       Speed of the player in km/h
49
     * @param string $distance    Distance traveled by the player
50
     */
51 1
    public function onPlayerEndLap(
52
        $login,
53
        $time,
54
        $lapTime,
55
        $stuntsScore,
56
        $cpInLap,
57
        $curLapCps,
58
        $blockId,
59
        $speed,
60
        $distance
61
    ) {
62 1
        $eventData = $this->recordsHandler->addRecord($login, $lapTime, $curLapCps);
63
64 1
        if ($eventData) {
65 1
            $this->dispatchEvent($eventData);
66
        }
67 1
    }
68
69
    /**
70
     * @param string $login       Login of the player that crossed the CP point
71
     * @param int    $time        Server time when the event occured,
72
     * @param int    $raceTime    Total race time in milliseconds
73
     * @param int    $lapTime     Lap time in milliseconds
74
     * @param int    $stuntsScore Stunts score
75
     * @param int    $cpInRace    Number of checkpoints crossed since the beginning of the race
76
     * @param int    $cpInLap     Number of checkpoints crossed since the beginning of the lap
77
     * @param int[]  $curCps      Checkpoints times since the beginning of the race
78
     * @param int[]  $curLapCps   Checkpoints time since the beginning of the lap
79
     * @param string $blockId     Id of the checkpoint block
80
     * @param string $speed       Speed of the player in km/h
81
     * @param string $distance    Distance traveled by the player
82
     */
83 1
    public function onPlayerWayPoint(
84
        $login,
85
        $time,
86
        $raceTime,
87
        $lapTime,
88
        $stuntsScore,
89
        $cpInRace,
90
        $cpInLap,
91
        $curCps,
92
        $curLapCps,
93
        $blockId,
94
        $speed,
95
        $distance
96
    ) {
97
        // Nothing to do.
98
    }
99
}