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

ClearTractoredBeam::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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