Completed
Pull Request — master (#191)
by De Cramer
38:20 queued 15:13
created

RaceRecords::onPlayerEndRace()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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

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;
6
7
/**
8
 * Class RaceRecords
9
 *
10
 * @package eXpansion\Bundle\LocalRecords\Plugins;
11
 * @author  oliver de Cramer <[email protected]>
12
 */
13
class RaceRecords extends BaseRecords implements RaceDataListenerInterface
14
{
15
    /**
16
     * @inheritdoc
17
     */
18 2
    public function onPlayerEndRace(
19
        $login,
20
        $time,
21
        $raceTime,
22
        $stuntsScore,
23
        $cpInRace,
24
        $curCps,
25
        $blockId,
26
        $speed,
27
        $distance
28
    )
29
    {
30 2
        $eventData = $this->recordsHandler->addRecord($login, $raceTime, $curCps);
31 2
        if ($eventData) {
32 1
            $this->dispatchEvent($eventData);
33
        }
34 2
    }
35
}
36