Completed
Push — master ( cac559...b1b643 )
by De Cramer
12s
created

Player::getClubLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: olive
5
 * Date: 12/03/2017
6
 * Time: 16:26
7
 */
8
9
namespace eXpansion\Core\Storage\Data;
10
11
/**
12
 * All data related to a player/spectator on the server.
13
 *
14
 * @package eXpansion\Core\Storage\Data
15
 */
16
class Player
17
{
18
    /** @var string */
19
    protected $login;
20
21
    /** @var bool */
22
    protected $isConnected = true;
23
24
    /** @var string */
25
    protected $nickName;
26
27
    /** @var int */
28
    protected $playerId;
29
30
    /** @var int */
31
    protected $teamId;
32
33
    /** @var bool */
34
    protected $isSpectator;
35
36
    /** @var bool */
37
    protected $isInOfficialMode;
38
39
    /** @var int */
40
    protected $ladderRanking;
41
42
    /** @var int */
43
    protected $spectatorStatus;
44
45
    /** @var int */
46
    protected $flags;
47
48
    /** @var int */
49
    protected $forceSpectator;
50
51
    /** @var bool */
52
    protected $isReferee;
53
54
    /** @var bool */
55
    protected $isPodiumReady;
56
57
    /** @var bool */
58
    protected $isUsingStereoscopy;
59
60
    /** @var bool */
61
    protected $isManagedByAnOtherServer;
62
63
    /** @var bool */
64
    protected $isServer;
65
66
    /** @var bool */
67
    protected $hasPlayerSlot;
68
69
    /** @var bool */
70
    protected $isBroadcasting;
71
72
    /** @var bool */
73
    protected $hasJoinedGame = false;
74
75
    /** @var bool */
76
    protected $spectator;
77
78
    /** @var bool */
79
    protected $temporarySpectator;
80
81
    /** @var bool */
82
    protected $pureSpectator;
83
84
    /** @var bool */
85
    protected $autoTarget;
86
87
    /** @var int */
88
    protected $currentTargetId;
89
90
91
    /** @var string */
92
    protected $path;
93
94
    /** @var string */
95
    protected $language;
96
97
    /** @var string */
98
    protected $clientVersion;
99
100
    /** @var string */
101
    protected $clientTitleVersion;
102
103
    /** @var string */
104
    protected $iPAddress;
105
106
    /** @var int */
107
    protected $downloadRate;
108
109
    /** @var int */
110
    protected $uploadRate;
111
112
    /** @var FileDesc */
113
    protected $avatar;
114
115
    /** @var Skin[] */
116
    protected $skins;
117
118
    /** @var mixed[] */
119
    protected $ladderStats;
120
121
    /** @var int */
122
    protected $hoursSinceZoneInscription;
123
124
    /** @var string */
125
    protected $broadcasterLogin;
126
127
    /** @var string[] */
128
    protected $allies = array();
129
130
    /** @var string */
131
    protected $clubLink;
132
    /** @var int */
133
    protected $rank;
134
135
    /** @var int */
136
    protected $bestTime;
137
138
    /** @var int[] */
139
    protected $bestCheckpoints;
140
141
    /** @var int */
142
    protected $score;
143
144
    /** @var int */
145
    protected $nbrLapsFinished;
146
147
    /** @var float */
148
    protected $ladderScore;
149
150
    /**
151
     * @return boolean
152
     */
153 1
    public function isIsConnected()
154
    {
155 1
        return $this->isConnected;
156
    }
157
158
    /**
159
     * @return string
160
     */
161 2
    public function getNickName()
162
    {
163 2
        return $this->nickName;
164
    }
165
166
    /**
167
     * @return int
168
     */
169 1
    public function getPlayerId()
170
    {
171 1
        return $this->playerId;
172
    }
173
174
    /**
175
     * @return int
176
     */
177 1
    public function getTeamId()
178
    {
179 1
        return $this->teamId;
180
    }
181
182
    /**
183
     * @return boolean
184
     */
185 1
    public function isIsSpectator()
186
    {
187 1
        return $this->isSpectator;
188
    }
189
190
    /**
191
     * @return boolean
192
     */
193 1
    public function isIsInOfficialMode()
194
    {
195 1
        return $this->isInOfficialMode;
196
    }
197
198
    /**
199
     * @return int
200
     */
201 1
    public function getLadderRanking()
202
    {
203 1
        return $this->ladderRanking;
204
    }
205
206
    /**
207
     * @return int
208
     */
209 1
    public function getSpectatorStatus()
210
    {
211 1
        return $this->spectatorStatus;
212
    }
213
214
    /**
215
     * @return int
216
     */
217 1
    public function getFlags()
218
    {
219 1
        return $this->flags;
220
    }
221
222
    /**
223
     * @return int
224
     */
225 1
    public function getForceSpectator()
226
    {
227 1
        return $this->forceSpectator;
228
    }
229
230
    /**
231
     * @return boolean
232
     */
233 1
    public function isIsReferee()
234
    {
235 1
        return $this->isReferee;
236
    }
237
238
    /**
239
     * @return boolean
240
     */
241 1
    public function isIsPodiumReady()
242
    {
243 1
        return $this->isPodiumReady;
244
    }
245
246
    /**
247
     * @return boolean
248
     */
249 1
    public function isIsUsingStereoscopy()
250
    {
251 1
        return $this->isUsingStereoscopy;
252
    }
253
254
    /**
255
     * @return boolean
256
     */
257 1
    public function isIsManagedByAnOtherServer()
258
    {
259 1
        return $this->isManagedByAnOtherServer;
260
    }
261
262
    /**
263
     * @return boolean
264
     */
265 2
    public function isIsServer()
266
    {
267 2
        return $this->isServer;
268
    }
269
270
    /**
271
     * @return boolean
272
     */
273 1
    public function isHasPlayerSlot()
274
    {
275 1
        return $this->hasPlayerSlot;
276
    }
277
278
    /**
279
     * @return boolean
280
     */
281 1
    public function isIsBroadcasting()
282
    {
283 1
        return $this->isBroadcasting;
284
    }
285
286
    /**
287
     * @return boolean
288
     */
289 1
    public function isHasJoinedGame()
290
    {
291 1
        return $this->hasJoinedGame;
292
    }
293
294
    /**
295
     * @return boolean
296
     */
297 5
    public function isSpectator()
298
    {
299 5
        return $this->spectator;
300
    }
301
302
    /**
303
     * @return boolean
304
     */
305 1
    public function isTemporarySpectator()
306
    {
307 1
        return $this->temporarySpectator;
308
    }
309
310
    /**
311
     * @return boolean
312
     */
313 1
    public function isPureSpectator()
314
    {
315 1
        return $this->pureSpectator;
316
    }
317
318
    /**
319
     * @return boolean
320
     */
321 1
    public function isAutoTarget()
322
    {
323 1
        return $this->autoTarget;
324
    }
325
326
    /**
327
     * @return int
328
     */
329 1
    public function getCurrentTargetId()
330
    {
331 1
        return $this->currentTargetId;
332
    }
333
334
    /**
335
     * @return string
336
     */
337 1
    public function getPath()
338
    {
339 1
        return $this->path;
340
    }
341
342
    /**
343
     * @return string
344
     */
345 1
    public function getLanguage()
346
    {
347 1
        return $this->language;
348
    }
349
350
    /**
351
     * @return string
352
     */
353 2
    public function getClientVersion()
354
    {
355 2
        return $this->clientVersion;
356
    }
357
358
    /**
359
     * @return string
360
     */
361 1
    public function getClientTitleVersion()
362
    {
363 1
        return $this->clientTitleVersion;
364
    }
365
366
    /**
367
     * @return string
368
     */
369 1
    public function getIPAddress()
370
    {
371 1
        return $this->iPAddress;
372
    }
373
374
    /**
375
     * @return int
376
     */
377 1
    public function getDownloadRate()
378
    {
379 1
        return $this->downloadRate;
380
    }
381
382
    /**
383
     * @return int
384
     */
385 1
    public function getUploadRate()
386
    {
387 1
        return $this->uploadRate;
388
    }
389
390
    /**
391
     * @return FileDesc
392
     */
393 1
    public function getAvatar()
394
    {
395 1
        return $this->avatar;
396
    }
397
398
    /**
399
     * @return Skin[]
400
     */
401 1
    public function getSkins()
402
    {
403 1
        return $this->skins;
404
    }
405
406
    /**
407
     * @return \mixed[]
408
     */
409 1
    public function getLadderStats()
410
    {
411 1
        return $this->ladderStats;
412
    }
413
414
    /**
415
     * @return int
416
     */
417 1
    public function getHoursSinceZoneInscription()
418
    {
419 1
        return $this->hoursSinceZoneInscription;
420
    }
421
422
    /**
423
     * @return string
424
     */
425 1
    public function getBroadcasterLogin()
426
    {
427 1
        return $this->broadcasterLogin;
428
    }
429
430
    /**
431
     * @return string[]
432
     */
433 1
    public function getAllies()
434
    {
435 1
        return $this->allies;
436
    }
437
438
    /**
439
     * @return string
440
     */
441 1
    public function getClubLink()
442
    {
443 1
        return $this->clubLink;
444
    }
445
446
    /**
447
     * @return int
448
     */
449 1
    public function getRank()
450
    {
451 1
        return $this->rank;
452
    }
453
454
    /**
455
     * @return int
456
     */
457 1
    public function getBestTime()
458
    {
459 1
        return $this->bestTime;
460
    }
461
462
    /**
463
     * @return integer[]
464
     */
465 1
    public function getBestCheckpoints()
466
    {
467 1
        return $this->bestCheckpoints;
468
    }
469
470
    /**
471
     * @return int
472
     */
473 1
    public function getScore()
474
    {
475 1
        return $this->score;
476
    }
477
478
    /**
479
     * @return int
480
     */
481 1
    public function getNbrLapsFinished()
482
    {
483 1
        return $this->nbrLapsFinished;
484
    }
485
486
    /**
487
     * @return float
488
     */
489 1
    public function getLadderScore()
490
    {
491 1
        return $this->ladderScore;
492
    }
493
494
    /**
495
     * @return string
496
     */
497 6
    public function getLogin()
498
    {
499 6
        return $this->login;
500
    }
501
502
    /**
503
     * @param \Maniaplanet\DedicatedServer\Structures\Player|array $data
504
     *
505
     * @return $this
506
     */
507 9
    function merge($data)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
508
    {
509 9
        foreach ($data as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $data of type object<Maniaplanet\Dedic...tructures\Player>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
510 9
            $this->$key = $value;
511 9
        }
512
513 9
        return $this;
514
    }
515
}
516