Player::getPlayerId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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