|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Movement; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\Collection; |
|
6
|
|
|
use Stu\Module\Ship\Lib\FleetWrapperInterface; |
|
7
|
|
|
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; |
|
8
|
|
|
use Stu\Module\Spacecraft\Lib\Movement\Component\PreFlight\ConditionCheckResult; |
|
9
|
|
|
use Stu\Module\Spacecraft\Lib\Movement\Component\PreFlight\PreFlightConditionsCheckInterface; |
|
10
|
|
|
use Stu\Module\Spacecraft\Lib\Movement\Route\FlightRouteInterface; |
|
11
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
|
12
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
13
|
|
|
|
|
14
|
|
|
class FlightCompany |
|
15
|
|
|
{ |
|
16
|
|
|
/** @param Collection<int, covariant SpacecraftWrapperInterface> $members */ |
|
|
|
|
|
|
17
|
14 |
|
public function __construct( |
|
18
|
|
|
private SpacecraftWrapperInterface|FleetWrapperInterface $subject, |
|
19
|
|
|
private Collection $members, |
|
20
|
|
|
private PreFlightConditionsCheckInterface $preFlightConditionsCheck |
|
21
|
14 |
|
) {} |
|
22
|
|
|
|
|
23
|
1 |
|
public function getLeader(): SpacecraftInterface |
|
24
|
|
|
{ |
|
25
|
1 |
|
return $this->getLeadWrapper()->get(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
2 |
|
public function getLeadWrapper(): SpacecraftWrapperInterface |
|
29
|
|
|
{ |
|
30
|
2 |
|
return $this->subject instanceof SpacecraftWrapperInterface |
|
31
|
1 |
|
? $this->subject |
|
32
|
2 |
|
: $this->subject->getLeadWrapper(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** @return Collection<int, SpacecraftWrapperInterface> */ |
|
36
|
4 |
|
public function getActiveMembers(): Collection |
|
37
|
|
|
{ |
|
38
|
4 |
|
return $this->members |
|
39
|
4 |
|
->filter(fn(SpacecraftWrapperInterface $wrapper): bool => !$wrapper->get()->isDestroyed()); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function isEmpty(): bool |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->getActiveMembers()->isEmpty(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
2 |
|
public function isFleetMode(): bool |
|
48
|
|
|
{ |
|
49
|
2 |
|
return $this->subject instanceof FleetWrapperInterface; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
3 |
|
public function isFixedFleetMode(): bool |
|
53
|
|
|
{ |
|
54
|
3 |
|
return $this->subject instanceof FleetWrapperInterface |
|
55
|
3 |
|
&& $this->subject->get()->isFleetFixed(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
3 |
|
public function hasToLeaveFleet(): bool |
|
59
|
|
|
{ |
|
60
|
3 |
|
return $this->subject instanceof SpacecraftWrapperInterface |
|
61
|
3 |
|
&& $this->subject->getFleetWrapper() !== null; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
2 |
|
public function isFlightPossible( |
|
65
|
|
|
FlightRouteInterface $flightRoute, |
|
66
|
|
|
MessageCollectionInterface $messages |
|
67
|
|
|
): bool { |
|
68
|
|
|
// check all flight pre conditions |
|
69
|
2 |
|
$conditionCheckResult = $this->preFlightConditionsCheck->checkPreconditions( |
|
70
|
2 |
|
$this, |
|
71
|
2 |
|
$flightRoute, |
|
72
|
2 |
|
$messages |
|
73
|
2 |
|
); |
|
74
|
|
|
|
|
75
|
2 |
|
$this->removeBlocked($conditionCheckResult); |
|
76
|
|
|
|
|
77
|
2 |
|
return $conditionCheckResult->isFlightPossible(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
2 |
|
private function removeBlocked(ConditionCheckResult $conditionCheckResult): void |
|
81
|
|
|
{ |
|
82
|
2 |
|
foreach ($conditionCheckResult->getBlockedIds() as $spacecraftId) { |
|
83
|
2 |
|
$this->members->remove($spacecraftId); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
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