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\OneToOne; |
18
|
|
|
use Doctrine\ORM\Mapping\OrderBy; |
19
|
|
|
use Doctrine\ORM\Mapping\Table; |
20
|
|
|
use Override; |
|
|
|
|
21
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
22
|
|
|
use Stu\Orm\Repository\TradePostRepository; |
23
|
|
|
|
24
|
|
|
#[Table(name: 'stu_trade_posts')] |
25
|
|
|
#[Index(name: 'trade_network_idx', columns: ['trade_network'])] |
26
|
|
|
#[Index(name: 'trade_post_station_idx', columns: ['station_id'])] |
27
|
|
|
#[Entity(repositoryClass: TradePostRepository::class)] |
28
|
|
|
class TradePost implements TradePostInterface |
29
|
|
|
{ |
30
|
|
|
#[Id] |
31
|
|
|
#[Column(type: 'integer')] |
32
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
33
|
|
|
private int $id; |
34
|
|
|
|
35
|
|
|
#[Column(type: 'integer')] |
36
|
|
|
private int $user_id = 0; |
37
|
|
|
|
38
|
|
|
#[Column(type: 'string')] |
39
|
|
|
private string $name = ''; |
40
|
|
|
|
41
|
|
|
#[Column(type: 'text')] |
42
|
|
|
private string $description = ''; |
43
|
|
|
|
44
|
|
|
#[Column(type: 'integer')] |
45
|
|
|
private int $station_id = 0; |
46
|
|
|
|
47
|
|
|
#[Column(type: 'smallint')] |
48
|
|
|
private int $trade_network = 0; |
49
|
|
|
|
50
|
|
|
#[Column(type: 'smallint')] |
51
|
|
|
private int $level = 0; |
52
|
|
|
|
53
|
|
|
#[Column(type: 'integer')] |
54
|
|
|
private int $transfer_capacity = 0; |
55
|
|
|
|
56
|
|
|
#[Column(type: 'integer')] |
57
|
|
|
private int $storage = 0; |
58
|
|
|
|
59
|
|
|
#[Column(type: 'boolean', nullable: true)] |
60
|
|
|
private ?bool $is_dock_pm_auto_read = null; |
61
|
|
|
|
62
|
|
|
#[ManyToOne(targetEntity: 'User')] |
63
|
|
|
#[JoinColumn(name: 'user_id', referencedColumnName: 'id')] |
64
|
|
|
private UserInterface $user; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var ArrayCollection<int, TradeLicenseInfoInterface> |
68
|
|
|
*/ |
69
|
|
|
#[OneToMany(targetEntity: 'TradeLicenseInfo', mappedBy: 'tradePost')] |
70
|
|
|
#[OrderBy(['id' => 'DESC'])] |
71
|
|
|
private Collection $licenseInfos; |
72
|
|
|
|
73
|
|
|
#[OneToOne(targetEntity: 'Station', inversedBy: 'tradePost')] |
74
|
|
|
#[JoinColumn(name: 'station_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
75
|
|
|
private StationInterface $station; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var ArrayCollection<int, CrewAssignmentInterface> |
79
|
|
|
*/ |
80
|
|
|
#[OneToMany(targetEntity: 'CrewAssignment', mappedBy: 'tradepost')] |
81
|
|
|
private Collection $crewAssignments; |
82
|
|
|
|
83
|
|
|
public function __construct() |
84
|
|
|
{ |
85
|
|
|
$this->licenseInfos = new ArrayCollection(); |
86
|
|
|
$this->crewAssignments = new ArrayCollection(); |
87
|
|
|
} |
88
|
|
|
|
89
|
9 |
|
#[Override] |
90
|
|
|
public function getId(): int |
91
|
|
|
{ |
92
|
9 |
|
return $this->id; |
93
|
|
|
} |
94
|
|
|
|
95
|
1 |
|
#[Override] |
96
|
|
|
public function getUserId(): int |
97
|
|
|
{ |
98
|
1 |
|
return $this->user_id; |
99
|
|
|
} |
100
|
|
|
|
101
|
1 |
|
#[Override] |
102
|
|
|
public function getUser(): UserInterface |
103
|
|
|
{ |
104
|
1 |
|
return $this->user; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
#[Override] |
108
|
|
|
public function setUser(UserInterface $user): TradePostInterface |
109
|
|
|
{ |
110
|
|
|
$this->user = $user; |
111
|
|
|
|
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
5 |
|
#[Override] |
116
|
|
|
public function getName(): string |
117
|
|
|
{ |
118
|
5 |
|
return $this->name; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
#[Override] |
122
|
|
|
public function setName(string $name): TradePostInterface |
123
|
|
|
{ |
124
|
|
|
$this->name = $name; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
#[Override] |
130
|
|
|
public function getDescription(): string |
131
|
|
|
{ |
132
|
|
|
return $this->description; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
#[Override] |
136
|
|
|
public function setDescription(string $description): TradePostInterface |
137
|
|
|
{ |
138
|
|
|
$this->description = $description; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
#[Override] |
144
|
|
|
public function getStationId(): int |
145
|
|
|
{ |
146
|
|
|
return $this->station_id; |
147
|
|
|
} |
148
|
|
|
|
149
|
1 |
|
#[Override] |
150
|
|
|
public function getTradeNetwork(): int |
151
|
|
|
{ |
152
|
1 |
|
return $this->trade_network; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
#[Override] |
156
|
|
|
public function setTradeNetwork(int $tradeNetwork): TradePostInterface |
157
|
|
|
{ |
158
|
|
|
$this->trade_network = $tradeNetwork; |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
#[Override] |
164
|
|
|
public function getLevel(): int |
165
|
|
|
{ |
166
|
|
|
return $this->level; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
#[Override] |
170
|
|
|
public function setLevel(int $level): TradePostInterface |
171
|
|
|
{ |
172
|
|
|
$this->level = $level; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
#[Override] |
178
|
|
|
public function getTransferCapacity(): int |
179
|
|
|
{ |
180
|
|
|
return $this->transfer_capacity; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
#[Override] |
184
|
|
|
public function setTransferCapacity(int $transferCapacity): TradePostInterface |
185
|
|
|
{ |
186
|
|
|
$this->transfer_capacity = $transferCapacity; |
187
|
|
|
|
188
|
|
|
return $this; |
189
|
|
|
} |
190
|
|
|
|
191
|
2 |
|
#[Override] |
192
|
|
|
public function getStorage(): int |
193
|
|
|
{ |
194
|
2 |
|
return $this->storage; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
#[Override] |
198
|
|
|
public function setStorage(int $storage): TradePostInterface |
199
|
|
|
{ |
200
|
|
|
$this->storage = $storage; |
201
|
|
|
|
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
1 |
|
#[Override] |
206
|
|
|
public function isDockPmAutoRead(): bool |
207
|
|
|
{ |
208
|
1 |
|
return $this->is_dock_pm_auto_read ?? false; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
#[Override] |
212
|
|
|
public function setIsDockPmAutoRead(bool $value): TradePostInterface |
213
|
|
|
{ |
214
|
|
|
$this->is_dock_pm_auto_read = $value; |
215
|
|
|
|
216
|
|
|
return $this; |
217
|
|
|
} |
218
|
|
|
|
219
|
3 |
|
#[Override] |
220
|
|
|
public function getLatestLicenseInfo(): ?TradeLicenseInfoInterface |
221
|
|
|
{ |
222
|
3 |
|
if ($this->licenseInfos->isEmpty()) { |
223
|
|
|
return null; |
224
|
|
|
} |
225
|
3 |
|
return $this->licenseInfos->first(); |
226
|
|
|
} |
227
|
|
|
|
228
|
5 |
|
#[Override] |
229
|
|
|
public function getStation(): StationInterface |
230
|
|
|
{ |
231
|
5 |
|
return $this->station; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
#[Override] |
235
|
|
|
public function setStation(StationInterface $station): TradePostInterface |
236
|
|
|
{ |
237
|
|
|
$this->station = $station; |
238
|
|
|
|
239
|
|
|
return $this; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
#[Override] |
243
|
|
|
public function getCrewAssignments(): Collection |
244
|
|
|
{ |
245
|
|
|
return $this->crewAssignments; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
#[Override] |
249
|
|
|
public function getCrewCountOfUser( |
250
|
|
|
UserInterface $user |
251
|
|
|
): int { |
252
|
|
|
$count = 0; |
253
|
|
|
|
254
|
|
|
foreach ($this->getCrewAssignments() as $crewAssignment) { |
255
|
|
|
if ($crewAssignment->getUser() === $user) { |
256
|
|
|
$count++; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
return $count; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
#[Override] |
264
|
|
|
public function isNpcTradepost(): bool |
265
|
|
|
{ |
266
|
|
|
return $this->getUserId() < UserEnum::USER_FIRST_ID; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
#[Override] |
270
|
|
|
public function __toString(): string |
271
|
|
|
{ |
272
|
|
|
return $this->getName(); |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
|
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