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

DriveActivatableCondition::check()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 33
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 21
nc 8
nop 3
dl 0
loc 33
ccs 24
cts 24
cp 1
crap 4
rs 9.584
c 0
b 0
f 0
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