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

RaceDataProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 43.84 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 32
loc 73
ccs 0
cts 43
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onWayPoint() 32 55 4

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;
4
5
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider;
6
use eXpansion\Framework\Core\Storage\MapStorage;
7
8
9
/**
10
 * Class RaceDataProvider
11
 *
12
 * @package eXpansion\Framework\GameTrackmania\DataProviders;
13
 * @author  oliver de Cramer <[email protected]>
14
 */
15
class RaceDataProvider extends AbstractDataProvider
16
{
17
    /** @var MapStorage */
18
    protected $mapStorage;
19
20
    /**
21
     * RaceDataProvider constructor.
22
     *
23
     * @param MapStorage $mapStorage
24
     */
25
    public function __construct(MapStorage $mapStorage)
26
    {
27
        $this->mapStorage = $mapStorage;
28
    }
29
30
31
    public function onWayPoint($params)
32
    {
33 View Code Duplication
        if ($params['isendrace']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
34
            $this->dispatch(
35
                'onPlayerEndRace',
36
                [
37
                    $params['login'],
38
                    $params['time'],
39
                    $params['racetime'],
40
                    $params['stuntsscore'],
41
                    $params['checkpointinrace'],
42
                    $params['curracecheckpoints'],
43
                    $params['blockid'],
44
                    $params['speed'],
45
                    $params['distance'],
46
                ]
47
            );
48
        }
49
50 View Code Duplication
        if ($params['isendlap'] && $this->mapStorage->getCurrentMap()->lapRace) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
51
            $this->dispatch(
52
                'onPlayerEndLap',
53
                [
54
                    $params['login'],
55
                    $params['time'],
56
                    $params['laptime'],
57
                    $params['stuntsscore'],
58
                    $params['checkpointinlap'],
59
                    $params['curlapcheckpoints'],
60
                    $params['blockid'],
61
                    $params['speed'],
62
                    $params['distance'],
63
                ]
64
            );
65
        }
66
67
        $this->dispatch(
68
            'onPlayerWayPoint',
69
            [
70
                $params['login'],
71
                $params['time'],
72
                $params['racetime'],
73
                $params['laptime'],
74
                $params['stuntsscore'],
75
                $params['checkpointinrace'],
76
                $params['checkpointinlap'],
77
                $params['curracecheckpoints'],
78
                $params['curlapcheckpoints'],
79
                $params['blockid'],
80
                $params['speed'],
81
                $params['distance'],
82
            ]
83
        );
84
85
    }
86
87
}
88