Passed
Push — master ( 0ac6a9...434e9a )
by Nico
16:38 queued 10:37
created

ShipSystemDataFactory::createSystemData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1.0001

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 21
nc 1
nop 2
dl 0
loc 27
ccs 19
cts 20
cp 0.95
crap 1.0001
rs 9.584
c 1
b 1
f 0
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
}