Passed
Pull Request — master (#2161)
by Janko
25:16 queued 15:11
created

SpacecraftRump::getCategoryId()   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
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
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\Table;
18
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...
19
use Stu\Component\Spacecraft\SpacecraftRumpCategoryEnum;
20
use Stu\Component\Spacecraft\SpacecraftRumpRoleEnum;
21
use Stu\Orm\Repository\SpacecraftRumpRepository;
22
23
#[Table(name: 'stu_rump')]
24
#[Index(name: 'rump_category_idx', columns: ['category_id'])]
25
#[Index(name: 'rump_role_idx', columns: ['role_id'])]
26
#[Entity(repositoryClass: SpacecraftRumpRepository::class)]
27
class SpacecraftRump implements SpacecraftRumpInterface
28
{
29
    #[Id]
30
    #[Column(type: 'integer')]
31
    #[GeneratedValue(strategy: 'IDENTITY')]
32
    private int $id;
33
34
    #[column(type: 'enum', enumType: SpacecraftRumpCategoryEnum::class, nullable: false)]
35
    private SpacecraftRumpCategoryEnum $category_id;
36
37
    #[column(type: 'enum', enumType: SpacecraftRumpRoleEnum::class, nullable: true)]
38
    private ?SpacecraftRumpRoleEnum $role_id = null;
39
40
    #[column(type: 'smallint')]
41
    private int $evade_chance = 0;
42
43
    #[column(type: 'smallint')]
44
    private int $hit_chance = 0;
45
46
    #[column(type: 'smallint')]
47
    private int $module_level = 0;
48
49
    #[column(type: 'smallint')]
50
    private int $base_crew = 0;
51
52
    #[column(type: 'smallint')]
53
    private int $base_eps = 0;
54
55
    #[column(type: 'smallint')]
56
    private int $base_reactor = 0;
57
58
    #[column(type: 'integer')]
59
    private int $base_hull = 0;
60
61
    #[column(type: 'integer')]
62
    private int $base_shield = 0;
63
64
    #[column(type: 'smallint')]
65
    private int $base_damage = 0;
66
67
    #[column(type: 'smallint')]
68
    private int $base_sensor_range = 0;
69
70
    #[column(type: 'smallint')]
71
    private int $base_torpedo_storage = 0;
72
73
    #[column(type: 'smallint')]
74
    private int $phaser_volleys = 0;
75
76
    #[column(type: 'smallint')]
77
    private int $phaser_hull_damage_factor = 0;
78
79
    #[column(type: 'smallint')]
80
    private int $phaser_shield_damage_factor = 0;
81
82
    #[column(type: 'smallint')]
83
    private int $torpedo_level = 0;
84
85
    #[column(type: 'smallint')]
86
    private int $torpedo_volleys = 0;
87
88
    #[Column(type: 'string')]
89
    private string $name = '';
90
91
    #[Column(type: 'boolean')]
92
    private bool $is_buildable;
93
94
    #[Column(type: 'boolean')]
95
    private bool $is_npc;
96
97
    #[column(type: 'smallint')]
98
    private int $eps_cost = 0;
99
100
    #[column(type: 'integer')]
101
    private int $storage = 0;
102
103
    #[column(type: 'smallint')]
104
    private int $slots = 0;
105
106
    #[column(type: 'integer')]
107
    private int $buildtime = 0;
108
109
    #[column(type: 'smallint', nullable: true)]
110
    private ?int $needed_workbees = null;
111
112
    #[column(type: 'smallint')]
113
    private int $sort = 0;
114
115
    #[column(type: 'integer', nullable: true)]
116
    private ?int $database_id = 0;
117
118
    #[column(type: 'integer', nullable: true)]
119
    private ?int $commodity_id = 0;
120
121
    #[column(type: 'smallint')]
122
    private int $flight_ecost = 0;
123
124
    #[column(type: 'smallint')]
125
    private int $beam_factor = 0;
126
127
    #[column(type: 'smallint')]
128
    private int $special_slots = 0;
129
130
    #[column(type: 'smallint')]
131
    private int $shuttle_slots = 0;
132
133
    #[column(type: 'integer')]
134
    private int $tractor_mass = 1;
135
136
    #[column(type: 'integer')]
137
    private int $tractor_payload = 100;
138
139
    #[Column(type: 'integer')]
140
    private int $prestige;
141
142
    #[Column(type: 'integer')]
143
    private int $base_warpdrive = 0;
144
145
    #[Column(type: 'boolean', nullable: true)]
146
    private ?bool $npc_buildable = true;
147
148
    #[ManyToOne(targetEntity: 'ShipRumpRole')]
149
    #[JoinColumn(name: 'role_id', referencedColumnName: 'id')]
150
    private ?ShipRumpRoleInterface $shipRumpRole = null;
151
152
    /**
153
     * @var ArrayCollection<int, ShipRumpSpecialInterface>
154
     */
155
    #[OneToMany(targetEntity: 'ShipRumpSpecial', mappedBy: 'spacecraftRump', indexBy: 'special')]
156
    private Collection $specialAbilities;
157
158
    #[ManyToOne(targetEntity: 'ShipRumpCategory')]
159
    #[JoinColumn(name: 'category_id', referencedColumnName: 'id')]
160
    private ShipRumpCategoryInterface $shipRumpCategory;
161
162
    #[ManyToOne(targetEntity: 'Commodity')]
163
    #[JoinColumn(name: 'commodity_id', referencedColumnName: 'id')]
164
    private ?CommodityInterface $commodity = null;
165
166
    #[ManyToOne(targetEntity: 'DatabaseEntry')]
167
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
168
    private ?DatabaseEntryInterface $databaseEntry = null;
169
170
    /**
171
     * @var ArrayCollection<int, ShipRumpCostInterface>
172
     */
173
    #[OneToMany(targetEntity: 'ShipRumpCost', mappedBy: 'spacecraftRump')]
174
    private Collection $buildingCosts;
175
176
    /**
177
     * @var ArrayCollection<int, BuildplanHangarInterface>
178
     */
179
    #[OneToMany(targetEntity: 'BuildplanHangar', mappedBy: 'spacecraftRump')]
180
    private Collection $startHangar;
181
182
    public function __construct()
183
    {
184
        $this->buildingCosts = new ArrayCollection();
185
        $this->startHangar = new ArrayCollection();
186
        $this->specialAbilities = new ArrayCollection();
187
    }
188
189 39
    #[Override]
190
    public function getId(): int
191
    {
192 39
        return $this->id;
193
    }
194
195 17
    #[Override]
196
    public function getCategoryId(): SpacecraftRumpCategoryEnum
197
    {
198 17
        return $this->category_id;
199
    }
200
201 19
    #[Override]
202
    public function getRoleId(): ?SpacecraftRumpRoleEnum
203
    {
204 19
        return $this->role_id;
205
    }
206
207
    #[Override]
208
    public function setRoleId(?SpacecraftRumpRoleEnum $roleId): SpacecraftRumpInterface
209
    {
210
        $this->role_id = $roleId;
211
        return $this;
212
    }
213
214 3
    #[Override]
215
    public function getEvadeChance(): int
216
    {
217 3
        return $this->evade_chance;
218
    }
219
220
    #[Override]
221
    public function setEvadeChance(int $evadeChance): SpacecraftRumpInterface
222
    {
223
        $this->evade_chance = $evadeChance;
224
        return $this;
225
    }
226
227 4
    #[Override]
228
    public function getHitChance(): int
229
    {
230 4
        return $this->hit_chance;
231
    }
232
233
    #[Override]
234
    public function setHitChance(int $hitChance): SpacecraftRumpInterface
235
    {
236
        $this->hit_chance = $hitChance;
237
        return $this;
238
    }
239
240 4
    #[Override]
241
    public function getModuleLevel(): int
242
    {
243 4
        return $this->module_level;
244
    }
245
246
    #[Override]
247
    public function setModuleLevel(int $moduleLevel): SpacecraftRumpInterface
248
    {
249
        $this->module_level = $moduleLevel;
250
        return $this;
251
    }
252
253 11
    #[Override]
254
    public function getBaseCrew(): int
255
    {
256 11
        return $this->base_crew;
257
    }
258
259
    #[Override]
260
    public function setBaseCrew(int $baseCrew): SpacecraftRumpInterface
261
    {
262
        $this->base_crew = $baseCrew;
263
        return $this;
264
    }
265
266 4
    #[Override]
267
    public function getBaseEps(): int
268
    {
269 4
        return $this->base_eps;
270
    }
271
272
    #[Override]
273
    public function setBaseEps(int $baseEps): SpacecraftRumpInterface
274
    {
275
        $this->base_eps = $baseEps;
276
        return $this;
277
    }
278
279 4
    #[Override]
280
    public function getBaseReactor(): int
281
    {
282 4
        return $this->base_reactor;
283
    }
284
285
    #[Override]
286
    public function setBaseReactor(int $baseReactor): SpacecraftRumpInterface
287
    {
288
        $this->base_reactor = $baseReactor;
289
        return $this;
290
    }
291
292 4
    #[Override]
293
    public function getBaseHull(): int
294
    {
295 4
        return $this->base_hull;
296
    }
297
298
    #[Override]
299
    public function setBaseHull(int $baseHull): SpacecraftRumpInterface
300
    {
301
        $this->base_hull = $baseHull;
302
        return $this;
303
    }
304
305 4
    #[Override]
306
    public function getBaseShield(): int
307
    {
308 4
        return $this->base_shield;
309
    }
310
311
    #[Override]
312
    public function setBaseShield(int $baseShield): SpacecraftRumpInterface
313
    {
314
        $this->base_shield = $baseShield;
315
        return $this;
316
    }
317
318 4
    #[Override]
319
    public function getBaseDamage(): int
320
    {
321 4
        return $this->base_damage;
322
    }
323
324 5
    #[Override]
325
    public function getBaseSensorRange(): int
326
    {
327 5
        return $this->base_sensor_range;
328
    }
329
330
    #[Override]
331
    public function setBaseSensorRange(int $baseSensorRange): SpacecraftRumpInterface
332
    {
333
        $this->base_sensor_range = $baseSensorRange;
334
        return $this;
335
    }
336
337 8
    #[Override]
338
    public function getBaseTorpedoStorage(): int
339
    {
340 8
        return $this->base_torpedo_storage;
341
    }
342
343
    #[Override]
344
    public function setBaseTorpedoStorage(int $baseTorpedoStorage): SpacecraftRumpInterface
345
    {
346
        $this->base_torpedo_storage = $baseTorpedoStorage;
347
        return $this;
348
    }
349
350 17
    #[Override]
351
    public function getBeamFactor(): int
352
    {
353 17
        return $this->beam_factor;
354
    }
355
356
    #[Override]
357
    public function setBeamFactor(int $beamFactor): SpacecraftRumpInterface
358
    {
359
        $this->beam_factor = $beamFactor;
360
        return $this;
361
    }
362
363 3
    #[Override]
364
    public function getSpecialSlots(): int
365
    {
366 3
        return $this->special_slots;
367
    }
368
369
    #[Override]
370
    public function setSpecialSlots(int $specialSlots): SpacecraftRumpInterface
371
    {
372
        $this->special_slots = $specialSlots;
373
        return $this;
374
    }
375
376 2
    #[Override]
377
    public function getShuttleSlots(): int
378
    {
379 2
        return $this->shuttle_slots;
380
    }
381
382
    #[Override]
383
    public function setShuttleSlots(int $shuttleSlots): SpacecraftRumpInterface
384
    {
385
        $this->shuttle_slots = $shuttleSlots;
386
        return $this;
387
    }
388
389 2
    #[Override]
390
    public function getTractorMass(): int
391
    {
392 2
        return $this->tractor_mass;
393
    }
394
395 2
    #[Override]
396
    public function getTractorPayload(): int
397
    {
398 2
        return $this->tractor_payload;
399
    }
400
401 3
    #[Override]
402
    public function getBaseWarpDrive(): int
403
    {
404 3
        return $this->base_warpdrive;
405
    }
406
407
    #[Override]
408
    public function setBaseWarpDrive(int $baseWarpDrive): SpacecraftRumpInterface
409
    {
410
        $this->base_warpdrive = $baseWarpDrive;
411
        return $this;
412
    }
413
414 6
    #[Override]
415
    public function getPhaserVolleys(): int
416
    {
417 6
        return $this->phaser_volleys;
418
    }
419
420
    #[Override]
421
    public function setPhaserVolleys(int $phaserVolleys): SpacecraftRumpInterface
422
    {
423
        $this->phaser_volleys = $phaserVolleys;
424
        return $this;
425
    }
426
427
    #[Override]
428
    public function getPhaserHullDamageFactor(): int
429
    {
430
        return $this->phaser_hull_damage_factor;
431
    }
432
433
    #[Override]
434
    public function setPhaserHullDamageFactor(int $phaserHullDamageFactor): SpacecraftRumpInterface
435
    {
436
        $this->phaser_hull_damage_factor = $phaserHullDamageFactor;
437
        return $this;
438
    }
439
440
    #[Override]
441
    public function getPhaserShieldDamageFactor(): int
442
    {
443
        return $this->phaser_shield_damage_factor;
444
    }
445
446
    #[Override]
447
    public function setPhaserShieldDamageFactor(int $phaserShieldDamageFactor): SpacecraftRumpInterface
448
    {
449
        $this->phaser_shield_damage_factor = $phaserShieldDamageFactor;
450
        return $this;
451
    }
452
453 6
    #[Override]
454
    public function getTorpedoLevel(): int
455
    {
456 6
        return $this->torpedo_level;
457
    }
458
459
    #[Override]
460
    public function setTorpedoLevel(int $torpedoLevel): SpacecraftRumpInterface
461
    {
462
        $this->torpedo_level = $torpedoLevel;
463
        return $this;
464
    }
465
466 6
    #[Override]
467
    public function getTorpedoVolleys(): int
468
    {
469 6
        return $this->torpedo_volleys;
470
    }
471
472
    #[Override]
473
    public function setTorpedoVolleys(int $torpedoVolleys): SpacecraftRumpInterface
474
    {
475
        $this->torpedo_volleys = $torpedoVolleys;
476
        return $this;
477
    }
478
479 26
    #[Override]
480
    public function getName(): string
481
    {
482 26
        return $this->name;
483
    }
484
485
    #[Override]
486
    public function setName(string $name): SpacecraftRumpInterface
487
    {
488
        $this->name = $name;
489
        return $this;
490
    }
491
492
    #[Override]
493
    public function getIsBuildable(): bool
494
    {
495
        return $this->is_buildable;
496
    }
497
498
    #[Override]
499
    public function setIsBuildable(bool $isBuildable): SpacecraftRumpInterface
500
    {
501
        $this->is_buildable = $isBuildable;
502
        return $this;
503
    }
504
505 1
    #[Override]
506
    public function getIsNpc(): bool
507
    {
508 1
        return $this->is_npc;
509
    }
510
511
    #[Override]
512
    public function setIsNpc(bool $isNpc): SpacecraftRumpInterface
513
    {
514
        $this->is_npc = $isNpc;
515
        return $this;
516
    }
517
518 4
    #[Override]
519
    public function getEpsCost(): int
520
    {
521 4
        return $this->eps_cost;
522
    }
523
524
    #[Override]
525
    public function setEpsCost(int $energyCosts): SpacecraftRumpInterface
526
    {
527
        $this->eps_cost = $energyCosts;
528
        return $this;
529
    }
530
531 19
    #[Override]
532
    public function getStorage(): int
533
    {
534 19
        return $this->storage;
535
    }
536
537
    #[Override]
538
    public function setStorage(int $storage): SpacecraftRumpInterface
539
    {
540
        $this->storage = $storage;
541
        return $this;
542
    }
543
544 2
    #[Override]
545
    public function getDockingSlots(): int
546
    {
547 2
        return $this->slots;
548
    }
549
550
    #[Override]
551
    public function setDockingSlots(int $slots): SpacecraftRumpInterface
552
    {
553
        $this->slots = $slots;
554
        return $this;
555
    }
556
557 4
    #[Override]
558
    public function getBuildtime(): int
559
    {
560 4
        return $this->buildtime;
561
    }
562
563
    #[Override]
564
    public function setBuildtime(int $buildtime): SpacecraftRumpInterface
565
    {
566
        $this->buildtime = $buildtime;
567
        return $this;
568
    }
569
570
    #[Override]
571
    public function getSort(): int
572
    {
573
        return $this->sort;
574
    }
575
576
    #[Override]
577
    public function setSort(int $sort): SpacecraftRumpInterface
578
    {
579
        $this->sort = $sort;
580
        return $this;
581
    }
582
583
    #[Override]
584
    public function getDatabaseId(): ?int
585
    {
586
        return $this->database_id;
587
    }
588
589
    #[Override]
590
    public function getCommodityId(): ?int
591
    {
592
        return $this->commodity_id;
593
    }
594
595
    #[Override]
596
    public function setCommodityId(?int $commodityId): SpacecraftRumpInterface
597
    {
598
        $this->commodity_id = $commodityId;
599
        return $this;
600
    }
601
602 8
    #[Override]
603
    public function getFlightEcost(): int
604
    {
605 8
        return $this->flight_ecost;
606
    }
607
608
    #[Override]
609
    public function setFlightEcost(int $flightEcost): SpacecraftRumpInterface
610
    {
611
        $this->flight_ecost = $flightEcost;
612
        return $this;
613
    }
614
615 5
    #[Override]
616
    public function getShipRumpRole(): ?ShipRumpRoleInterface
617
    {
618 5
        return $this->shipRumpRole;
619
    }
620
621
    #[Override]
622
    public function setShipRumpRole(?ShipRumpRoleInterface $shipRumpRole): SpacecraftRumpInterface
623
    {
624
        $this->shipRumpRole = $shipRumpRole;
625
        return $this;
626
    }
627
628 4
    #[Override]
629
    public function getShipRumpCategory(): ShipRumpCategoryInterface
630
    {
631 4
        return $this->shipRumpCategory;
632
    }
633
634
    #[Override]
635
    public function setShipRumpCategory(ShipRumpCategoryInterface $shipRumpCategory): SpacecraftRumpInterface
636
    {
637
        $this->shipRumpCategory = $shipRumpCategory;
638
        return $this;
639
    }
640
641
    #[Override]
642
    public function getCommodity(): ?CommodityInterface
643
    {
644
        return $this->commodity;
645
    }
646
647
    #[Override]
648
    public function setCommodity(?CommodityInterface $commodity): SpacecraftRumpInterface
649
    {
650
        $this->commodity = $commodity;
651
        return $this;
652
    }
653
654
    #[Override]
655
    public function getNeededWorkbees(): ?int
656
    {
657
        return $this->needed_workbees;
658
    }
659
660
    #[Override]
661
    public function getNeededRepairWorkbees(): ?int
662
    {
663
        return  $this->getNeededWorkbees() / 5;
664
    }
665
666
    #[Override]
667
    public function getDatabaseEntry(): ?DatabaseEntryInterface
668
    {
669
        return $this->databaseEntry;
670
    }
671
672
    #[Override]
673
    public function setDatabaseEntry(?DatabaseEntryInterface $databaseEntry): SpacecraftRumpInterface
674
    {
675
        $this->databaseEntry = $databaseEntry;
676
        return $this;
677
    }
678
679
    #[Override]
680
    public function getPrestige(): int
681
    {
682
        return $this->prestige;
683
    }
684
685
    #[Override]
686
    public function isEscapePods(): bool
687
    {
688
        return $this->getCategoryId() === SpacecraftRumpCategoryEnum::SHIP_CATEGORY_ESCAPE_PODS;
689
    }
690
691 1
    #[Override]
692
    public function isShipyard(): bool
693
    {
694 1
        return $this->getCategoryId() === SpacecraftRumpCategoryEnum::SHIP_CATEGORY_STATION
695 1
            && $this->getRoleId() === SpacecraftRumpRoleEnum::SHIP_ROLE_SHIPYARD;
696
    }
697
698 1
    #[Override]
699
    public function isStation(): bool
700
    {
701 1
        return $this->getCategoryId() === SpacecraftRumpCategoryEnum::SHIP_CATEGORY_STATION;
702
    }
703
704
    #[Override]
705
    public function isWorkbee(): bool
706
    {
707
        $commodity = $this->getCommodity();
708
709
        return $commodity !== null && $commodity->isWorkbee();
710
    }
711
712
    #[Override]
713
    public function getStartHangar(): Collection
714
    {
715
        return $this->startHangar;
716
    }
717
718 4
    #[Override]
719
    public function getBuildingCosts(): Collection
720
    {
721 4
        return $this->buildingCosts;
722
    }
723
724
    #[Override]
725
    public function hasSpecialAbility(int $value): bool
726
    {
727
        return $this->specialAbilities->containsKey($value);
728
    }
729
730 1
    #[Override]
731
    public function getFractionId(): int
732
    {
733
        //last digit of id shows fraction id
734 1
        return $this->getId() % 10;
735
    }
736
737
    /**
738
     * @return Collection<int, ShipRumpSpecialInterface>
739
     */
740
    #[Override]
741
    public function getSpecialAbilities(): Collection
742
    {
743
        return $this->specialAbilities;
744
    }
745
746
    #[Override]
747
    public function getNpcBuildable(): ?bool
748
    {
749
        return $this->npc_buildable;
750
    }
751
752
    #[Override]
753
    public function setNpcBuildable(?bool $npcBuildable): SpacecraftRumpInterface
754
    {
755
        $this->npc_buildable = $npcBuildable;
756
        return $this;
757
    }
758
}
759