Completed
Push — dev ( 8eacd8...04be10 )
by De Cramer
02:44
created

BaseDataProvider::onWayPoint()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 55
Code Lines 39

Duplication

Lines 32
Ratio 58.18 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 32
loc 55
rs 9.7692
c 0
b 0
f 0
ccs 0
cts 40
cp 0
cc 3
eloc 39
nc 4
nop 1
crap 12

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace eXpansion\Framework\GameTrackmania\DataProviders;
4
5
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider;
6
7
8
/**
9
 * Class BaseDataProvider
10
 *
11
 * @package eXpansion\Framework\GameTrackmania\DataProviders;
12
 * @author  oliver de Cramer <[email protected]>
13
 */
14
class BaseDataProvider extends AbstractDataProvider
15
{
16
    public function onWayPoint($params)
17
    {
18 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...
19
            $this->dispatch(
20
                'onPlayerEndRace',
21
                [
22
                    $params['login'],
23
                    $params['time'],
24
                    $params['racetime'],
25
                    $params['stuntsscore'],
26
                    $params['checkpointinrace'],
27
                    $params['curracecheckpoints'],
28
                    $params['blockid'],
29
                    $params['speed'],
30
                    $params['distance'],
31
                ]
32
            );
33
        }
34
35 View Code Duplication
        if ($params['isendlap']) {
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...
36
            $this->dispatch(
37
                'onPlayerEndLap',
38
                [
39
                    $params['login'],
40
                    $params['time'],
41
                    $params['laptime'],
42
                    $params['stuntsscore'],
43
                    $params['checkpointinlap'],
44
                    $params['curlapcheckpoints'],
45
                    $params['blockid'],
46
                    $params['speed'],
47
                    $params['distance'],
48
                ]
49
            );
50
        }
51
52
        $this->dispatch(
53
            'onPlayerWayPoint',
54
            [
55
                $params['login'],
56
                $params['time'],
57
                $params['racetime'],
58
                $params['laptime'],
59
                $params['stuntsscore'],
60
                $params['checkpointinrace'],
61
                $params['checkpointinlap'],
62
                $params['curracecheckpoints'],
63
                $params['curlapcheckpoints'],
64
                $params['blockid'],
65
                $params['speed'],
66
                $params['distance'],
67
            ]
68
        );
69
70
    }
71
72
}