Passed
Push — master ( 3d0840...13d157 )
by Nico
48:12 queued 22:32
created

DriveActivatableCondition   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 42
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A check() 0 33 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib\Movement\Component\PreFlight\Condition;
6
7
use Stu\Component\Ship\System\ShipSystemTypeEnum;
8
use Stu\Module\Ship\Lib\ActivatorDeactivatorHelperInterface;
9
use Stu\Module\Ship\Lib\Movement\Component\PreFlight\ConditionCheckResult;
10
use Stu\Module\Ship\Lib\Movement\Route\FlightRouteInterface;
11
use Stu\Module\Ship\Lib\ShipWrapperInterface;
12
13
class DriveActivatableCondition implements PreFlightConditionInterface
14
{
15
    private ActivatorDeactivatorHelperInterface $activatorDeactivatorHelper;
16
17 4
    public function __construct(ActivatorDeactivatorHelperInterface $activatorDeactivatorHelper)
18
    {
19 4
        $this->activatorDeactivatorHelper = $activatorDeactivatorHelper;
20
    }
21
22 3
    public function check(
23
        ShipWrapperInterface $wrapper,
24
        FlightRouteInterface $flightRoute,
25
        ConditionCheckResult $conditionCheckResult
26
    ): void {
27
28 3
        if ($flightRoute->isImpulseDriveNeeded()) {
29 1
            $this->activatorDeactivatorHelper->activate(
30 1
                $wrapper,
31 1
                ShipSystemTypeEnum::SYSTEM_IMPULSEDRIVE,
32 1
                $conditionCheckResult,
33 1
                false,
34 1
                true
35 1
            );
36
        }
37
38 3
        if ($flightRoute->isWarpDriveNeeded()) {
39 1
            $this->activatorDeactivatorHelper->activate(
40 1
                $wrapper,
41 1
                ShipSystemTypeEnum::SYSTEM_WARPDRIVE,
42 1
                $conditionCheckResult,
43 1
                false,
44 1
                true
45 1
            );
46
        }
47
48 3
        if ($flightRoute->isTranswarpCoilNeeded()) {
49 1
            $this->activatorDeactivatorHelper->activate(
50 1
                $wrapper,
51 1
                ShipSystemTypeEnum::SYSTEM_TRANSWARP_COIL,
52 1
                $conditionCheckResult,
53 1
                false,
54 1
                true
55 1
            );
56
        }
57
    }
58
}
59