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

BlockedCondition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 24
ccs 13
cts 13
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 22 4
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