Completed
Push — master ( 7c5112...0705e2 )
by
unknown
15s
created

LapsRecords   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 77
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 58.81%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 77
loc 77
ccs 10
cts 17
cp 0.5881
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onStartMapStart() 9 9 2
A onPlayerEndRace() 13 13 1
A onPlayerEndLap() 20 20 3
A onPlayerWayPoint() 16 16 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
<?php
2
3
namespace eXpansion\Bundle\LocalRecords\Plugins;
4
5
use eXpansion\Framework\GameTrackmania\DataProviders\Listener\RaceDataListenerInterface as TmRaceDataListenerInterface;
6
use Maniaplanet\DedicatedServer\Structures\Map;
7
8
/**
9
 * Class RaceRecords
10
 *
11
 * @package eXpansion\Bundle\LocalRecords\Plugins;
12
 * @author  oliver de Cramer <[email protected]>
13
 */
14 View Code Duplication
class LapsRecords extends BaseRecords implements TmRaceDataListenerInterface
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...
15
{
16
    /*
17
     * @inheritdoc
18
     */
19
    public function onStartMapStart($count, $time, $restarted, Map $map)
20
    {
21
        if (!$map->lapRace) {
22
            $this->status = false;
23
            return;
24
        }
25
26
        parent::onStartMapStart($count, $time, $restarted, $map);
27
    }
28
29
30
    /*
31
     * @inheritdoc
32
     */
33 1
    public function onPlayerEndRace(
34
        $login,
35
        $time,
36
        $raceTime,
37
        $stuntsScore,
38
        $cpInRace,
39
        $curCps,
40
        $blockId,
41
        $speed,
42
        $distance
43
    ) {
44
        // Nothing to do.
45 1
    }
46
47
    /*
48
     * @inheritdoc
49
     */
50 1
    public function onPlayerEndLap(
51
        $login,
52
        $time,
53
        $lapTime,
54
        $stuntsScore,
55
        $cpInLap,
56
        $curLapCps,
57
        $blockId,
58
        $speed,
59
        $distance
60
    ) {
61 1
        if (!$this->status) {
62
            return;
63
        }
64
65 1
        $eventData = $this->recordsHandler->addRecord($login, $lapTime, $curLapCps);
66 1
        if ($eventData) {
67 1
            $this->dispatchEvent($eventData);
68
        }
69 1
    }
70
71
    /*
72
     * @inheritdoc
73
     */
74 1
    public function onPlayerWayPoint(
75
        $login,
76
        $time,
77
        $raceTime,
78
        $lapTime,
79
        $stuntsScore,
80
        $cpInRace,
81
        $cpInLap,
82
        $curCps,
83
        $curLapCps,
84
        $blockId,
85
        $speed,
86
        $distance
87
    ) {
88
        // Nothing to do.
89 1
    }
90
}
91