Completed
Pull Request — master (#180)
by De Cramer
03:01
created

RaceRecords::onPlayerEndLap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 14
loc 14
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
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