|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Movement\Component; |
|
6
|
|
|
|
|
7
|
|
|
use InvalidArgumentException; |
|
8
|
|
|
use Override; |
|
|
|
|
|
|
9
|
|
|
use Stu\Component\Map\DirectionEnum; |
|
10
|
|
|
use Stu\Orm\Entity\FlightSignature; |
|
11
|
|
|
use Stu\Orm\Entity\Location; |
|
12
|
|
|
use Stu\Orm\Entity\Map; |
|
13
|
|
|
use Stu\Orm\Entity\Spacecraft; |
|
14
|
|
|
use Stu\Orm\Repository\FlightSignatureRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Creates flight signatures for ship movements |
|
18
|
|
|
*/ |
|
19
|
|
|
final class FlightSignatureCreator implements FlightSignatureCreatorInterface |
|
20
|
|
|
{ |
|
21
|
|
|
public function __construct(private FlightSignatureRepositoryInterface $flightSignatureRepository) {} |
|
22
|
|
|
|
|
23
|
|
|
#[Override] |
|
24
|
|
|
public function createSignatures( |
|
25
|
|
|
Spacecraft $spacecraft, |
|
26
|
11 |
|
DirectionEnum $direction, |
|
27
|
|
|
Location $currentLocation, |
|
28
|
|
|
Location $nextLocation |
|
29
|
|
|
): void { |
|
30
|
|
|
if ($currentLocation instanceof Map !== $nextLocation instanceof Map) { |
|
31
|
11 |
|
throw new InvalidArgumentException('wayopints have different type'); |
|
32
|
|
|
} |
|
33
|
13 |
|
|
|
34
|
|
|
$fromSignature = $this->createSignature($spacecraft); |
|
35
|
|
|
$fromSignature->setLocation($currentLocation); |
|
36
|
|
|
|
|
37
|
|
|
$toSignature = $this->createSignature($spacecraft); |
|
38
|
|
|
$toSignature->setLocation($nextLocation); |
|
39
|
|
|
|
|
40
|
13 |
|
$this->create( |
|
41
|
2 |
|
$direction, |
|
42
|
|
|
$fromSignature, |
|
43
|
|
|
$toSignature |
|
44
|
11 |
|
); |
|
45
|
11 |
|
} |
|
46
|
|
|
|
|
47
|
11 |
|
private function create( |
|
48
|
11 |
|
DirectionEnum $direction, |
|
49
|
|
|
FlightSignature $fromSignature, |
|
50
|
11 |
|
FlightSignature $toSignature |
|
51
|
11 |
|
): void { |
|
52
|
11 |
|
|
|
53
|
11 |
|
$fromSignature->setToDirection($direction); |
|
54
|
11 |
|
$toSignature->setFromDirection($direction->getOpposite()); |
|
55
|
|
|
|
|
56
|
|
|
$this->flightSignatureRepository->save($fromSignature); |
|
57
|
11 |
|
$this->flightSignatureRepository->save($toSignature); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
private function createSignature(Spacecraft $spacecraft): FlightSignature |
|
61
|
|
|
{ |
|
62
|
|
|
$signature = $this->flightSignatureRepository->prototype(); |
|
63
|
11 |
|
$signature->setUserId($spacecraft->getUser()->getId()); |
|
64
|
11 |
|
$signature->setShipId($spacecraft->getId()); |
|
65
|
|
|
$signature->setSpacecraftName($spacecraft->getName()); |
|
66
|
11 |
|
$signature->setRump($spacecraft->getRump()); |
|
67
|
11 |
|
$signature->setIsCloaked($spacecraft->isCloaked()); |
|
68
|
|
|
$signature->setTime(time()); |
|
69
|
|
|
|
|
70
|
11 |
|
return $signature; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
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