Passed
Push — dev ( d85471...98511f )
by Janko
18:01
created

ModuleRumpWrapperBase   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 8.33%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 33
ccs 1
cts 12
cp 0.0833
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A initialize() 0 5 1
A getSecondValue() 0 4 1
A getModule() 0 11 3
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\Spacecraft\SpacecraftModuleTypeEnum;
10
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface;
11
use Stu\Orm\Entity\ModuleInterface;
12
use Stu\Orm\Entity\SpacecraftBuildplanInterface;
13
use Stu\Orm\Entity\SpacecraftRumpInterface;
14
15
abstract class ModuleRumpWrapperBase implements ModuleRumpWrapperInterface
16
{
17
    /** @var null|array<int, ModuleInterface> */
18
    private ?array $modules = null;
19
20 3
    public function __construct(protected SpacecraftRumpInterface $rump, private ?SpacecraftBuildplanInterface $buildplan) {}
21
22
    abstract public function getModuleType(): SpacecraftModuleTypeEnum;
23
24
    #[Override]
25
    public function getModule(): iterable
26
    {
27
        if ($this->modules === null) {
28
            $buildplan = $this->buildplan;
29
            $this->modules = $buildplan === null
30
                ? []
31
                : $buildplan->getModulesByType($this->getModuleType())->toArray();
32
        }
33
34
        return $this->modules;
35
    }
36
37
    #[Override]
38
    public function getSecondValue(?ModuleInterface $module = null): int
39
    {
40
        throw new RuntimeException(sprintf('not implemented for moduleType: %s', $this->getModuleType()->name));
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Stu\Component\Spacecraft\SpacecraftModuleTypeEnum.
Loading history...
41
    }
42
43
    #[Override]
44
    public function initialize(SpacecraftWrapperInterface $wrapper): ModuleRumpWrapperInterface
45
    {
46
        //override if neccessary
47
        return $this;
48
    }
49
}
50