Passed
Pull Request — master (#1882)
by Janko
28:33
created

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