Passed
Push — master ( a3f62b...37016c )
by Nico
54:32 queued 29:36
created

ModuleRumpWrapperWarpDrive::getValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 12
ccs 0
cts 8
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\ModuleRumpWrapper;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use RuntimeException;
9
use Stu\Component\Ship\ShipModuleTypeEnum;
10
use Stu\Module\Ship\Lib\ModuleValueCalculator;
11
use Stu\Module\Ship\Lib\ShipWrapperInterface;
12
use Stu\Orm\Entity\ModuleInterface;
13
14
final class ModuleRumpWrapperWarpDrive extends ModuleRumpWrapperBase implements ModuleRumpWrapperInterface
15
{
16
    #[Override]
17
    public function getValue(?ModuleInterface $module = null): int
18
    {
19
        $module ??= current($this->getModule());
20
        if ($module === false) {
21
            return 0;
22
        }
23
24
        return (new ModuleValueCalculator())->calculateModuleValue(
25
            $this->rump,
26
            $module,
27
            $this->rump->getBaseWarpDrive()
28
        );
29
    }
30
31
    #[Override]
32
    public function getSecondValue(?ModuleInterface $module = null): ?int
33
    {
34
        return null;
35
    }
36
37
    #[Override]
38
    public function getModuleType(): ShipModuleTypeEnum
39
    {
40
        return ShipModuleTypeEnum::WARPDRIVE;
41
    }
42
43
    #[Override]
44
    public function apply(ShipWrapperInterface $wrapper): void
45
    {
46
        $ship = $wrapper->get();
47
48
        $systemData = $wrapper->getWarpDriveSystemData();
49
        if ($systemData === null) {
50
            throw new RuntimeException('this should not happen');
51
        }
52
53
        $systemData
54
            ->setMaxWarpDrive($this->getValue())
55
            ->setWarpDriveSplit(100)
56
            ->setAutoCarryOver($ship->getUser()->getWarpsplitAutoCarryoverDefault())
57
            ->update();
58
    }
59
}
60