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

RaceDataProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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