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

HistoryEntryCreation::handleShipDestruction()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 1
nop 4
dl 0
loc 13
ccs 0
cts 6
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\History\Lib\EntryCreatorInterface;
7
use Stu\Module\PlayerSetting\Lib\UserEnum;
8
use Stu\Module\Ship\Lib\Destruction\ShipDestroyerInterface;
9
use Stu\Module\Ship\Lib\Destruction\ShipDestructionCauseEnum;
10
use Stu\Module\Ship\Lib\ShipWrapperInterface;
11
12
class HistoryEntryCreation implements ShipDestructionHandlerInterface
13
{
14 1
    public function __construct(
15
        private EntryCreatorInterface $entryCreator
16
    ) {
17 1
    }
18
19
    public function handleShipDestruction(
20
        ?ShipDestroyerInterface $destroyer,
21
        ShipWrapperInterface $destroyedShipWrapper,
22
        ShipDestructionCauseEnum $cause,
23
        InformationInterface $informations
24
    ): void {
25
26
        $ship = $destroyedShipWrapper->get();
27
28
        $this->entryCreator->addEntry(
29
            $cause->getHistoryEntryText($destroyer, $ship),
30
            $destroyer === null ? UserEnum::USER_NOONE : $destroyer->getUser()->getId(),
31
            $ship
32
        );
33
    }
34
}
35