Completed
Pull Request — master (#191)
by De Cramer
04:00
created

RaceDataProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 33
loc 33
rs 10
c 0
b 0
f 0
ccs 0
cts 16
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isCompatible() 4 4 1
A onWayPoint() 19 19 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace eXpansion\Framework\GameTrackmania\DataProviders\ScriptBaseRounds;
4
5
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider;
6
use eXpansion\Framework\Core\Model\CompatibilityCheckDataProviderInterface;
7
use Maniaplanet\DedicatedServer\Structures\Map;
8
9
/**
10
 * Class RaceDataProvider
11
 *
12
 * @author    de Cramer Oliver<[email protected]>
13
 * @copyright 2017 Smile
14
 * @package eXpansion\Framework\GameTrackmania\DataProviders\ScriptBaseRounds
15
 */
16 View Code Duplication
class RaceDataProvider extends AbstractDataProvider implements CompatibilityCheckDataProviderInterface
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...
17
{
18
    /**
19
     * Check if data provider is compatible with current situation.
20
     *
21
     * @return bool
22
     */
23
    public function isCompatible(Map $map): bool
24
    {
25
        return !$map->lapRace;
26
    }
27
28
29
    public function onWayPoint($params)
30
    {
31
        if ($params['isendrace']) {
32
            $this->dispatch(
33
                'onPlayerEndRace',
34
                [
35
                    $params['login'],
36
                    $params['time'],
37
                    $params['racetime'],
38
                    $params['stuntsscore'],
39
                    $params['checkpointinrace'],
40
                    $params['curracecheckpoints'],
41
                    $params['blockid'],
42
                    $params['speed'],
43
                    $params['distance'],
44
                ]
45
            );
46
        }
47
    }
48
}
49