Passed
Push — dev ( 2ba144...6e3434 )
by Janko
17:42
created

SpacecraftRump::setModuleLevel()   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\JoinColumn;
14
use Doctrine\ORM\Mapping\ManyToOne;
15
use Doctrine\ORM\Mapping\OneToMany;
16
use Doctrine\ORM\Mapping\OneToOne;
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
#[Entity(repositoryClass: SpacecraftRumpRepository::class)]
25
class SpacecraftRump implements SpacecraftRumpInterface
26
{
27
    #[Id]
28
    #[Column(type: 'integer')]
29
    #[GeneratedValue(strategy: 'IDENTITY')]
30
    private int $id;
31
32
    #[OneToOne(targetEntity: 'SpacecraftRumpBaseValues', mappedBy: 'rump', fetch: 'EXTRA_LAZY', cascade: ['all'])]
33
    private SpacecraftRumpBaseValuesInterface $baseValues;
34
35
    #[column(type: 'integer', enumType: SpacecraftRumpCategoryEnum::class, nullable: false)]
36
    private SpacecraftRumpCategoryEnum $category_id;
37
38
    #[column(type: 'integer', enumType: SpacecraftRumpRoleEnum::class, nullable: true)]
39
    private ?SpacecraftRumpRoleEnum $role_id = null;
40
41
    #[column(type: 'smallint')]
42
    private int $phaser_volleys = 0;
43
44
    #[column(type: 'smallint')]
45
    private int $phaser_hull_damage_factor = 0;
46
47
    #[column(type: 'smallint')]
48
    private int $phaser_shield_damage_factor = 0;
49
50
    #[column(type: 'smallint')]
51
    private int $torpedo_level = 0;
52
53
    #[column(type: 'smallint')]
54
    private int $torpedo_volleys = 0;
55
56
    #[column(type: 'smallint')]
57
    private int $base_torpedo_storage = 0;
58
59
    #[Column(type: 'string')]
60
    private string $name = '';
61
62
    #[Column(type: 'boolean')]
63
    private bool $is_buildable;
64
65
    #[Column(type: 'boolean')]
66
    private bool $is_npc;
67
68
    #[column(type: 'smallint')]
69
    private int $eps_cost = 0;
70
71
    #[column(type: 'integer')]
72
    private int $storage = 0;
73
74
    #[column(type: 'smallint')]
75
    private int $slots = 0;
76
77
    #[column(type: 'integer')]
78
    private int $buildtime = 0;
79
80
    #[column(type: 'smallint', nullable: true)]
81
    private ?int $needed_workbees = null;
82
83
    #[column(type: 'smallint')]
84
    private int $sort = 0;
85
86
    #[column(type: 'integer', nullable: true)]
87
    private ?int $database_id = 0;
88
89
    #[column(type: 'integer', nullable: true)]
90
    private ?int $commodity_id = 0;
91
92
    #[column(type: 'smallint')]
93
    private int $flight_ecost = 0;
94
95
    #[column(type: 'smallint')]
96
    private int $beam_factor = 0;
97
98
    #[column(type: 'smallint')]
99
    private int $shuttle_slots = 0;
100
101
    #[column(type: 'integer')]
102
    private int $tractor_mass = 1;
103
104
    #[column(type: 'integer')]
105
    private int $tractor_payload = 100;
106
107
    #[Column(type: 'integer')]
108
    private int $prestige;
109
110
    #[Column(type: 'boolean', nullable: true)]
111
    private ?bool $npc_buildable = true;
112
113
    #[ManyToOne(targetEntity: 'ShipRumpRole')]
114
    #[JoinColumn(name: 'role_id', referencedColumnName: 'id')]
115
    private ?ShipRumpRoleInterface $shipRumpRole = null;
116
117
    /**
118
     * @var ArrayCollection<int, ShipRumpSpecialInterface>
119
     */
120
    #[OneToMany(targetEntity: 'ShipRumpSpecial', mappedBy: 'spacecraftRump', indexBy: 'special')]
121
    private Collection $specialAbilities;
122
123
    #[ManyToOne(targetEntity: 'ShipRumpCategory')]
124
    #[JoinColumn(name: 'category_id', referencedColumnName: 'id')]
125
    private ShipRumpCategoryInterface $shipRumpCategory;
126
127
    #[ManyToOne(targetEntity: 'Commodity')]
128
    #[JoinColumn(name: 'commodity_id', referencedColumnName: 'id')]
129
    private ?CommodityInterface $commodity = null;
130
131
    #[ManyToOne(targetEntity: 'DatabaseEntry')]
132
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
133
    private ?DatabaseEntryInterface $databaseEntry = null;
134
135
    /**
136
     * @var ArrayCollection<int, ShipRumpCostInterface>
137
     */
138
    #[OneToMany(targetEntity: 'ShipRumpCost', mappedBy: 'spacecraftRump')]
139
    private Collection $buildingCosts;
140
141
    /**
142
     * @var ArrayCollection<int, BuildplanHangarInterface>
143
     */
144
    #[OneToMany(targetEntity: 'BuildplanHangar', mappedBy: 'spacecraftRump')]
145
    private Collection $startHangar;
146
147
    public function __construct()
148
    {
149
        $this->buildingCosts = new ArrayCollection();
150
        $this->startHangar = new ArrayCollection();
151
        $this->specialAbilities = new ArrayCollection();
152
    }
153
154 39
    #[Override]
155
    public function getId(): int
156
    {
157 39
        return $this->id;
158
    }
159
160 12
    #[Override]
161
    public function getBaseValues(): SpacecraftRumpBaseValuesInterface
162
    {
163 12
        return $this->baseValues;
164
    }
165
166 17
    #[Override]
167
    public function getCategoryId(): SpacecraftRumpCategoryEnum
168
    {
169 17
        return $this->category_id;
170
    }
171
172 19
    #[Override]
173
    public function getRoleId(): ?SpacecraftRumpRoleEnum
174
    {
175 19
        return $this->role_id;
176
    }
177
178 17
    #[Override]
179
    public function getBeamFactor(): int
180
    {
181 17
        return $this->beam_factor;
182
    }
183
184 2
    #[Override]
185
    public function getShuttleSlots(): int
186
    {
187 2
        return $this->shuttle_slots;
188
    }
189
190 2
    #[Override]
191
    public function getTractorMass(): int
192
    {
193 2
        return $this->tractor_mass;
194
    }
195
196 2
    #[Override]
197
    public function getTractorPayload(): int
198
    {
199 2
        return $this->tractor_payload;
200
    }
201
202 6
    #[Override]
203
    public function getPhaserVolleys(): int
204
    {
205 6
        return $this->phaser_volleys;
206
    }
207
208
    #[Override]
209
    public function getPhaserHullDamageFactor(): int
210
    {
211
        return $this->phaser_hull_damage_factor;
212
    }
213
214
    #[Override]
215
    public function getPhaserShieldDamageFactor(): int
216
    {
217
        return $this->phaser_shield_damage_factor;
218
    }
219
220 6
    #[Override]
221
    public function getTorpedoLevel(): int
222
    {
223 6
        return $this->torpedo_level;
224
    }
225
226 6
    #[Override]
227
    public function getTorpedoVolleys(): int
228
    {
229 6
        return $this->torpedo_volleys;
230
    }
231
232 8
    #[Override]
233
    public function getBaseTorpedoStorage(): int
234
    {
235 8
        return $this->base_torpedo_storage;
236
    }
237
238 26
    #[Override]
239
    public function getName(): string
240
    {
241 26
        return $this->name;
242
    }
243
244
    #[Override]
245
    public function setName(string $name): SpacecraftRumpInterface
246
    {
247
        $this->name = $name;
248
        return $this;
249
    }
250
251
    #[Override]
252
    public function getIsBuildable(): bool
253
    {
254
        return $this->is_buildable;
255
    }
256
257
    #[Override]
258
    public function setIsBuildable(bool $isBuildable): SpacecraftRumpInterface
259
    {
260
        $this->is_buildable = $isBuildable;
261
        return $this;
262
    }
263
264 1
    #[Override]
265
    public function getIsNpc(): bool
266
    {
267 1
        return $this->is_npc;
268
    }
269
270
    #[Override]
271
    public function setIsNpc(bool $isNpc): SpacecraftRumpInterface
272
    {
273
        $this->is_npc = $isNpc;
274
        return $this;
275
    }
276
277 4
    #[Override]
278
    public function getEpsCost(): int
279
    {
280 4
        return $this->eps_cost;
281
    }
282
283
    #[Override]
284
    public function setEpsCost(int $energyCosts): SpacecraftRumpInterface
285
    {
286
        $this->eps_cost = $energyCosts;
287
        return $this;
288
    }
289
290 19
    #[Override]
291
    public function getStorage(): int
292
    {
293 19
        return $this->storage;
294
    }
295
296
    #[Override]
297
    public function setStorage(int $storage): SpacecraftRumpInterface
298
    {
299
        $this->storage = $storage;
300
        return $this;
301
    }
302
303 2
    #[Override]
304
    public function getDockingSlots(): int
305
    {
306 2
        return $this->slots;
307
    }
308
309
    #[Override]
310
    public function setDockingSlots(int $slots): SpacecraftRumpInterface
311
    {
312
        $this->slots = $slots;
313
        return $this;
314
    }
315
316 4
    #[Override]
317
    public function getBuildtime(): int
318
    {
319 4
        return $this->buildtime;
320
    }
321
322
    #[Override]
323
    public function setBuildtime(int $buildtime): SpacecraftRumpInterface
324
    {
325
        $this->buildtime = $buildtime;
326
        return $this;
327
    }
328
329
    #[Override]
330
    public function getSort(): int
331
    {
332
        return $this->sort;
333
    }
334
335
    #[Override]
336
    public function setSort(int $sort): SpacecraftRumpInterface
337
    {
338
        $this->sort = $sort;
339
        return $this;
340
    }
341
342
    #[Override]
343
    public function getDatabaseId(): ?int
344
    {
345
        return $this->database_id;
346
    }
347
348
    #[Override]
349
    public function getCommodityId(): ?int
350
    {
351
        return $this->commodity_id;
352
    }
353
354
    #[Override]
355
    public function setCommodityId(?int $commodityId): SpacecraftRumpInterface
356
    {
357
        $this->commodity_id = $commodityId;
358
        return $this;
359
    }
360
361 8
    #[Override]
362
    public function getFlightEcost(): int
363
    {
364 8
        return $this->flight_ecost;
365
    }
366
367 5
    #[Override]
368
    public function getShipRumpRole(): ?ShipRumpRoleInterface
369
    {
370 5
        return $this->shipRumpRole;
371
    }
372
373 4
    #[Override]
374
    public function getShipRumpCategory(): ShipRumpCategoryInterface
375
    {
376 4
        return $this->shipRumpCategory;
377
    }
378
379
    #[Override]
380
    public function getCommodity(): ?CommodityInterface
381
    {
382
        return $this->commodity;
383
    }
384
385
    #[Override]
386
    public function setCommodity(?CommodityInterface $commodity): SpacecraftRumpInterface
387
    {
388
        $this->commodity = $commodity;
389
        return $this;
390
    }
391
392
    #[Override]
393
    public function getNeededWorkbees(): ?int
394
    {
395
        return $this->needed_workbees;
396
    }
397
398
    #[Override]
399
    public function getNeededRepairWorkbees(): ?int
400
    {
401
        return  $this->getNeededWorkbees() / 5;
402
    }
403
404
    #[Override]
405
    public function getDatabaseEntry(): ?DatabaseEntryInterface
406
    {
407
        return $this->databaseEntry;
408
    }
409
410
    #[Override]
411
    public function setDatabaseEntry(?DatabaseEntryInterface $databaseEntry): SpacecraftRumpInterface
412
    {
413
        $this->databaseEntry = $databaseEntry;
414
        return $this;
415
    }
416
417
    #[Override]
418
    public function getPrestige(): int
419
    {
420
        return $this->prestige;
421
    }
422
423
    #[Override]
424
    public function isEscapePods(): bool
425
    {
426
        return $this->getCategoryId() === SpacecraftRumpCategoryEnum::SHIP_CATEGORY_ESCAPE_PODS;
427
    }
428
429 1
    #[Override]
430
    public function isShipyard(): bool
431
    {
432 1
        return $this->getCategoryId() === SpacecraftRumpCategoryEnum::SHIP_CATEGORY_STATION
433 1
            && $this->getRoleId() === SpacecraftRumpRoleEnum::SHIP_ROLE_SHIPYARD;
434
    }
435
436 1
    #[Override]
437
    public function isStation(): bool
438
    {
439 1
        return $this->getCategoryId() === SpacecraftRumpCategoryEnum::SHIP_CATEGORY_STATION;
440
    }
441
442
    #[Override]
443
    public function isWorkbee(): bool
444
    {
445
        $commodity = $this->getCommodity();
446
447
        return $commodity !== null && $commodity->isWorkbee();
448
    }
449
450
    #[Override]
451
    public function getStartHangar(): Collection
452
    {
453
        return $this->startHangar;
454
    }
455
456 4
    #[Override]
457
    public function getBuildingCosts(): Collection
458
    {
459 4
        return $this->buildingCosts;
460
    }
461
462
    #[Override]
463
    public function hasSpecialAbility(int $value): bool
464
    {
465
        return $this->specialAbilities->containsKey($value);
466
    }
467
468 1
    #[Override]
469
    public function getFactionId(): int
470
    {
471
        //last digit of id shows faction id
472 1
        return $this->getId() % 10;
473
    }
474
475
    /**
476
     * @return Collection<int, ShipRumpSpecialInterface>
477
     */
478
    #[Override]
479
    public function getSpecialAbilities(): Collection
480
    {
481
        return $this->specialAbilities;
482
    }
483
484
    #[Override]
485
    public function getNpcBuildable(): ?bool
486
    {
487
        return $this->npc_buildable;
488
    }
489
490
    #[Override]
491
    public function setNpcBuildable(?bool $npcBuildable): SpacecraftRumpInterface
492
    {
493
        $this->npc_buildable = $npcBuildable;
494
        return $this;
495
    }
496
}
497