Completed
Push — master ( 0705e2...638f8a )
by De Cramer
13s
created

LapsRecords   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 78
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 4
dl 78
loc 78
ccs 10
cts 18
cp 0.5556
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onStartMapStart() 10 10 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->logger->info("Disabling lap records.", ['map' => $map->lapRace]);
23
            $this->status = false;
24
            return;
25
        }
26
27
        parent::onStartMapStart($count, $time, $restarted, $map);
28
    }
29
30
31
    /*
32
     * @inheritdoc
33
     */
34 1
    public function onPlayerEndRace(
35
        $login,
36
        $time,
37
        $raceTime,
38
        $stuntsScore,
39
        $cpInRace,
40
        $curCps,
41
        $blockId,
42
        $speed,
43
        $distance
44
    ) {
45
        // Nothing to do.
46 1
    }
47
48
    /*
49
     * @inheritdoc
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
        if (!$this->status) {
63
            return;
64
        }
65
66 1
        $eventData = $this->recordsHandler->addRecord($login, $lapTime, $curLapCps);
67 1
        if ($eventData) {
68 1
            $this->dispatchEvent($eventData);
69
        }
70 1
    }
71
72
    /*
73
     * @inheritdoc
74
     */
75 1
    public function onPlayerWayPoint(
76
        $login,
77
        $time,
78
        $raceTime,
79
        $lapTime,
80
        $stuntsScore,
81
        $cpInRace,
82
        $cpInLap,
83
        $curCps,
84
        $curLapCps,
85
        $blockId,
86
        $speed,
87
        $distance
88
    ) {
89
        // Nothing to do.
90 1
    }
91
}
92