|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Component\Spacecraft\System\Data\ComputerSystemData; |
|
10
|
|
|
use Stu\Component\Spacecraft\System\Data\EnergyWeaponSystemData; |
|
11
|
|
|
use Stu\Component\Spacecraft\System\Data\EpsSystemData; |
|
12
|
|
|
use Stu\Component\Spacecraft\System\Data\HullSystemData; |
|
13
|
|
|
use Stu\Component\Spacecraft\System\Data\LssSystemData; |
|
14
|
|
|
use Stu\Component\Spacecraft\System\Data\ProjectileLauncherSystemData; |
|
15
|
|
|
use Stu\Component\Spacecraft\System\Data\ShieldSystemData; |
|
16
|
|
|
use Stu\Component\Spacecraft\System\Data\SubspaceSystemData; |
|
17
|
|
|
use Stu\Component\Spacecraft\System\Data\WarpDriveSystemData; |
|
18
|
|
|
use Stu\Component\Spacecraft\System\Exception\SystemNotFoundException; |
|
19
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
|
20
|
|
|
|
|
21
|
|
|
trait SpacecraftWrapperSystemDataTrait |
|
22
|
|
|
{ |
|
23
|
24 |
|
private function getThis(): SpacecraftWrapper |
|
24
|
|
|
{ |
|
25
|
24 |
|
if (!$this instanceof SpacecraftWrapper) { |
|
26
|
|
|
throw new RuntimeException('trait can only be used on spacecraft wrapper'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
24 |
|
return $this; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
10 |
|
#[Override] |
|
33
|
|
|
public function getHullSystemData(): HullSystemData |
|
34
|
|
|
{ |
|
35
|
10 |
|
$hullSystemData = $this->getThis()->getSpecificShipSystem( |
|
36
|
10 |
|
SpacecraftSystemTypeEnum::HULL, |
|
37
|
10 |
|
HullSystemData::class |
|
38
|
10 |
|
); |
|
39
|
|
|
|
|
40
|
10 |
|
if ($hullSystemData === null) { |
|
41
|
|
|
throw new SystemNotFoundException('no hull installed?'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
10 |
|
return $hullSystemData; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
9 |
|
#[Override] |
|
48
|
|
|
public function getShieldSystemData(): ?ShieldSystemData |
|
49
|
|
|
{ |
|
50
|
9 |
|
return $this->getThis()->getSpecificShipSystem( |
|
51
|
9 |
|
SpacecraftSystemTypeEnum::SHIELDS, |
|
52
|
9 |
|
ShieldSystemData::class |
|
53
|
9 |
|
); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
20 |
|
#[Override] |
|
57
|
|
|
public function getEpsSystemData(): ?EpsSystemData |
|
58
|
|
|
{ |
|
59
|
20 |
|
return $this->getThis()->getSpecificShipSystem( |
|
60
|
20 |
|
SpacecraftSystemTypeEnum::EPS, |
|
61
|
20 |
|
EpsSystemData::class |
|
62
|
20 |
|
); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
6 |
|
#[Override] |
|
66
|
|
|
public function getComputerSystemDataMandatory(): ComputerSystemData |
|
67
|
|
|
{ |
|
68
|
6 |
|
$computer = $this->getThis()->getSpecificShipSystem( |
|
69
|
6 |
|
SpacecraftSystemTypeEnum::COMPUTER, |
|
70
|
6 |
|
ComputerSystemData::class |
|
71
|
6 |
|
); |
|
72
|
6 |
|
if ($computer === null) { |
|
73
|
|
|
throw new SystemNotFoundException('no computer installed?'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
6 |
|
return $computer; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
4 |
|
#[Override] |
|
80
|
|
|
public function getLssSystemData(): ?LssSystemData |
|
81
|
|
|
{ |
|
82
|
4 |
|
return $this->getThis()->getSpecificShipSystem( |
|
83
|
4 |
|
SpacecraftSystemTypeEnum::LSS, |
|
84
|
4 |
|
LssSystemData::class |
|
85
|
4 |
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
2 |
|
#[Override] |
|
89
|
|
|
public function getEnergyWeaponSystemData(): ?EnergyWeaponSystemData |
|
90
|
|
|
{ |
|
91
|
2 |
|
return $this->getThis()->getSpecificShipSystem( |
|
92
|
2 |
|
SpacecraftSystemTypeEnum::PHASER, |
|
93
|
2 |
|
EnergyWeaponSystemData::class |
|
94
|
2 |
|
); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
10 |
|
#[Override] |
|
98
|
|
|
public function getWarpDriveSystemData(): ?WarpDriveSystemData |
|
99
|
|
|
{ |
|
100
|
10 |
|
return $this->getThis()->getSpecificShipSystem( |
|
101
|
10 |
|
SpacecraftSystemTypeEnum::WARPDRIVE, |
|
102
|
10 |
|
WarpDriveSystemData::class |
|
103
|
10 |
|
); |
|
104
|
|
|
} |
|
105
|
2 |
|
#[Override] |
|
106
|
|
|
public function getProjectileLauncherSystemData(): ?ProjectileLauncherSystemData |
|
107
|
|
|
{ |
|
108
|
2 |
|
return $this->getThis()->getSpecificShipSystem( |
|
109
|
2 |
|
SpacecraftSystemTypeEnum::TORPEDO, |
|
110
|
2 |
|
ProjectileLauncherSystemData::class |
|
111
|
2 |
|
); |
|
112
|
|
|
} |
|
113
|
|
|
#[Override] |
|
114
|
|
|
public function getSubspaceSystemData(): ?SubspaceSystemData |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->getThis()->getSpecificShipSystem( |
|
117
|
|
|
SpacecraftSystemTypeEnum::SUBSPACE_SCANNER, |
|
118
|
|
|
SubspaceSystemData::class |
|
119
|
|
|
); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths