1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib\Movement\Route; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Doctrine\Common\Collections\Collection; |
9
|
|
|
use InvalidArgumentException; |
10
|
|
|
use Override; |
|
|
|
|
11
|
|
|
use RuntimeException; |
12
|
|
|
use Stu\Orm\Entity\LocationInterface; |
13
|
|
|
use Stu\Orm\Entity\MapInterface; |
14
|
|
|
use Stu\Orm\Entity\StarSystemMapInterface; |
15
|
|
|
use Stu\Orm\Repository\MapRepositoryInterface; |
16
|
|
|
use Stu\Orm\Repository\StarSystemMapRepositoryInterface; |
17
|
|
|
|
18
|
|
|
final class LoadWaypoints implements LoadWaypointsInterface |
19
|
|
|
{ |
20
|
10 |
|
public function __construct(private MapRepositoryInterface $mapRepository, private StarSystemMapRepositoryInterface $starSystemMapRepository) {} |
21
|
|
|
|
22
|
10 |
|
#[Override] |
23
|
|
|
public function load( |
24
|
|
|
LocationInterface $start, |
25
|
|
|
LocationInterface $destination |
26
|
|
|
): Collection { |
27
|
10 |
|
if ($start instanceof MapInterface !== $destination instanceof MapInterface) { |
28
|
2 |
|
throw new InvalidArgumentException('start and destination have different type'); |
29
|
|
|
} |
30
|
|
|
|
31
|
8 |
|
$startX = $start->getX(); |
32
|
8 |
|
$startY = $start->getY(); |
33
|
|
|
|
34
|
8 |
|
$destinationX = $destination->getX(); |
35
|
8 |
|
$destinationY = $destination->getY(); |
36
|
|
|
|
37
|
8 |
|
$sortAscending = true; |
38
|
|
|
|
39
|
8 |
|
if ($startY > $destinationY) { |
40
|
2 |
|
$sortAscending = false; |
41
|
|
|
} |
42
|
8 |
|
if ($startX > $destinationX) { |
43
|
2 |
|
$sortAscending = false; |
44
|
|
|
} |
45
|
8 |
|
if ($start instanceof StarSystemMapInterface) { |
46
|
4 |
|
$waypoints = $this->starSystemMapRepository->getByCoordinateRange( |
47
|
4 |
|
$start->getSystem(), |
48
|
4 |
|
min($startX, $destinationX), |
49
|
4 |
|
max($startX, $destinationX), |
50
|
4 |
|
min($startY, $destinationY), |
51
|
4 |
|
max($startY, $destinationY), |
52
|
4 |
|
$sortAscending |
53
|
4 |
|
); |
54
|
|
|
} else { |
55
|
4 |
|
$layer = $start->getLayer(); |
56
|
4 |
|
if ($layer === null) { |
57
|
|
|
throw new RuntimeException('this should not happen'); |
58
|
|
|
} |
59
|
4 |
|
$waypoints = $this->mapRepository->getByCoordinateRange( |
60
|
4 |
|
$layer->getId(), |
61
|
4 |
|
min($startX, $destinationX), |
62
|
4 |
|
max($startX, $destinationX), |
63
|
4 |
|
min($startY, $destinationY), |
64
|
4 |
|
max($startY, $destinationY), |
65
|
4 |
|
$sortAscending |
66
|
4 |
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
8 |
|
$result = new ArrayCollection(); |
70
|
|
|
|
71
|
8 |
|
foreach ($waypoints as $waypoint) { |
72
|
8 |
|
if ($waypoint !== $start) { |
73
|
8 |
|
$result->add($waypoint); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
8 |
|
return $result; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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