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

HistoryEntryCreation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 20
ccs 2
cts 8
cp 0.25
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handleShipDestruction() 0 13 2
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