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

AstroMappingConsequence::triggerSpecific()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

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