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

RaceRecords::startMap()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 3.7085

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 4
cts 7
cp 0.5714
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 2
nop 2
crap 3.7085
1
<?php
2
3
namespace eXpansion\Bundle\LocalRecords\Plugins;
4
5
use eXpansion\Framework\GameTrackmania\DataProviders\Listener\RaceDataListenerInterface as TmRaceDataListenerInterface;
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 RaceRecords 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...
14
{
15
    /**
16
     * @inheritdoc
17
     */
18 2
    public function startMap($map, $nbLaps)
19
    {
20 2
        if ($nbLaps == 1 && $map->lapRace) {
21
            $this->logger->info("Disabling race records.", ['nbLaps' => $nbLaps, 'map' => $map->lapRace]);
22
            $this->status = false;
23
            return;
24
        }
25
26 2
        parent::startMap($map, $nbLaps);
27 2
    }
28
29
30
    /**
31
     * @inheritdoc
32
     */
33 2
    public function onPlayerEndRace(
34
        $login,
35
        $time,
36
        $raceTime,
37
        $stuntsScore,
38
        $cpInRace,
39
        $curCps,
40
        $blockId,
41
        $speed,
42
        $distance
43
    )
44
    {
45 2
        if (!$this->status) {
46
            return;
47
        }
48
49 2
        $eventData = $this->recordsHandler->addRecord($login, $raceTime, $curCps);
50 2
        if ($eventData) {
51 1
            $this->dispatchEvent($eventData);
52
        }
53 2
    }
54
55
    /*
56
     * @inheritdoc
57
     */
58 1
    public function onPlayerEndLap(
59
        $login,
60
        $time,
61
        $lapTime,
62
        $stuntsScore,
63
        $cpInLap,
64
        $curLapCps,
65
        $blockId,
66
        $speed,
67
        $distance
68
    )
69
    {
70
        // Nothing to do.
71 1
    }
72
73
    /*
74
     * @inheritdoc
75
     */
76 1
    public function onPlayerWayPoint(
77
        $login,
78
        $time,
79
        $raceTime,
80
        $lapTime,
81
        $stuntsScore,
82
        $cpInRace,
83
        $cpInLap,
84
        $curCps,
85
        $curLapCps,
86
        $blockId,
87
        $speed,
88
        $distance
89
    )
90
    {
91
        // Nothing to do.
92 1
    }
93
}
94