Test Failed
Push — dev ( f6482b...4c1dc5 )
by Janko
15:40
created

Colony::getUserDepositMinings()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 12
ccs 4
cts 6
cp 0.6667
crap 3.3332
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Colony::setUser() 0 5 1
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\Colony\ColonyMenuEnum;
22
use Stu\Component\Game\ModuleEnum;
23
use Stu\Component\Game\TimeConstants;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Game\TimeConstants 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\Lib\Colony\PlanetFieldHostTypeEnum;
25
use Stu\Lib\Transfer\CommodityTransfer;
26
use Stu\Lib\Transfer\TransferEntityTypeEnum;
27
use Stu\Module\Colony\View\ShowColony\ShowColony;
28
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...
29
use Stu\Orm\Repository\ColonyRepository;
30
31
#[Table(name: 'stu_colonies')]
32
#[Index(name: 'colony_user_idx', columns: ['user_id'])]
33
#[Index(name: 'colony_classes_idx', columns: ['colonies_classes_id'])]
34
#[Index(name: 'colony_sys_map_idx', columns: ['starsystem_map_id'])]
35
#[Entity(repositoryClass: ColonyRepository::class)]
36
class Colony implements ColonyInterface
37
{
38
    #[Id]
39
    #[Column(type: 'integer')]
40
    #[GeneratedValue(strategy: 'IDENTITY')]
41
    private int $id;
42
43
    #[Column(type: 'integer')]
44
    private int $colonies_classes_id = 0;
45
46
    #[Column(type: 'integer')]
47
    private int $user_id = 0;
48
49
    #[Column(type: 'integer')]
50
    private int $starsystem_map_id = 0;
0 ignored issues
show
introduced by
The private property $starsystem_map_id is not used, and could be removed.
Loading history...
51
52
    #[Column(type: 'string')]
53
    private string $name = '';
54
55
    #[Column(type: 'string', length: 100)]
56
    private string $planet_name = '';
57
58
    #[Column(type: 'integer', length: 5)]
59
    private int $bev_work = 0;
60
61
    #[Column(type: 'integer', length: 5)]
62
    private int $bev_free = 0;
63
64
    #[Column(type: 'integer', length: 5)]
65
    private int $bev_max = 0;
66
67
    #[Column(type: 'integer', length: 5)]
68
    private int $eps = 0;
69
70
    #[Column(type: 'integer', length: 5)]
71
    private int $max_eps = 0;
72
73
    #[Column(type: 'integer', length: 5)]
74
    private int $max_storage = 0;
75
76
    #[Column(type: 'text', nullable: true)]
77
    private ?string $mask = null;
78
79
    #[Column(type: 'integer', nullable: true)]
80
    private ?int $database_id = null;
81
82
    #[Column(type: 'integer', length: 5)]
83
    private int $populationlimit = 0;
84
85
    #[Column(type: 'boolean')]
86
    private bool $immigrationstate = true;
87
88
    #[Column(type: 'integer', length: 6, nullable: true)]
89
    private ?int $shields = 0;
90
91
    #[Column(type: 'integer', length: 6, nullable: true)]
92
    private ?int $shield_frequency = 0;
93
94
    #[Column(type: 'integer', length: 3, nullable: true)]
95
    private ?int $torpedo_type = null;
0 ignored issues
show
introduced by
The private property $torpedo_type is not used, and could be removed.
Loading history...
96
97
    #[Column(type: 'integer', length: 3)]
98
    private int $rotation_factor = 1;
99
100
    #[Column(type: 'integer', length: 2)]
101
    private int $surface_width = 0;
102
103
    #[ManyToOne(targetEntity: 'ColonyClass')]
104
    #[JoinColumn(name: 'colonies_classes_id', referencedColumnName: 'id')]
105
    private ColonyClassInterface $colonyClass;
106
107
    #[OneToOne(targetEntity: 'StarSystemMap', inversedBy: 'colony')]
108
    #[JoinColumn(name: 'starsystem_map_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
109
    private StarSystemMapInterface $starsystem_map;
110
111
    #[ManyToOne(targetEntity: 'User')]
112
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id')]
113
    private UserInterface $user;
114
115
    /**
116
     * @var ArrayCollection<int, PlanetFieldInterface>
117
     */
118
    #[OneToMany(targetEntity: 'PlanetField', mappedBy: 'colony', indexBy: 'field_id', fetch: 'EXTRA_LAZY')]
119
    #[OrderBy(['field_id' => 'ASC'])]
120
    private Collection $planetFields;
121
122
    /**
123
     * @var ArrayCollection<int, StorageInterface>
124
     */
125
    #[OneToMany(targetEntity: 'Storage', mappedBy: 'colony', indexBy: 'commodity_id')]
126
    #[OrderBy(['commodity_id' => 'ASC'])]
127
    private Collection $storage;
128
129
    #[ManyToOne(targetEntity: 'TorpedoType')]
130
    #[JoinColumn(name: 'torpedo_type', referencedColumnName: 'id')]
131
    private ?TorpedoTypeInterface $torpedo = null;
132
133
    #[OneToOne(targetEntity: 'DatabaseEntry')]
134
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
135
    private ?DatabaseEntryInterface $databaseEntry;
136
137
    /**
138
     * @var ArrayCollection<int, FleetInterface>
139
     */
140
    #[OneToMany(targetEntity: 'Fleet', mappedBy: 'defendedColony')]
141
    private Collection $defenders;
142
143
    /**
144
     * @var ArrayCollection<int, FleetInterface>
145
     */
146
    #[OneToMany(targetEntity: 'Fleet', mappedBy: 'blockedColony')]
147
    private Collection $blockers;
148
149
    /**
150
     * @var ArrayCollection<int, CrewAssignmentInterface>
151
     */
152
    #[OneToMany(targetEntity: 'CrewAssignment', mappedBy: 'colony')]
153
    private Collection $crewAssignments;
154
155
    /**
156
     * @var ArrayCollection<int, CrewAssignmentInterface>
157
     */
158
    #[OneToMany(targetEntity: 'CrewTraining', mappedBy: 'colony')]
159
    private Collection $crewTrainings;
160
161
    /** @var array<int, int> */
162
    private array $twilightZones = [];
163
164
    public function __construct()
165
    {
166
        $this->planetFields = new ArrayCollection();
167
        $this->storage = new ArrayCollection();
168
        $this->defenders = new ArrayCollection();
169
        $this->blockers = new ArrayCollection();
170
        $this->crewAssignments = new ArrayCollection();
171
        $this->crewTrainings = new ArrayCollection();
172
    }
173
174
    #[Override]
175
    public function getId(): int
176
    {
177
        return $this->id;
178
    }
179
180
    #[Override]
181
    public function getColonyClassId(): int
182 45
    {
183
        return $this->colonies_classes_id;
184
    }
185 45
186
    #[Override]
187
    public function getUserId(): int
188 9
    {
189
        return $this->user_id;
190
    }
191 9
192
    #[Override]
193
    public function getSx(): int
194 39
    {
195
        return $this->getStarsystemMap()->getSx();
196
    }
197 39
198
    #[Override]
199
    public function getSy(): int
200 10
    {
201
        return $this->getStarsystemMap()->getSy();
202
    }
203 10
204
    #[Override]
205
    public function getSystemsId(): int
206 10
    {
207
        return $this->getSystem()->getId();
208
    }
209 10
210
    #[Override]
211
    public function getName(): string
212
    {
213
        return $this->name;
214
    }
215
216
    #[Override]
217
    public function getNameAndSectorString(): string
218 19
    {
219
        return sprintf(
220
            '%s %s',
221 19
            $this->getName(),
222
            $this->getSectorString()
223
        );
224 2
    }
225
226
    #[Override]
227 2
    public function getSystemString(): string
228 2
    {
229 2
        return sprintf('%s-System (%s|%s)', $this->getSystem()->getName(), $this->getSystem()->getCx(), $this->getSystem()->getCy());
230 2
    }
231 2
232
    #[Override]
233
    public function setName(string $name): ColonyInterface
234 4
    {
235
        $this->name = $name;
236
        return $this;
237 4
    }
238
239
    #[Override]
240
    public function getPlanetName(): string
241
    {
242
        return $this->planet_name;
243
    }
244
245
    #[Override]
246
    public function setPlanetName(string $planet_name): ColonyInterface
247 4
    {
248
        $this->planet_name = $planet_name;
249
        return $this;
250 4
    }
251
252
    #[Override]
253
    public function getWorkers(): int
254
    {
255
        return $this->bev_work;
256
    }
257
258
    #[Override]
259
    public function setWorkers(int $bev_work): ColonyInterface
260 10
    {
261
        $this->bev_work = $bev_work;
262
        return $this;
263 10
    }
264
265
    #[Override]
266
    public function getWorkless(): int
267
    {
268
        return $this->bev_free;
269
    }
270
271
    #[Override]
272
    public function setWorkless(int $bev_free): ColonyInterface
273 10
    {
274
        $this->bev_free = $bev_free;
275
        return $this;
276 10
    }
277
278
    #[Override]
279
    public function getMaxBev(): int
280
    {
281
        return $this->bev_max;
282
    }
283
284
    #[Override]
285
    public function setMaxBev(int $bev_max): ColonyInterface
286 5
    {
287
        $this->bev_max = $bev_max;
288
        return $this;
289 5
    }
290
291
    #[Override]
292
    public function getEps(): int
293
    {
294
        return $this->eps;
295
    }
296
297
    #[Override]
298
    public function setEps(int $eps): ColonyInterface
299 11
    {
300
        $this->eps = $eps;
301
        return $this;
302 11
    }
303
304
    #[Override]
305
    public function getMaxEps(): int
306
    {
307
        return $this->max_eps;
308
    }
309
310
    #[Override]
311
    public function setMaxEps(int $max_eps): ColonyInterface
312 9
    {
313
        $this->max_eps = $max_eps;
314
        return $this;
315 9
    }
316
317
    #[Override]
318
    public function getMaxStorage(): int
319
    {
320
        return $this->max_storage;
321
    }
322
323
    #[Override]
324
    public function setMaxStorage(int $max_storage): ColonyInterface
325 13
    {
326
        $this->max_storage = $max_storage;
327
        return $this;
328 13
    }
329
330
    #[Override]
331
    public function getMask(): ?string
332
    {
333
        return $this->mask;
334
    }
335
336
    #[Override]
337
    public function setMask(?string $mask): ColonyInterface
338
    {
339
        $this->mask = $mask;
340
        return $this;
341
    }
342
343
    #[Override]
344
    public function getDatabaseId(): ?int
345
    {
346
        return $this->database_id;
347
    }
348
349
    #[Override]
350
    public function setDatabaseEntry(?DatabaseEntryInterface $entry): ColonyInterface
351
    {
352
        $this->databaseEntry = $entry;
353
        return $this;
354
    }
355
356
    #[Override]
357
    public function getPopulationlimit(): int
358
    {
359
        return $this->populationlimit;
360
    }
361
362
    #[Override]
363
    public function setPopulationlimit(int $populationlimit): ColonyInterface
364 6
    {
365
        $this->populationlimit = $populationlimit;
366
        return $this;
367 6
    }
368
369
    #[Override]
370
    public function getImmigrationstate(): bool
371
    {
372
        return $this->immigrationstate;
373
    }
374
375
    #[Override]
376
    public function setImmigrationstate(bool $immigrationstate): ColonyInterface
377 6
    {
378
        $this->immigrationstate = $immigrationstate;
379
        return $this;
380 6
    }
381
382
    #[Override]
383
    public function getShields(): ?int
384
    {
385
        return $this->shields;
386
    }
387
388
    #[Override]
389
    public function setShields(?int $shields): ColonyInterface
390
    {
391
        $this->shields = $shields;
392
        return $this;
393
    }
394
395
    #[Override]
396
    public function getTwilightZone(int $timestamp): int
397
    {
398
        if (array_key_exists($timestamp, $this->twilightZones)) {
399
            return $this->twilightZones[$timestamp];
400
        }
401
402
        $twilightZone = 0;
403 6
404
        $width = $this->getSurfaceWidth();
405
        $rotationTime = $this->getRotationTime();
406 6
        $colonyTimeSeconds = $this->getColonyTimeSeconds($timestamp);
407 6
408
        if ($this->getDayTimePrefix($timestamp) == 1) {
409
            $scaled = floor((((100 / ($rotationTime * 0.125)) * ($colonyTimeSeconds - $rotationTime * 0.25)) / 100) * $width);
410 1
            if ($scaled == 0) {
411
                $twilightZone = - (($width) - 1);
412 1
            } elseif ((int) - (($width) - ceil($scaled)) == 0) {
413 1
                $twilightZone = -1;
414 1
            } else {
415
                $twilightZone = (int) - (($width) - $scaled);
416 1
            }
417
        }
418
        if ($this->getDayTimePrefix($timestamp) == 2) {
419
            $twilightZone = $width;
420
        }
421
        if ($this->getDayTimePrefix($timestamp) == 3) {
422
            $scaled = floor((((100 / ($rotationTime * 0.125)) * ($colonyTimeSeconds - $rotationTime * 0.75)) / 100) * $width);
423
            $twilightZone = (int) ($width - $scaled);
424
        }
425
        if ($this->getDayTimePrefix($timestamp) == 4) {
426 1
            $twilightZone = 0;
427 1
        }
428
429 1
        $this->twilightZones[$timestamp] = $twilightZone;
430
431
        return $twilightZone;
432
    }
433 1
434
    #[Override]
435
    public function getShieldFrequency(): ?int
436
    {
437 1
        return $this->shield_frequency;
438
    }
439 1
440
    #[Override]
441
    public function setShieldFrequency(?int $shieldFrequency): ColonyInterface
442
    {
443
        $this->shield_frequency = $shieldFrequency;
444
        return $this;
445
    }
446
447
    #[Override]
448
    public function getTorpedo(): ?TorpedoTypeInterface
449
    {
450
        return $this->torpedo;
451
    }
452
453
    #[Override]
454
    public function setTorpedo(?TorpedoTypeInterface $torpedoType): ColonyInterface
455
    {
456
        $this->torpedo = $torpedoType;
457
        return $this;
458
    }
459
460
    #[Override]
461
    public function getRotationFactor(): int
462
    {
463
        return $this->rotation_factor;
464
    }
465
466
    #[Override]
467
    public function setRotationFactor(int $rotationFactor): ColonyInterface
468 4
    {
469
        $this->rotation_factor = $rotationFactor;
470
471 4
        return $this;
472
    }
473
474
    #[Override]
475
    public function getRotationTime(): int
476
    {
477
        return (int) (TimeConstants::ONE_DAY_IN_SECONDS * $this->getRotationFactor() / 100);
478
    }
479
480
    public function getColonyTimeSeconds(int $timestamp): int
481
    {
482 4
        return $timestamp % $this->getRotationTime();
483
    }
484
485 4
    #[Override]
486
    public function getColonyTimeHour(int $timestamp): ?string
487
    {
488 4
        $rotationTime = $this->getRotationTime();
489
490 4
        return sprintf("%02d", (int) floor(($rotationTime / 3600) * ($this->getColonyTimeSeconds($timestamp) / $rotationTime)));
491
    }
492
493 4
    #[Override]
494
    public function getColonyTimeMinute(int $timestamp): ?string
495
    {
496 4
        $rotationTime = $this->getRotationTime();
497
498 4
        return sprintf("%02d", (int) floor(60 * (($rotationTime / 3600) * ($this->getColonyTimeSeconds($timestamp) / $rotationTime) - ((int) $this->getColonyTimeHour($timestamp)))));
499
    }
500
501 4
    #[Override]
502
    public function getDayTimePrefix(int $timestamp): ?int
503
    {
504 4
        $daytimeprefix = null;
505
        $daypercent = (int) (($this->getColonyTimeSeconds($timestamp) / $this->getRotationTime()) * 100);
506 4
        if ($daypercent > 25 && $daypercent <= 37.5) {
507
            $daytimeprefix = 1; //Sonnenaufgang
508
        }
509 4
        if ($daypercent > 37.5 && $daypercent <= 75) {
510
            $daytimeprefix = 2; //Tag
511
        }
512 4
        if ($daypercent > 75 && $daypercent <= 87.5) {
513 4
            $daytimeprefix = 3; //Sonnenuntergang
514 4
        }
515
        if ($daypercent > 87.5 || $daypercent <= 25) {
516
            $daytimeprefix = 4; //Nacht
517 4
        }
518 4
        return $daytimeprefix;
519
    }
520 4
521
    #[Override]
522
    public function getDayTimeName(int $timestamp): ?string
523 4
    {
524
        $daytimename = null;
525
        if ($this->getDayTimePrefix($timestamp) == 1) {
526 4
            $daytimename = 'Morgen';
527
        }
528
529 4
        if ($this->getDayTimePrefix($timestamp) == 2) {
530
            $daytimename = 'Tag';
531
        }
532 4
533 4
        if ($this->getDayTimePrefix($timestamp) == 3) {
534
            $daytimename = 'Abend';
535
        }
536
537 4
        if ($this->getDayTimePrefix($timestamp) == 4) {
538 4
            $daytimename = 'Nacht';
539
        }
540
        return $daytimename;
541 4
    }
542
543
    #[Override]
544
    public function getSurfaceWidth(): int
545 4
    {
546
        return $this->surface_width;
547
    }
548 4
549
    #[Override]
550
    public function setSurfaceWidth(int $surfaceWidth): ColonyInterface
551 6
    {
552
        $this->surface_width = $surfaceWidth;
553
        return $this;
554 6
    }
555
556
    #[Override]
557
    public function getColonyClass(): ColonyClassInterface
558
    {
559
        return $this->colonyClass;
560
    }
561
562
    #[Override]
563
    public function setColonyClass(ColonyClassInterface $colonyClass): ColonyInterface
564 22
    {
565
        $this->colonyClass = $colonyClass;
566
        return $this;
567 22
    }
568
569
    #[Override]
570
    public function getStorageSum(): int
571
    {
572
        return array_reduce(
573
            $this->getStorage()->getValues(),
574
            fn(int $sum, StorageInterface $storage): int => $sum + $storage->getAmount(),
575
            0
576
        );
577 13
    }
578
579
    #[Override]
580 13
    public function storagePlaceLeft(): bool
581 13
    {
582 13
        return $this->getMaxStorage() > $this->getStorageSum();
583 13
    }
584 13
585
    #[Override]
586
    public function getStarsystemMap(): StarSystemMapInterface
587
    {
588
        return $this->starsystem_map;
589
    }
590
591
    #[Override]
592
    public function getLocation(): MapInterface|StarSystemMapInterface
593 19
    {
594
        return $this->getStarsystemMap();
595
    }
596 19
597
    #[Override]
598
    public function setStarsystemMap(StarSystemMapInterface $systemMap): ColonyInterface
599 10
    {
600
        $this->starsystem_map = $systemMap;
601
602 10
        return $this;
603
    }
604
605
    #[Override]
606
    public function getSystem(): StarSystemInterface
607
    {
608
        return $this->getStarsystemMap()->getSystem();
609
    }
610
611
    #[Override]
612
    public function getBeamFactor(): int
613 10
    {
614
        return 10;
615
    }
616 10
617
    #[Override]
618
    public function getPlanetFields(): Collection
619 2
    {
620
        return $this->planetFields;
621
    }
622 2
623
    #[Override]
624
    public function getBeamableStorage(): Collection
625 5
    {
626
        return CommodityTransfer::excludeNonBeamable($this->storage);
627
    }
628 5
629
    #[Override]
630
    public function getStorage(): Collection
631 2
    {
632
        return $this->storage;
633
    }
634 2
635
    #[Override]
636
    public function isDefended(): bool
637 20
    {
638
        return !$this->getDefenders()->isEmpty();
639
    }
640 20
641
    #[Override]
642
    public function getDefenders(): Collection
643 1
    {
644
        return $this->defenders;
645
    }
646 1
647
    #[Override]
648
    public function isBlocked(): bool
649 1
    {
650
        return !$this->getBlockers()->isEmpty();
651
    }
652 1
653
    #[Override]
654
    public function getBlockers(): Collection
655 1
    {
656
        return $this->blockers;
657
    }
658 1
659
    #[Override]
660
    public function getCrewAssignments(): Collection
661 1
    {
662
        return $this->crewAssignments;
663
    }
664 1
665
    #[Override]
666
    public function getCrewAssignmentAmount(): int
667
    {
668
        return $this->crewAssignments->count();
669
    }
670
671
    #[Override]
672
    public function getCrewTrainingAmount(): int
673 3
    {
674
        return $this->crewTrainings->count();
675
    }
676 3
677
    #[Override]
678
    public function isFree(): bool
679 1
    {
680
        return $this->getUserId() === UserEnum::USER_NOONE;
681
    }
682 1
683
    #[Override]
684
    public function getUser(): UserInterface
685 5
    {
686
        return $this->user;
687
    }
688 5
689
    #[Override]
690 5
    public function setUser(UserInterface $user): ColonyInterface
691
    {
692
        $this->user = $user;
693
        return $this;
694
    }
695
696 5
    #[Override]
697
    public function getPopulation(): int
698
    {
699 5
        return $this->getWorkers() + $this->getWorkless();
700
    }
701
702 5
    #[Override]
703
    public function getFreeHousing(): int
704
    {
705 15
        return $this->getMaxBev() - $this->getPopulation();
706
    }
707
708 15
    #[Override]
709
    public function lowerEps(int $value): void
710
    {
711
        $this->setEps($this->getEps() - $value);
712
    }
713
714
    #[Override]
715
    public function upperEps(int $value): void
716
    {
717
        $this->setEps($this->getEps() + $value);
718 10
    }
719
720
    #[Override]
721 10
    public function getSectorString(): string
722
    {
723
        return $this->getStarsystemMap()->getSectorString();
724 4
    }
725
726
    #[Override]
727 4
    public function getPlanetFieldHostIdentifier(): string
728
    {
729
        return 'colony';
730
    }
731
732
    #[Override]
733
    public function getPlanetFieldHostColumnIdentifier(): string
734
    {
735
        return 'colonies_id';
736
    }
737
738
    #[Override]
739
    public function isColony(): bool
740
    {
741
        return true;
742 2
    }
743
744
    #[Override]
745 2
    public function getHostType(): PlanetFieldHostTypeEnum
746
    {
747
        return PlanetFieldHostTypeEnum::COLONY;
748 4
    }
749
750
    #[Override]
751 4
    public function getDefaultViewIdentifier(): string
752
    {
753
        return ShowColony::VIEW_IDENTIFIER;
754 12
    }
755
756
    #[Override]
757 12
    public function isMenuAllowed(ColonyMenuEnum $menu): bool
758
    {
759
        return true;
760 15
    }
761
762
    #[Override]
763 15
    public function getTransferEntityType(): TransferEntityTypeEnum
764
    {
765
        return TransferEntityTypeEnum::COLONY;
766
    }
767
768
    #[Override]
769
    public function getHref(): string
770
    {
771
        return sprintf(
772 20
            '%s?%s=1&id=%d',
773
            ModuleEnum::COLONY->getPhpPage(),
774
            ShowColony::VIEW_IDENTIFIER,
775 20
            $this->getId()
776
        );
777
    }
778
779
    #[Override]
780
    public function getComponentParameters(): string
781
    {
782
        return sprintf(
783
            '&hosttype=%d&id=%d',
784
            $this->getHostType()->value,
785
            $this->getId()
786
        );
787
    }
788
}
789