Passed
Push — master ( bf860f...1dd8f7 )
by Nico
57:55 queued 29:36
created

CrewEvacuation::handleShipDestruction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 4
dl 0
loc 12
ccs 0
cts 4
cp 0
crap 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Ship\Lib\Destruction\Handler;
4
5
use Stu\Lib\Information\InformationInterface;
6
use Stu\Module\Ship\Lib\Crew\ShipLeaverInterface;
7
use Stu\Module\Ship\Lib\Destruction\ShipDestroyerInterface;
8
use Stu\Module\Ship\Lib\Destruction\ShipDestructionCauseEnum;
9
use Stu\Module\Ship\Lib\ShipWrapperInterface;
10
11
class CrewEvacuation implements ShipDestructionHandlerInterface
12
{
13 1
    public function __construct(
14
        private ShipLeaverInterface $shipLeaver
15
    ) {
16 1
    }
17
18
    public function handleShipDestruction(
19
        ?ShipDestroyerInterface $destroyer,
20
        ShipWrapperInterface $destroyedShipWrapper,
21
        ShipDestructionCauseEnum $cause,
22
        InformationInterface $informations
23
    ): void {
24
25
        //leave ship if there is crew
26
        if ($destroyedShipWrapper->get()->getCrewCount() > 0) {
27
            $msg = $this->shipLeaver->evacuate($destroyedShipWrapper);
28
29
            $informations->addInformation($msg);
30
        }
31
    }
32
}
33