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

ModuleRumpWrapperReactor::getSecondValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 5
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
use Stu\Module\Ship\Lib\ReactorWrapperInterface;
14
15
final class ModuleRumpWrapperReactor extends ModuleRumpWrapperBase implements ModuleRumpWrapperInterface
16
{
17
    #[Override]
18
    public function getValue(?ModuleInterface $module = null): int
19
    {
20
        $module ??= current($this->getModule());
21
        if ($module === false) {
22
            return 0;
23
        }
24
25
        return (new ModuleValueCalculator())->calculateModuleValue(
26
            $this->rump,
27
            $module,
28
            $this->rump->getBaseReactor()
29
        );
30
    }
31
32
    #[Override]
33
    public function getSecondValue(?ModuleInterface $module = null): ?int
34
    {
35
        $module ??= current($this->getModule());
36
        if ($module === false) {
37
            return null;
38
        }
39
        return $this->getValue($module) * ReactorWrapperInterface::WARPCORE_CAPACITY_MULTIPLIER;
40
    }
41
42
    #[Override]
43
    public function getModuleType(): ShipModuleTypeEnum
44
    {
45
        return ShipModuleTypeEnum::REACTOR;
46
    }
47
48
    #[Override]
49
    public function apply(ShipWrapperInterface $wrapper): void
50
    {
51
        $reactorWrapper = $wrapper->getReactorWrapper();
52
        if ($reactorWrapper === null) {
53
            throw new RuntimeException('this should not happen');
54
        }
55
56
        $reactorWrapper->setOutput($this->getValue());
57
    }
58
}
59