Passed
Push — master ( 288b46...98b0e3 )
by Nico
31:30 queued 08:00
created

BlockedCondition::check()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
c 1
b 0
f 0
nc 3
nop 3
dl 0
loc 22
ccs 13
cts 13
cp 1
crap 4
rs 9.9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Ship\Lib\Movement\Component\PreFlight\Condition;
6
7
use Stu\Module\Ship\Lib\Movement\Component\PreFlight\ConditionCheckResult;
8
use Stu\Module\Ship\Lib\Movement\Route\FlightRouteInterface;
9
use Stu\Module\Ship\Lib\ShipWrapperInterface;
10
11
class BlockedCondition implements PreFlightConditionInterface
12
{
13 4
    public function check(
14
        ShipWrapperInterface $wrapper,
15
        FlightRouteInterface $flightRoute,
16
        ConditionCheckResult $conditionCheckResult
17
    ): void {
18
19 4
        $ship = $wrapper->get();
20
21 4
        if ($ship->isTractored()) {
22 1
            $conditionCheckResult->addBlockedShip(
23 1
                $ship,
24 1
                sprintf(_('Die %s wird von einem Traktorstrahl gehalten'), $ship->getName())
25 1
            );
26
27 1
            return;
28
        }
29
30 3
        $holdingWeb = $ship->getHoldingWeb();
31 3
        if ($holdingWeb !== null && $holdingWeb->isFinished()) {
32 1
            $conditionCheckResult->addBlockedShip(
33 1
                $ship,
34 1
                sprintf(_('Die %s wird von einem Energienetz gehalten'), $ship->getName())
35 1
            );
36
        }
37
    }
38
}
39