Passed
Push — dev ( 3eb706...7dad97 )
by Janko
09:39
created

FlightRouteFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 12.5%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 44
ccs 2
cts 16
cp 0.125
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getRouteForMapDestination() 0 6 1
A getRouteForCoordinateDestination() 0 4 1
A getFlightRoutePrototype() 0 9 1
A __construct() 0 8 1
A getRouteForWormholeDestination() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Spacecraft\Lib\Movement\Route;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Component\Map\Effects\EffectHandlingInterface;
9
use Stu\Module\Spacecraft\Lib\Movement\Component\Consequence\FlightConsequenceInterface;
10
use Stu\Orm\Entity\MapInterface;
11
use Stu\Orm\Entity\SpacecraftInterface;
12
use Stu\Orm\Entity\StarSystemMapInterface;
13
use Stu\Orm\Entity\WormholeEntryInterface;
14
15
final class FlightRouteFactory implements FlightRouteFactoryInterface
16
{
17
    /**
18
     * @param array<string, FlightConsequenceInterface> $flightConsequences
19
     * @param array<string, FlightConsequenceInterface> $postFlightConsequences
20
     */
21 1
    public function __construct(
22
        private CheckDestinationInterface $checkDestination,
23
        private LoadWaypointsInterface $loadWaypoints,
24
        private EnterWaypoint $enterWaypoint,
25
        private EffectHandlingInterface $effectHandling,
26
        private array $flightConsequences,
27
        private array $postFlightConsequences
28 1
    ) {}
29
30
    #[Override]
31
    public function getRouteForMapDestination(
32
        MapInterface|StarSystemMapInterface $destination,
33
        bool $isTranswarp = false
34
    ): FlightRouteInterface {
35
        return $this->getFlightRoutePrototype()->setDestination($destination, $isTranswarp);
36
    }
37
38
    #[Override]
39
    public function getRouteForWormholeDestination(WormholeEntryInterface $destination, bool $isEntry): FlightRouteInterface
40
    {
41
        return $this->getFlightRoutePrototype()->setDestinationViaWormhole($destination, $isEntry);
42
    }
43
44
    #[Override]
45
    public function getRouteForCoordinateDestination(SpacecraftInterface $spacecraft, int $x, int $y): FlightRouteInterface
46
    {
47
        return $this->getFlightRoutePrototype()->setDestinationViaCoordinates($spacecraft, $x, $y);
48
    }
49
50
    private function getFlightRoutePrototype(): FlightRoute
51
    {
52
        return new FlightRoute(
53
            $this->checkDestination,
54
            $this->loadWaypoints,
55
            $this->enterWaypoint,
56
            $this->effectHandling,
57
            $this->flightConsequences,
58
            $this->postFlightConsequences
59
        );
60
    }
61
}
62