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

LapsRecords::onPlayerEndRace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 2
cts 2
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 9
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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