|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Component\Ship\System\Data; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Component\Ship\System\Exception\InvalidSystemException; |
|
8
|
|
|
use Stu\Component\Ship\System\ShipSystemTypeEnum; |
|
9
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperFactoryInterface; |
|
10
|
|
|
use Stu\Orm\Repository\ShipRepositoryInterface; |
|
11
|
|
|
use Stu\Orm\Repository\ShipSystemRepositoryInterface; |
|
12
|
|
|
use Stu\Orm\Repository\TholianWebRepositoryInterface; |
|
13
|
|
|
|
|
14
|
|
|
final class ShipSystemDataFactory implements ShipSystemDataFactoryInterface |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
1 |
|
public function __construct( |
|
18
|
|
|
private ShipRepositoryInterface $shipRepository, |
|
19
|
|
|
private ShipSystemRepositoryInterface $shipSystemRepository, |
|
20
|
|
|
private TholianWebRepositoryInterface $tholianWebRepository |
|
21
|
|
|
) { |
|
22
|
1 |
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function createSystemData( |
|
25
|
|
|
ShipSystemTypeEnum $systemType, |
|
26
|
|
|
ShipWrapperFactoryInterface $shipWrapperFactory |
|
27
|
|
|
): AbstractSystemData { |
|
28
|
|
|
switch ($systemType) { |
|
29
|
|
|
case ShipSystemTypeEnum::SYSTEM_HULL: |
|
30
|
|
|
return new HullSystemData($this->shipSystemRepository); |
|
31
|
|
|
case ShipSystemTypeEnum::SYSTEM_SHIELDS: |
|
32
|
|
|
return new ShieldSystemData($this->shipSystemRepository); |
|
33
|
|
|
case ShipSystemTypeEnum::SYSTEM_EPS: |
|
34
|
|
|
return new EpsSystemData($this->shipSystemRepository); |
|
35
|
|
|
case ShipSystemTypeEnum::SYSTEM_TRACKER: |
|
36
|
|
|
return new TrackerSystemData( |
|
37
|
|
|
$this->shipRepository, |
|
38
|
|
|
$shipWrapperFactory, |
|
39
|
|
|
$this->shipSystemRepository |
|
40
|
|
|
); |
|
41
|
|
|
case ShipSystemTypeEnum::SYSTEM_THOLIAN_WEB: |
|
42
|
|
|
return new WebEmitterSystemData( |
|
43
|
|
|
$this->shipSystemRepository, |
|
44
|
|
|
$this->tholianWebRepository |
|
45
|
|
|
); |
|
46
|
|
|
case ShipSystemTypeEnum::SYSTEM_WARPDRIVE: |
|
47
|
|
|
return new WarpDriveSystemData($this->shipSystemRepository); |
|
48
|
|
|
case ShipSystemTypeEnum::SYSTEM_WARPCORE: |
|
49
|
|
|
return new WarpCoreSystemData($this->shipSystemRepository); |
|
50
|
|
|
case ShipSystemTypeEnum::SYSTEM_SINGULARITY_REACTOR: |
|
51
|
|
|
return new SingularityCoreSystemData($this->shipSystemRepository); |
|
52
|
|
|
case ShipSystemTypeEnum::SYSTEM_FUSION_REACTOR: |
|
53
|
|
|
return new FusionCoreSystemData($this->shipSystemRepository); |
|
54
|
|
|
case ShipSystemTypeEnum::SYSTEM_ASTRO_LABORATORY: |
|
55
|
|
|
return new AstroLaboratorySystemData($this->shipSystemRepository); |
|
56
|
|
|
case ShipSystemTypeEnum::SYSTEM_TORPEDO: |
|
57
|
|
|
return new ProjectileLauncherSystemData($this->shipSystemRepository); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
throw new InvalidSystemException(sprintf('no system data present for systemType: %d', $systemType->value)); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|