1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Colony\Lib; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Component\Building\BuildingFunctionEnum; |
9
|
|
|
use Stu\Orm\Entity\BuildingFunction; |
10
|
|
|
|
11
|
|
|
final class BuildingFunctionWrapper implements BuildingFunctionWrapperInterface |
12
|
|
|
{ |
13
|
|
|
/** @param array<BuildingFunction> $buildingfunctions */ |
14
|
1 |
|
public function __construct(private array $buildingfunctions) {} |
15
|
|
|
|
16
|
1 |
|
#[Override] |
17
|
|
|
public function isTorpedoFab(): bool |
18
|
|
|
{ |
19
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::TORPEDO_FAB); |
20
|
|
|
} |
21
|
|
|
|
22
|
1 |
|
#[Override] |
23
|
|
|
public function isAirfield(): bool |
24
|
|
|
{ |
25
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::AIRFIELD); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
#[Override] |
29
|
|
|
public function isFighterShipyard(): bool |
30
|
|
|
{ |
31
|
|
|
return $this->hasFunction(BuildingFunctionEnum::FIGHTER_SHIPYARD); |
32
|
|
|
} |
33
|
|
|
|
34
|
1 |
|
#[Override] |
35
|
|
|
public function isAcademy(): bool |
36
|
|
|
{ |
37
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::ACADEMY); |
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
#[Override] |
41
|
|
|
public function isFabHall(): bool |
42
|
|
|
{ |
43
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::FABRICATION_HALL); |
44
|
|
|
} |
45
|
|
|
|
46
|
1 |
|
#[Override] |
47
|
|
|
public function isTechCenter(): bool |
48
|
|
|
{ |
49
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::TECH_CENTER); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
#[Override] |
53
|
|
|
public function isShipyard(): bool |
54
|
|
|
{ |
55
|
1 |
|
return array_any( |
56
|
1 |
|
$this->buildingfunctions, |
57
|
1 |
|
fn(BuildingFunction $function): bool => $function->getFunction()->isShipyard() |
58
|
1 |
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
#[Override] |
62
|
|
|
public function getShipyardBuildingFunctionId(): ?int |
63
|
|
|
{ |
64
|
|
|
return array_find( |
65
|
|
|
$this->buildingfunctions, |
66
|
|
|
fn(BuildingFunction $function): bool => $function->getFunction()->isShipyard() |
67
|
|
|
)?->getId(); |
68
|
|
|
} |
69
|
|
|
|
70
|
1 |
|
#[Override] |
71
|
|
|
public function isModuleFab(): bool |
72
|
|
|
{ |
73
|
1 |
|
return array_any( |
74
|
1 |
|
$this->buildingfunctions, |
75
|
1 |
|
fn(BuildingFunction $function): bool => $function->getFunction()->isModuleFab() |
76
|
1 |
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
1 |
|
#[Override] |
80
|
|
|
public function isWarehouse(): bool |
81
|
|
|
{ |
82
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::WAREHOUSE); |
83
|
|
|
} |
84
|
|
|
|
85
|
1 |
|
#[Override] |
86
|
|
|
public function isSubspaceTelescope(): bool |
87
|
|
|
{ |
88
|
1 |
|
return $this->hasFunction(BuildingFunctionEnum::SUBSPACE_TELESCOPE); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
#[Override] |
92
|
|
|
public function getModuleFabBuildingFunctionId(): ?int |
93
|
|
|
{ |
94
|
|
|
return array_find( |
95
|
|
|
$this->buildingfunctions, |
96
|
|
|
fn(BuildingFunction $function): bool => $function->getFunction()->isModuleFab() |
97
|
|
|
)?->getId(); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
#[Override] |
101
|
|
|
public function getFabHallBuildingFunctionId(): ?int |
102
|
|
|
{ |
103
|
|
|
foreach ($this->buildingfunctions as $func) { |
104
|
|
|
if ($func->getFunction() === BuildingFunctionEnum::FABRICATION_HALL) { |
105
|
|
|
return $func->getId(); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
return null; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
#[Override] |
112
|
|
|
public function getTechCenterBuildingFunctionId(): ?int |
113
|
|
|
{ |
114
|
|
|
foreach ($this->buildingfunctions as $func) { |
115
|
|
|
if ($func->getFunction() === BuildingFunctionEnum::TECH_CENTER) { |
116
|
|
|
return $func->getId(); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
return null; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
#[Override] |
123
|
|
|
public function getSubspaceTelescopeBuildingFunctionId(): ?int |
124
|
|
|
{ |
125
|
|
|
foreach ($this->buildingfunctions as $func) { |
126
|
|
|
if ($func->getFunction() === BuildingFunctionEnum::SUBSPACE_TELESCOPE) { |
127
|
|
|
return $func->getId(); |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
return null; |
131
|
|
|
} |
132
|
|
|
|
133
|
1 |
|
private function hasFunction(BuildingFunctionEnum $function): bool |
134
|
|
|
{ |
135
|
1 |
|
return array_key_exists($function->value, $this->buildingfunctions); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
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