Passed
Pull Request — master (#2327)
by Janko
12:17 queued 06:15
created

ClearTractoredBeam   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 5
c 1
b 1
f 0
dl 0
loc 18
ccs 2
cts 6
cp 0.3333
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleSpacecraftDestruction() 0 12 2
A __construct() 0 3 1
1
<?php
2
3
namespace Stu\Module\Spacecraft\Lib\Destruction\Handler;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemManagerInterface;
6
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
7
use Stu\Lib\Information\InformationInterface;
8
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestroyerInterface;
9
use Stu\Module\Spacecraft\Lib\Destruction\SpacecraftDestructionCauseEnum;
10
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface;
11
12
class ClearTractoredBeam implements SpacecraftDestructionHandlerInterface
13
{
14 1
    public function __construct(
15
        private SpacecraftSystemManagerInterface $spacecraftSystemManager
16 1
    ) {}
17
18
    #[\Override]
19
    public function handleSpacecraftDestruction(
20
        ?SpacecraftDestroyerInterface $destroyer,
21
        SpacecraftWrapperInterface $destroyedSpacecraftWrapper,
22
        SpacecraftDestructionCauseEnum $cause,
23
        InformationInterface $informations
24
    ): void {
25
26
        $tractoredShipWrapper = $destroyedSpacecraftWrapper->getTractoredShipWrapper();
27
        if ($tractoredShipWrapper !== null) {
28
29
            $this->spacecraftSystemManager->deactivate($destroyedSpacecraftWrapper, SpacecraftSystemTypeEnum::TRACTOR_BEAM, true);
30
        }
31
    }
32
}
33