Passed
Push — master ( eed220...e3ff64 )
by Janko
21:01 queued 11:01
created

ShipSystemDataFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
eloc 21
c 0
b 0
f 0
dl 0
loc 35
ccs 20
cts 21
cp 0.9524
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createSystemData() 0 26 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Spacecraft\System\Data;
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 Stu\Component\Spacecraft\System\Exception\InvalidSystemException;
9
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
10
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperFactoryInterface;
11
use Stu\Module\Template\StatusBarFactoryInterface;
12
use Stu\Orm\Repository\ShipRepositoryInterface;
13
use Stu\Orm\Repository\SpacecraftSystemRepositoryInterface;
14
use Stu\Orm\Repository\TholianWebRepositoryInterface;
15
16
final class ShipSystemDataFactory implements ShipSystemDataFactoryInterface
17
{
18 1
    public function __construct(
19
        private readonly ShipRepositoryInterface $shipRepository,
20
        private readonly SpacecraftSystemRepositoryInterface $shipSystemRepository,
21
        private readonly TholianWebRepositoryInterface $tholianWebRepository,
22
        private readonly StatusBarFactoryInterface $statusBarFactory
23 1
    ) {}
24
25 22
    #[Override]
26
    public function createSystemData(
27
        SpacecraftSystemTypeEnum $systemType,
28
        SpacecraftWrapperFactoryInterface $spacecraftWrapperFactory
29
    ): AbstractSystemData {
30
31
        return match ($systemType) {
32 22
            SpacecraftSystemTypeEnum::HULL =>  new HullSystemData($this->shipSystemRepository, $this->statusBarFactory),
33 18
            SpacecraftSystemTypeEnum::SHIELDS =>  new ShieldSystemData($this->shipSystemRepository, $this->statusBarFactory),
34 18
            SpacecraftSystemTypeEnum::EPS =>  new EpsSystemData($this->shipSystemRepository, $this->statusBarFactory),
35 13
            SpacecraftSystemTypeEnum::COMPUTER =>  new ComputerSystemData($this->shipSystemRepository, $this->statusBarFactory),
36 12
            SpacecraftSystemTypeEnum::TRACKER =>  new TrackerSystemData($this->shipRepository, $spacecraftWrapperFactory, $this->shipSystemRepository, $this->statusBarFactory),
37 12
            SpacecraftSystemTypeEnum::THOLIAN_WEB =>  new WebEmitterSystemData($this->shipSystemRepository, $this->tholianWebRepository, $this->statusBarFactory),
38 11
            SpacecraftSystemTypeEnum::WARPDRIVE =>  new WarpDriveSystemData($this->shipSystemRepository, $this->statusBarFactory),
39 9
            SpacecraftSystemTypeEnum::WARPCORE =>  new WarpCoreSystemData($this->shipSystemRepository, $this->statusBarFactory),
40 6
            SpacecraftSystemTypeEnum::SINGULARITY_REACTOR =>  new SingularityCoreSystemData($this->shipSystemRepository, $this->statusBarFactory),
41 6
            SpacecraftSystemTypeEnum::FUSION_REACTOR =>  new FusionCoreSystemData($this->shipSystemRepository, $this->statusBarFactory),
42 6
            SpacecraftSystemTypeEnum::ASTRO_LABORATORY =>  new AstroLaboratorySystemData($this->shipSystemRepository, $this->statusBarFactory),
43 6
            SpacecraftSystemTypeEnum::PHASER =>  new EnergyWeaponSystemData($this->shipSystemRepository, $this->statusBarFactory),
44 6
            SpacecraftSystemTypeEnum::TORPEDO =>  new ProjectileLauncherSystemData($this->shipSystemRepository, $this->statusBarFactory),
45 6
            SpacecraftSystemTypeEnum::BUSSARD_COLLECTOR =>  new BussardCollectorSystemData($this->shipSystemRepository, $this->statusBarFactory),
46 5
            SpacecraftSystemTypeEnum::AGGREGATION_SYSTEM =>  new AggregationSystemSystemData($this->shipSystemRepository, $this->statusBarFactory),
47 4
            SpacecraftSystemTypeEnum::LSS =>  new LssSystemData($this->shipSystemRepository, $this->statusBarFactory),
48
            SpacecraftSystemTypeEnum::SUBSPACE_SCANNER => new SubspaceSystemData($this->shipSystemRepository, $this->statusBarFactory),
49
50 22
            default => throw new InvalidSystemException(sprintf('no system data present for systemType: %d', $systemType->value))
51
        };
52
    }
53
}
54