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

AstroMappingConsequence::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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