Completed
Pull Request — master (#210)
by
unknown
03:50
created

PlayerDataProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 90
Duplicated Lines 30 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 2
dl 27
loc 90
ccs 0
cts 45
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A onPlayerHit() 0 13 1
A onArmorEmpty() 11 11 1
A onCapture() 0 9 1
A onPlayerTriggersSector() 0 6 1
A onPlayerTouchesObject() 8 8 1
A onPlayerThrowsObject() 8 8 1

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\GameShootmania\DataProviders;
4
5
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider;
6
use eXpansion\Framework\GameShootmania\Structures\Landmark;
7
8
/**
9
 * Class PlayerDataProvider provides information to plugins about what is going on with players.
10
 *
11
 * @package eXpansion\Framework\Core\DataProviders
12
 */
13
class PlayerDataProvider extends AbstractDataProvider
14
{
15
16
    /**
17
     * Callback sent when a player is hit.
18
     *
19
     * @param $params
20
     */
21
    public function onPlayerHit($params)
22
    {
23
        $this->dispatch(__FUNCTION__, [
24
            $params['shooter'],
25
            $params['victim'],
26
            $params['weapon'],
27
            $params['damage'],
28
            $params['points'],
29
            $params['distance'],
30
            (object)$params['shooterPosition'],
31
            (object)$params['victimPosition'],
32
        ]);
33
    }
34
35
    /**
36
     * Callback sent when a player is eliminated.
37
     *
38
     * @param $params
39
     */
40 View Code Duplication
    public function onArmorEmpty($params)
0 ignored issues
show
Duplication introduced by
This method 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...
41
    {
42
        $this->dispatch(__FUNCTION__, [
43
            $params['shooter'],
44
            $params['victim'],
45
            $params['weapon'],
46
            $params['distance'],
47
            (object)$params['shooterposition'],
48
            (object)$params['victimposition'],
49
        ]);
50
    }
51
52
53
    /**
54
     * @param $params
55
     */
56
    public function onCapture($params)
57
    {
58
        $landmarkObj = Landmark::fromArray($params['landmark']);
59
60
        $this->dispatch(__FUNCTION__, [
61
            $params['players'],
62
            $landmarkObj,
63
        ]);
64
    }
65
66
    /**
67
     * @param $params
68
     */
69
    public function onPlayerTriggersSector($params) {
70
        $this->dispatch(__FUNCTION__, [
71
            $params['login'],
72
            $params['sectorid'],
73
        ]);
74
    }
75
76
    /**
77
     *
78
     * @param $params
79
     */
80 View Code Duplication
    public function onPlayerTouchesObject($params) {
0 ignored issues
show
Duplication introduced by
This method 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...
81
        $this->dispatch(__FUNCTION__, [
82
            $params['login'],
83
            $params['objectid'],
84
            $params['modelid'],
85
            $params['modelname'],
86
        ]);
87
    }
88
89
    /**
90
     *
91
     * @param $params
92
     */
93 View Code Duplication
    public function onPlayerThrowsObject($params) {
0 ignored issues
show
Duplication introduced by
This method 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...
94
        $this->dispatch(__FUNCTION__, [
95
            $params['login'],
96
            $params['objectid'],
97
            $params['modelid'],
98
            $params['modelname'],
99
        ]);
100
    }
101
102
}
103