Completed
Push — master ( 638f8a...aff35e )
by
unknown
15s
created

LapsRecords::onPlayerEndLap()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 0
Metric Value
dl 20
loc 20
ccs 6
cts 7
cp 0.8571
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 15
nc 3
nop 9
crap 3.0261

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->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