Passed
Push — master ( bdc105...ec8122 )
by Peter
01:57
created

Participant   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 223
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 223
ccs 73
cts 73
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 49 1
A createFromArray() 0 52 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Match;
4
5
use Webmozart\Assert\Assert;
6
7
/**
8
 * @SuppressWarnings(PHPMD.TooManyFields)
9
 */
10
class Participant
11
{
12
    /**
13
     * @var string
14
     */
15
    public $type;
16
17
    /**
18
     * @var string
19
     */
20
    public $id;
21
22
    /**
23
     * @var string
24
     */
25
    public $actor;
26
27
    /**
28
     * @var string
29
     */
30
    public $shardId;
31
32
    /**
33
     * @var int
34
     */
35
    public $abilityUses;
36
37
    /**
38
     * @var int
39
     */
40
    public $attachment;
41
42
    /**
43
     * @var int
44
     */
45
    public $damageDone;
46
47
    /**
48
     * @var int
49
     */
50
    public $damageReceived;
51
52
    /**
53
     * @var int
54
     */
55
    public $deaths;
56
57
    /**
58
     * @var int
59
     */
60
    public $disablesDone;
61
62
    /**
63
     * @var int
64
     */
65
    public $disablesReceived;
66
67
    /**
68
     * @var int
69
     */
70
    public $emote;
71
72
    /**
73
     * @var int
74
     */
75
    public $energyGained;
76
77
    /**
78
     * @var int
79
     */
80
    public $energyUsed;
81
82
    /**
83
     * @var int
84
     */
85
    public $healingDone;
86
87
    /**
88
     * @var int
89
     */
90
    public $healingReceived;
91
92
    /**
93
     * @var int
94
     */
95
    public $kills;
96
97
    /**
98
     * @var int
99
     */
100
    public $mount;
101
102
    /**
103
     * @var int
104
     */
105
    public $outfit;
106
107
    /**
108
     * @var int
109
     */
110
    public $score;
111
112
    /**
113
     * @var int
114
     */
115
    public $side;
116
117
    /**
118
     * @var int
119
     */
120
    public $timeAlive;
121
122
    /**
123
     * @var string
124
     */
125
    public $userID;
126
127
    /**
128
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
129
     */
130 1
    private function __construct(
131
        string $type,
132
        string $id,
133
        string $actor,
134
        string $shardId,
135
        int $abilityUses,
136
        int $attachment,
137
        int $damageDone,
138
        int $damageReceived,
139
        int $deaths,
140
        int $disablesDone,
141
        int $disablesReceived,
142
        int $emote,
143
        int $energyGained,
144
        int $energyUsed,
145
        int $healingDone,
146
        int $healingReceived,
147
        int $kills,
148
        int $mount,
149
        int $outfit,
150
        int $score,
151
        int $side,
152
        int $timeAlive,
153
        string $userID
154
    ) {
155 1
        $this->type = $type;
156 1
        $this->id = $id;
157 1
        $this->actor = $actor;
158 1
        $this->shardId = $shardId;
159 1
        $this->abilityUses = $abilityUses;
160 1
        $this->attachment = $attachment;
161 1
        $this->damageDone = $damageDone;
162 1
        $this->damageReceived = $damageReceived;
163 1
        $this->deaths = $deaths;
164 1
        $this->disablesDone = $disablesDone;
165 1
        $this->disablesReceived = $disablesReceived;
166 1
        $this->emote = $emote;
167 1
        $this->energyGained = $energyGained;
168 1
        $this->energyUsed = $energyUsed;
169 1
        $this->healingDone = $healingDone;
170 1
        $this->healingReceived = $healingReceived;
171 1
        $this->kills = $kills;
172 1
        $this->mount = $mount;
173 1
        $this->outfit = $outfit;
174 1
        $this->score = $score;
175 1
        $this->side = $side;
176 1
        $this->timeAlive = $timeAlive;
177 1
        $this->userID = $userID;
178 1
    }
179
180 1
    public static function createFromArray(array $participant): self
181
    {
182 1
        Assert::string($participant['type']);
183 1
        Assert::string($participant['id']);
184 1
        Assert::string($participant['attributes']['actor']);
185 1
        Assert::string($participant['attributes']['shardId']);
186 1
        Assert::integer($participant['attributes']['stats']['abilityUses']);
187 1
        Assert::integer($participant['attributes']['stats']['attachment']);
188 1
        Assert::integer($participant['attributes']['stats']['damageDone']);
189 1
        Assert::integer($participant['attributes']['stats']['damageReceived']);
190 1
        Assert::integer($participant['attributes']['stats']['deaths']);
191 1
        Assert::integer($participant['attributes']['stats']['disablesDone']);
192 1
        Assert::integer($participant['attributes']['stats']['disablesReceived']);
193 1
        Assert::integer($participant['attributes']['stats']['emote']);
194 1
        Assert::integer($participant['attributes']['stats']['energyGained']);
195 1
        Assert::integer($participant['attributes']['stats']['energyUsed']);
196 1
        Assert::integer($participant['attributes']['stats']['healingDone']);
197 1
        Assert::integer($participant['attributes']['stats']['healingReceived']);
198 1
        Assert::integer($participant['attributes']['stats']['kills']);
199 1
        Assert::integer($participant['attributes']['stats']['mount']);
200 1
        Assert::integer($participant['attributes']['stats']['outfit']);
201 1
        Assert::integer($participant['attributes']['stats']['score']);
202 1
        Assert::integer($participant['attributes']['stats']['side']);
203 1
        Assert::integer($participant['attributes']['stats']['timeAlive']);
204 1
        Assert::string($participant['attributes']['stats']['userID']);
205
206 1
        return new self(
207 1
            $participant['type'],
208 1
            $participant['id'],
209 1
            $participant['attributes']['actor'],
210 1
            $participant['attributes']['shardId'],
211 1
            $participant['attributes']['stats']['abilityUses'],
212 1
            $participant['attributes']['stats']['attachment'],
213 1
            $participant['attributes']['stats']['damageDone'],
214 1
            $participant['attributes']['stats']['damageReceived'],
215 1
            $participant['attributes']['stats']['deaths'],
216 1
            $participant['attributes']['stats']['disablesDone'],
217 1
            $participant['attributes']['stats']['disablesReceived'],
218 1
            $participant['attributes']['stats']['emote'],
219 1
            $participant['attributes']['stats']['energyGained'],
220 1
            $participant['attributes']['stats']['energyUsed'],
221 1
            $participant['attributes']['stats']['healingDone'],
222 1
            $participant['attributes']['stats']['healingReceived'],
223 1
            $participant['attributes']['stats']['kills'],
224 1
            $participant['attributes']['stats']['mount'],
225 1
            $participant['attributes']['stats']['outfit'],
226 1
            $participant['attributes']['stats']['score'],
227 1
            $participant['attributes']['stats']['side'],
228 1
            $participant['attributes']['stats']['timeAlive'],
229 1
            $participant['attributes']['stats']['userID']
230
        );
231
    }
232
}
233