Test Failed
Push — dev ( 2a033c...9ed769 )
by Nico
21:17 queued 07:42
created

User::setSmsSended()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\ORM\Mapping\Column;
10
use Doctrine\ORM\Mapping\Entity;
11
use Doctrine\ORM\Mapping\GeneratedValue;
12
use Doctrine\ORM\Mapping\Id;
13
use Doctrine\ORM\Mapping\Index;
14
use Doctrine\ORM\Mapping\JoinColumn;
15
use Doctrine\ORM\Mapping\ManyToOne;
16
use Doctrine\ORM\Mapping\OneToMany;
17
use Doctrine\ORM\Mapping\OneToOne;
18
use Doctrine\ORM\Mapping\OrderBy;
19
use Doctrine\ORM\Mapping\Table;
20
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use Stu\Component\Game\GameEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Game\GameEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use Stu\Component\Game\ModuleEnum;
23
use Stu\Component\Map\MapEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Map\MapEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use Stu\Component\Player\UserAwardEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Player\UserAwardEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use Stu\Component\Player\UserCssClassEnum;
26
use Stu\Component\Player\UserRpgBehaviorEnum;
27
use Stu\Module\PlayerSetting\Lib\UserEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Module\PlayerSetting\Lib\UserEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use Stu\Module\PlayerSetting\Lib\UserSettingEnum;
29
use Stu\Orm\Repository\UserRepository;
30
31
#[Table(name: 'stu_user')]
32
#[Index(name: 'user_alliance_idx', columns: ['allys_id'])]
33
#[Entity(repositoryClass: UserRepository::class)]
34
class User implements UserInterface
35
{
36
    #[Id]
37
    #[Column(type: 'integer')]
38
    #[GeneratedValue(strategy: 'IDENTITY')]
39
    private int $id;
40
41
    #[Column(type: 'string')]
42
    private string $username = '';
43
44
    #[Column(type: 'string', length: 20)]
45
    private string $login = '';
46
47
    #[Column(type: 'string', length: 255)]
48
    private string $pass = '';
49
50
    #[Column(type: 'string', length: 6, nullable: true)]
51
    private ?string $sms_code = null;
52
53
    #[Column(type: 'string', length: 200)]
54
    private string $email = '';
55
56
    #[Column(type: 'string', length: 255, nullable: true)]
57
    private ?string $mobile = null;
58
59
    #[Column(type: 'integer', nullable: true)]
60
    private ?int $allys_id = null;
61
62
    #[Column(type: 'integer')]
63
    private int $race = 9;
64
65
    #[Column(type: 'smallint')]
66
    private int $state = UserEnum::USER_STATE_NEW;
67
68
    #[Column(type: 'integer')]
69
    private int $lastaction = 0;
70
71
    #[Column(type: 'integer')]
72
    private int $creation = 0;
73
74
    #[Column(type: 'integer')]
75
    private int $kn_lez = 0;
76
77
    #[Column(type: 'smallint')]
78
    private int $delmark = 0;
79
80
    #[Column(type: 'boolean')]
81
    private bool $vac_active = false;
82
83
    #[Column(type: 'integer')]
84
    private int $vac_request_date = 0;
85
86
    #[Column(type: 'text')]
87
    private string $description = '';
88
89
    #[Column(type: 'smallint')]
90
    private int $tick = 1;
91
92
    #[Column(type: 'smallint', nullable: true)]
93
    private ?int $maptype = MapEnum::MAPTYPE_INSERT;
0 ignored issues
show
introduced by
The private property $maptype is not used, and could be removed.
Loading history...
94
95
    #[Column(type: 'text')]
96
    private string $sessiondata = '';
97
98
    #[Column(type: 'string', length: 255)]
99
    private string $password_token = '';
100
101
    #[Column(type: 'integer')]
102
    private int $prestige = 0;
103
104
    #[Column(type: 'boolean')]
105
    private bool $deals = false;
106
107
    #[Column(type: 'integer', nullable: true)]
108
    private ?int $last_boarding = null;
109
110
    #[Column(type: 'integer', nullable: true, options: ['default' => 1])]
111
    private ?int $sms_sended = 1;
112
113
    #[ManyToOne(targetEntity: 'Alliance', inversedBy: 'members')]
114
    #[JoinColumn(name: 'allys_id', referencedColumnName: 'id')]
115
    private ?AllianceInterface $alliance = null;
116
117
    #[ManyToOne(targetEntity: 'Faction')]
118
    #[JoinColumn(name: 'race', referencedColumnName: 'id')]
119
    private FactionInterface $faction;
120
121
    /**
122
     * @var ArrayCollection<int, BuoyInterface>
123
     */
124
    #[OneToMany(targetEntity: 'Buoy', mappedBy: 'user')]
125
    private Collection $buoys;
126
127
    /**
128
     * @var ArrayCollection<int, UserAwardInterface>
129
     */
130
    #[OneToMany(targetEntity: 'UserAward', mappedBy: 'user', indexBy: 'award_id')]
131
    #[OrderBy(['award_id' => 'ASC'])]
132
    private Collection $awards;
133
134
    /**
135
     * @var ArrayCollection<int, ColonyInterface>
136
     */
137
    #[OneToMany(targetEntity: 'Colony', mappedBy: 'user', indexBy: 'id')]
138
    #[OrderBy(['colonies_classes_id' => 'ASC', 'id' => 'ASC'])]
139
    private Collection $colonies;
140
141
    /**
142
     * @var ArrayCollection<int, UserLayerInterface>
143
     */
144
    #[OneToMany(targetEntity: 'UserLayer', mappedBy: 'user', indexBy: 'layer_id')]
145
    private Collection $userLayers;
146
147
    #[OneToOne(targetEntity: 'UserLock', mappedBy: 'user')]
148
    private ?UserLockInterface $userLock = null;
149
150
    /**
151
     * @var ArrayCollection<string, UserSettingInterface>
152
     */
153
    #[OneToMany(targetEntity: 'UserSetting', mappedBy: 'user', indexBy: 'setting')]
154
    private Collection $settings;
155
156
    /**
157
     * @var ArrayCollection<int, UserCharacterInterface>
158
     */
159
    #[OneToMany(targetEntity: 'UserCharacter', mappedBy: 'user')]
160
    private Collection $characters;
161
162
    /**
163
     * @var ArrayCollection<int, ColonyScanInterface>
164
     */
165
    #[OneToMany(targetEntity: 'ColonyScan', mappedBy: 'user', indexBy: 'id', fetch: 'EXTRA_LAZY')]
166
    #[OrderBy(['colony_id' => 'ASC', 'date' => 'ASC'])]
167
    private Collection $colonyScans;
168
169
    #[OneToOne(targetEntity: 'PirateWrath', mappedBy: 'user')]
170
    private ?PirateWrathInterface $pirateWrath = null;
171
172
    /**
173
     * @var ArrayCollection<int, UserTutorialInterface>
174
     */
175
    #[OneToMany(targetEntity: 'UserTutorial', mappedBy: 'user', indexBy: 'tutorial_step_id', fetch: 'EXTRA_LAZY')]
176
    private Collection $tutorials;
177
178
    /** @var null|array<mixed> */
179
    private $sessiondataUnserialized;
180
181
    /**
182
     * @var ArrayCollection<int, WormholeRestriction>
183
     */
184
    #[OneToMany(targetEntity: 'WormholeRestriction', mappedBy: 'user')]
185
    private Collection $wormholeRestrictions;
186
187
    #[OneToOne(targetEntity: 'UserReferer', mappedBy: 'user')]
188
    private ?UserRefererInterface $referer = null;
189
190
191
    public function __construct()
192
    {
193
        $this->awards = new ArrayCollection();
194
        $this->colonies = new ArrayCollection();
195
        $this->userLayers = new ArrayCollection();
196
        $this->settings = new ArrayCollection();
197
        $this->characters = new ArrayCollection();
198
        $this->buoys = new ArrayCollection();
199
        $this->colonyScans = new ArrayCollection();
200
        $this->tutorials = new ArrayCollection();
201 201
        $this->wormholeRestrictions = new ArrayCollection();
202
    }
203
204 201
    #[Override]
205
    public function getId(): int
206
    {
207 201
        return $this->id;
208
    }
209
210
    #[Override]
211 201
    public function getName(): string
212
    {
213
        //if UMODE active, add info to user name
214 201
        if ($this->isVacationRequestOldEnough()) {
215
            return $this->username . '[b][color=red] (UMODE)[/color][/b]';
216
        }
217
        return $this->username;
218
    }
219
220
    #[Override]
221
    public function setUsername(string $username): UserInterface
222
    {
223
        $this->username = $username;
224
        return $this;
225
    }
226
227
    #[Override]
228
    public function getLogin(): string
229
    {
230
        return $this->login;
231
    }
232
233
    #[Override]
234
    public function setLogin(string $login): UserInterface
235
    {
236
        $this->login = $login;
237
        return $this;
238
    }
239
240
    #[Override]
241
    public function getPassword(): string
242
    {
243
        return $this->pass;
244
    }
245
246
    #[Override]
247
    public function setPassword(string $password): UserInterface
248
    {
249
        $this->pass = $password;
250
        return $this;
251
    }
252
253
    #[Override]
254
    public function getSmsCode(): ?string
255
    {
256
        return $this->sms_code;
257
    }
258
259
    #[Override]
260
    public function setSmsCode(?string $code): UserInterface
261
    {
262
        $this->sms_code = $code;
263 1
        return $this;
264
    }
265
266 1
    #[Override]
267
    public function getEmail(): string
268
    {
269
        return $this->email;
270
    }
271
272
    #[Override]
273
    public function setEmail(string $email): UserInterface
274
    {
275
        $this->email = $email;
276
        return $this;
277
    }
278
279
    #[Override]
280
    public function getMobile(): ?string
281
    {
282
        return $this->mobile;
283
    }
284
285
    #[Override]
286
    public function setMobile(?string $mobile): UserInterface
287
    {
288
        $this->mobile = $mobile;
289 1
        return $this;
290
    }
291
292 1
    #[Override]
293 1
    public function getRgbCode(): string
294
    {
295
        $setting = $this->getSettings()->get(UserSettingEnum::RGB_CODE->value);
296
        if ($setting !== null) {
297 1
            return $setting->getValue();
298
        }
299
300 201
        return '';
301
    }
302
303 201
    #[Override]
304 201
    public function getCss(): string
305
    {
306
        $setting = $this->getSettings()->get(UserSettingEnum::CSS_COLOR_SHEET->value);
307
        if ($setting !== null) {
308 201
            return $setting->getValue();
309
        }
310
311 201
        return UserCssClassEnum::BLACK->value;
312
    }
313
314 201
    #[Override]
315
    public function getFactionId(): int
316
    {
317
        return $this->race;
318
    }
319
320
    #[Override]
321
    public function setFaction(FactionInterface $faction): UserInterface
322
    {
323
        $this->faction = $faction;
324 11
        return $this;
325
    }
326
327 11
    #[Override]
328
    public function getFaction(): FactionInterface
329
    {
330 1
        return $this->faction;
331
    }
332
333 1
    #[Override]
334
    public function getAwards(): Collection
335
    {
336 12
        return $this->awards;
337
    }
338
339 12
    #[Override]
340
    public function getColonies(): Collection
341
    {
342 2
        return $this->colonies;
343
    }
344
345
    #[Override]
346 2
    public function hasColony(): bool
347 2
    {
348
        if (
349
            $this->getState() === UserEnum::USER_STATE_COLONIZATION_SHIP
350
            || $this->getState() === UserEnum::USER_STATE_UNCOLONIZED
351
        ) {
352 2
            return false;
353
        }
354
355 6
        return !$this->getColonies()->isEmpty();
356
    }
357
358 6
    #[Override]
359
    public function getState(): int
360
    {
361 1
        return $this->state;
362
    }
363
364 1
    #[Override]
365
    public function isLocked(): bool
366
    {
367 1
        return $this->getUserLock() !== null && $this->getUserLock()->getRemainingTicks() > 0;
368
    }
369
370 1
    #[Override]
371
    public function getUserStateDescription(): string
372
    {
373 1
        if ($this->isLocked()) {
374
            return _('GESPERRT');
375
        }
376
        return UserEnum::getUserStateDescription($this->getState());
377
    }
378
379
    #[Override]
380
    public function setState(int $state): UserInterface
381
    {
382
        $this->state = $state;
383 201
        return $this;
384
    }
385
386 201
    #[Override]
387 201
    public function getAvatar(): string
388
    {
389
        $setting = $this->getSettings()->get(UserSettingEnum::AVATAR->value);
390
        if ($setting !== null) {
391 201
            return $setting->getValue();
392
        }
393
394 1
        return '';
395
    }
396
397 1
    #[Override]
398 1
    public function isEmailNotification(): bool
399
    {
400
        $setting = $this->getSettings()->get(UserSettingEnum::EMAIL_NOTIFICATION->value);
401
        if ($setting !== null) {
402 1
            return (bool)$setting->getValue();
403
        }
404
405 4
        return false;
406
    }
407
408 4
    #[Override]
409
    public function getLastaction(): int
410
    {
411
        return $this->lastaction;
412
    }
413
414
    #[Override]
415
    public function setLastaction(int $lastaction): UserInterface
416
    {
417
        $this->lastaction = $lastaction;
418 1
        return $this;
419
    }
420
421 1
    #[Override]
422
    public function getCreationDate(): int
423
    {
424
        return $this->creation;
425
    }
426
427
    #[Override]
428
    public function setCreationDate(int $creationDate): UserInterface
429
    {
430
        $this->creation = $creationDate;
431 4
        return $this;
432
    }
433
434 4
    #[Override]
435
    public function getKnMark(): int
436
    {
437
        return $this->kn_lez;
438
    }
439
440
    #[Override]
441
    public function setKnMark(int $knMark): UserInterface
442
    {
443
        $this->kn_lez = $knMark;
444
        return $this;
445
    }
446
447
    #[Override]
448
    public function getDeletionMark(): int
449
    {
450
        return $this->delmark;
451
    }
452
453
    #[Override]
454
    public function setDeletionMark(int $deletionMark): UserInterface
455
    {
456
        $this->delmark = $deletionMark;
457 201
        return $this;
458
    }
459
460 201
    #[Override]
461
    public function isVacationMode(): bool
462
    {
463
        return $this->vac_active;
464
    }
465
466
    #[Override]
467
    public function setVacationMode(bool $vacationMode): UserInterface
468
    {
469
        $this->vac_active = $vacationMode;
470
        return $this;
471
    }
472
473
    #[Override]
474
    public function getVacationRequestDate(): int
475
    {
476
        return $this->vac_request_date;
477
    }
478
479
    #[Override]
480
    public function setVacationRequestDate(int $date): UserInterface
481
    {
482
        $this->vac_request_date = $date;
483
484 201
        return $this;
485
    }
486
487 201
    #[Override]
488
    public function isVacationRequestOldEnough(): bool
489
    {
490 1
        return $this->isVacationMode() && (time() - $this->getVacationRequestDate() > UserEnum::VACATION_DELAY_IN_SECONDS);
491
    }
492
493 1
    #[Override]
494 1
    public function isStorageNotification(): bool
495
    {
496
        $setting = $this->getSettings()->get(UserSettingEnum::STORAGE_NOTIFICATION->value);
497
        if ($setting !== null) {
498 1
            return (bool)$setting->getValue();
499
        }
500
501 2
        return false;
502
    }
503
504 2
    #[Override]
505
    public function getDescription(): string
506
    {
507
        return $this->description;
508
    }
509
510
    #[Override]
511
    public function setDescription(string $description): UserInterface
512
    {
513
        $this->description = $description;
514 5
        return $this;
515
    }
516
517 5
    #[Override]
518 5
    public function isShowOnlineState(): bool
519
    {
520
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_ONLINE_STATUS->value);
521
        if ($setting !== null) {
522 5
            return (bool)$setting->getValue();
523
        }
524
525 2
        return false;
526
    }
527
528 2
    #[Override]
529 2
    public function isShowPmReadReceipt(): bool
530 1
    {
531
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_PM_READ_RECEIPT->value);
532
        if ($setting !== null) {
533 2
            return (bool)$setting->getValue();
534
        }
535
536 1
        return false;
537
    }
538
539 1
    #[Override]
540 1
    public function isSaveLogin(): bool
541
    {
542
        $setting = $this->getSettings()->get(UserSettingEnum::SAVE_LOGIN->value);
543
        if ($setting !== null) {
544 1
            return (bool)$setting->getValue();
545
        }
546
547 1
        return false;
548
    }
549
550 1
    #[Override]
551 1
    public function getFleetFixedDefault(): bool
552
    {
553
        $setting = $this->getSettings()->get(UserSettingEnum::FLEET_FIXED_DEFAULT->value);
554
        if ($setting !== null) {
555 1
            return (bool)$setting->getValue();
556
        }
557
558 1
        return false;
559
    }
560
561 1
    #[Override]
562 1
    public function getWarpsplitAutoCarryoverDefault(): bool
563
    {
564
        $setting = $this->getSettings()->get(UserSettingEnum::WARPSPLIT_AUTO_CARRYOVER_DEFAULT->value);
565
        if ($setting !== null) {
566 1
            return (bool)$setting->getValue();
567
        }
568
569
        return false;
570
    }
571
572
    #[Override]
573
    public function getTick(): int
574
    {
575
        return $this->tick;
576
    }
577
578
    #[Override]
579
    public function setTick(int $tick): UserInterface
580
    {
581
        $this->tick = $tick;
582 5
        return $this;
583
    }
584
585 5
    #[Override]
586
    public function getUserLayers(): Collection
587
    {
588 4
        return $this->userLayers;
589
    }
590
591 4
    #[Override]
592
    public function hasSeen(int $layerId): bool
593
    {
594 4
        return $this->getUserLayers()->containsKey($layerId);
595
    }
596
597 4
    #[Override]
598
    public function hasExplored(int $layerId): bool
599
    {
600 201
        return $this->hasSeen($layerId) && $this->getUserLayers()->get($layerId)->isExplored();
601
    }
602
603 201
    #[Override]
604
    public function getSettings(): Collection
605
    {
606 1
        return $this->settings;
607
    }
608
609 1
    #[Override]
610
    public function getSessiondata(): string
611
    {
612
        return $this->sessiondata;
613
    }
614
615
    #[Override]
616
    public function setSessiondata(string $sessiondata): UserInterface
617
    {
618
        $this->sessiondata = $sessiondata;
619
        $this->sessiondataUnserialized = null;
620 1
        return $this;
621
    }
622
623 1
    #[Override]
624
    public function getPasswordToken(): string
625
    {
626
        return $this->password_token;
627
    }
628
629
    #[Override]
630
    public function setPasswordToken(string $password_token): UserInterface
631
    {
632
        $this->password_token = $password_token;
633 5
        return $this;
634
    }
635
636 5
    #[Override]
637
    public function getPrestige(): int
638
    {
639
        return $this->prestige;
640
    }
641
642
    #[Override]
643
    public function setPrestige(int $prestige): UserInterface
644
    {
645
        $this->prestige = $prestige;
646 2
        return $this;
647
    }
648
649 2
    #[Override]
650 2
    public function getDefaultView(): ModuleEnum
651
    {
652
        $setting = $this->getSettings()->get(UserSettingEnum::DEFAULT_VIEW->value);
653
        if ($setting !== null) {
654 2
            return ModuleEnum::from($setting->getValue());
655
        }
656
657 5
        return ModuleEnum::MAINDESK;
658
    }
659
660 5
    #[Override]
661 5
    public function getRpgBehavior(): UserRpgBehaviorEnum
662
    {
663
        $setting = $this->getSettings()->get(UserSettingEnum::RPG_BEHAVIOR->value);
664
        if ($setting !== null) {
665 5
            return UserRpgBehaviorEnum::from((int)$setting->getValue());
666
        }
667
668 3
        return UserRpgBehaviorEnum::NOT_SET;
669
    }
670
671 3
    #[Override]
672
    public function getDeals(): bool
673
    {
674 1
        return $this->deals;
675
    }
676
677 1
    #[Override]
678 1
    public function setDeals(bool $deals): UserInterface
679
    {
680
        $this->deals = $deals;
681
        return $this;
682
    }
683
684
    #[Override]
685
    public function getLastBoarding(): ?int
686
    {
687
        return $this->last_boarding;
688
    }
689
690
    #[Override]
691
    public function setLastBoarding(int $lastBoarding): UserInterface
692
    {
693
        $this->last_boarding = $lastBoarding;
694 2
        return $this;
695
    }
696
697 2
    #[Override]
698
    public function isOnline(): bool
699
    {
700 20
        return !($this->getLastAction() < time() - GameEnum::USER_ONLINE_PERIOD);
701
    }
702
703 20
    #[Override]
704
    public function getAlliance(): ?AllianceInterface
705
    {
706
        return $this->alliance;
707
    }
708
709
    #[Override]
710
    public function setAlliance(?AllianceInterface $alliance): UserInterface
711
    {
712
        $this->alliance = $alliance;
713
        return $this;
714
    }
715
716
    #[Override]
717
    public function setAllianceId(?int $allianceId): UserInterface
718
    {
719
        $this->allys_id = $allianceId;
720 3
        return $this;
721
    }
722
723 3
    #[Override]
724 1
    public function getSessionDataUnserialized(): array
725 1
    {
726 1
        if ($this->sessiondataUnserialized === null) {
727
            $this->sessiondataUnserialized = unserialize($this->getSessionData());
728
            if (!is_array($this->sessiondataUnserialized)) {
729 3
                $this->sessiondataUnserialized = [];
730
            }
731
        }
732 1
        return $this->sessiondataUnserialized;
733
    }
734
735 1
    #[Override]
736
    public function isContactable(): bool
737
    {
738 200
        return $this->getId() != UserEnum::USER_NOONE;
739
    }
740
741 200
    #[Override]
742
    public function hasAward(int $awardId): bool
743
    {
744 4
        return $this->awards->containsKey($awardId) === true;
745
    }
746
747 4
    #[Override]
748
    public function hasStationsPmCategory(): bool
749
    {
750
        if ($this->isNpc()) {
751 4
            return true;
752
        }
753
754 205
        return $this->hasAward(UserAwardEnum::RESEARCHED_STATIONS);
755
    }
756 205
757
    public static function isUserNpc(int $userId): bool
758
    {
759 201
        return $userId < UserEnum::USER_FIRST_ID;
760
    }
761
762 201
    #[Override]
763
    public function isNpc(): bool
764
    {
765 1
        return self::isUserNpc($this->getId());
766
    }
767
768 1
    #[Override]
769
    public function getUserLock(): ?UserLockInterface
770
    {
771
        return $this->userLock;
772
    }
773
774
    #[Override]
775
    public function __toString(): string
776
    {
777
        return sprintf('userName: %s', $this->getName());
778
    }
779
780
    #[Override]
781
    public function hasTranslation(): bool
782
    {
783
        $text = $this->getDescription();
784 4
        return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false;
785
    }
786
787 4
    #[Override]
788 4
    public function isShowPirateHistoryEntrys(): bool
789
    {
790
        $setting = $this->getSettings()->get(UserSettingEnum::SHOW_PIRATE_HISTORY_ENTRYS->value);
791
        if ($setting !== null) {
792 4
            return (bool)$setting->getValue();
793
        }
794
795 3
        return false;
796
    }
797
798 3
    #[Override]
799 3
    public function isInboxMessengerStyle(): bool
800 1
    {
801
        $setting = $this->getSettings()->get(UserSettingEnum::INBOX_MESSENGER_STYLE->value);
802
        if ($setting !== null) {
803 2
            return (bool)$setting->getValue();
804
        }
805
806 1
        return false;
807
    }
808
809 1
    #[Override]
810
    public function getCharacters(): Collection
811
    {
812 1
        return $this->characters;
813
    }
814
815 1
    #[Override]
816
    public function getColonyScans(): Collection
817
    {
818
        return $this->colonyScans;
819
    }
820
821
    /**
822
     * @return Collection<int, BuoyInterface>
823
     */
824
    public function getBuoys(): Collection
825
    {
826 2
        return $this->buoys;
827
    }
828
829 2
    #[Override]
830
    public function getPirateWrath(): ?PirateWrathInterface
831
    {
832
        return $this->pirateWrath;
833
    }
834
835
    #[Override]
836
    public function setPirateWrath(?PirateWrathInterface $wrath): UserInterface
837
    {
838
        $this->pirateWrath = $wrath;
839
840
        return $this;
841
    }
842
843
    #[Override]
844
    public function isProtectedAgainstPirates(): bool
845
    {
846
        $pirateWrath = $this->pirateWrath;
847
        if ($pirateWrath === null) {
848
            return false;
849
        }
850
851
        $timeout = $pirateWrath->getProtectionTimeout();
852
        if ($timeout === null) {
853
            return false;
854
        }
855
856
        return $timeout > time();
857
    }
858
859
    /**
860
     * @return Collection<int, UserTutorialInterface>
861
     */
862
    #[Override]
863
    public function getTutorials(): Collection
864
    {
865
        return $this->tutorials;
866
    }
867
868
    #[Override]
869
    /**
870
     * @return Collection<int, WormholeRestriction>
871
     */
872
    public function getWormholeRestrictions(): iterable
873
    {
874
        return $this->wormholeRestrictions;
875
    }
876
877
    #[Override]
878
    public function getReferer(): ?UserRefererInterface
879
    {
880
        return $this->referer;
881
    }
882
883
    #[Override]
884
    public function setReferer(?UserRefererInterface $referer): UserInterface
885
    {
886
        $this->referer = $referer;
887
        return $this;
888
    }
889
890
    #[Override]
891
    public function getSmsSended(): int
892
    {
893
        return $this->sms_sended ?? 1;
894
    }
895
896
    #[Override]
897
    public function setSmsSended(int $smsSended): UserInterface
898
    {
899
        $this->sms_sended = $smsSended;
900
        return $this;
901
    }
902
}
903