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

ResetTrackerDevices::handleShipDestruction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 4
dl 0
loc 13
ccs 0
cts 5
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\Component\Ship\System\ShipSystemManagerInterface;
6
use Stu\Component\Ship\System\ShipSystemTypeEnum;
7
use Stu\Lib\Information\InformationInterface;
8
use Stu\Module\Ship\Lib\Destruction\ShipDestroyerInterface;
9
use Stu\Module\Ship\Lib\Destruction\ShipDestructionCauseEnum;
10
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface;
11
use Stu\Module\Ship\Lib\ShipWrapperInterface;
12
use Stu\Orm\Repository\ShipSystemRepositoryInterface;
13
14
class ResetTrackerDevices implements ShipDestructionHandlerInterface
15
{
16 1
    public function __construct(
17
        private ShipSystemRepositoryInterface $shipSystemRepository,
18
        private ShipSystemManagerInterface $shipSystemManager,
19
        private ShipWrapperFactoryInterface $shipWrapperFactory
20
    ) {
21 1
    }
22
23
    public function handleShipDestruction(
24
        ?ShipDestroyerInterface $destroyer,
25
        ShipWrapperInterface $destroyedShipWrapper,
26
        ShipDestructionCauseEnum $cause,
27
        InformationInterface $informations
28
    ): void {
29
30
        $shipId = $destroyedShipWrapper->get()->getId();
31
32
        foreach ($this->shipSystemRepository->getTrackingShipSystems($shipId) as $system) {
33
            $wrapper = $this->shipWrapperFactory->wrapShip($system->getShip());
34
35
            $this->shipSystemManager->deactivate($wrapper, ShipSystemTypeEnum::SYSTEM_TRACKER, true);
36
        }
37
    }
38
}
39