PlayerDataProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 91
Duplicated Lines 29.67 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 27
loc 91
ccs 0
cts 56
cp 0
rs 10
c 0
b 0
f 0

6 Methods

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