Passed
Push — master ( 288b46...98b0e3 )
by Nico
31:30 queued 08:00
created

AstroMappingConsequence   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 26
ccs 12
cts 12
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A triggerSpecific() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib\Movement\Component\Consequence\Flight;
6
7
use Stu\Component\Ship\ShipStateEnum;
8
use Stu\Module\Ship\Lib\AstroEntryLibInterface;
9
use Stu\Module\Ship\Lib\Message\Message;
10
use Stu\Module\Ship\Lib\Message\MessageCollectionInterface;
11
use Stu\Module\Ship\Lib\Movement\Component\Consequence\AbstractFlightConsequence;
12
use Stu\Module\Ship\Lib\Movement\Route\FlightRouteInterface;
13
use Stu\Module\Ship\Lib\ShipWrapperInterface;
14
15
class AstroMappingConsequence extends AbstractFlightConsequence
16
{
17
    private AstroEntryLibInterface $astroEntryLib;
18
19 4
    public function __construct(AstroEntryLibInterface $astroEntryLib)
20
    {
21 4
        $this->astroEntryLib = $astroEntryLib;
22
    }
23
24 2
    protected function triggerSpecific(
25
        ShipWrapperInterface $wrapper,
26
        FlightRouteInterface $flightRoute,
27
        MessageCollectionInterface $messages
28
    ): void {
29
30 2
        $ship = $wrapper->get();
31
32 2
        if ($ship->getState() === ShipStateEnum::SHIP_STATE_ASTRO_FINALIZING) {
33 1
            $message = new Message(
34 1
                null,
35 1
                $ship->getUser()->getId(),
36 1
                [sprintf('Die %s hat die Kartographierung abgebrochen', $ship->getName())]
37 1
            );
38 1
            $messages->add($message);
39
40 1
            $this->astroEntryLib->cancelAstroFinalizing($ship);
41
        }
42
    }
43
}
44