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

ModuleRumpWrapperEps::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 1
Bugs 0 Features 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 1
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 ModuleRumpWrapperEps 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->getBaseEps()
28
        );
29
    }
30
31
    #[Override]
32
    public function getSecondValue(?ModuleInterface $module = null): ?int
33
    {
34
        $module ??= current($this->getModule());
35
        if ($module === false) {
36
            return null;
37
        }
38
        return (int) round($this->getValue($module) / 3);
39
    }
40
41
    #[Override]
42
    public function getModuleType(): ShipModuleTypeEnum
43
    {
44
        return ShipModuleTypeEnum::EPS;
45
    }
46
47
    #[Override]
48
    public function apply(ShipWrapperInterface $wrapper): void
49
    {
50
        $epsSystem = $wrapper->getEpsSystemData();
51
        if ($epsSystem === null) {
52
            throw new RuntimeException('this should not happen');
53
        }
54
55
        $epsSystem->setMaxEps($this->getValue())->update();
56
    }
57
}
58