Passed
Push — dev ( 01e00b...1a995e )
by Nico
06:06
created

ShipSystemDataFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 95.45%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 22
dl 0
loc 41
ccs 21
cts 22
cp 0.9545
rs 10
c 1
b 1
f 0
wmc 2

2 Methods

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