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
|
|
|
private ShipRepositoryInterface $shipRepository; |
17
|
|
|
|
18
|
|
|
private ShipSystemRepositoryInterface $shipSystemRepository; |
19
|
|
|
|
20
|
|
|
private TholianWebRepositoryInterface $tholianWebRepository; |
21
|
|
|
|
22
|
1 |
|
public function __construct( |
23
|
|
|
ShipRepositoryInterface $shipRepository, |
24
|
|
|
ShipSystemRepositoryInterface $shipSystemRepository, |
25
|
|
|
TholianWebRepositoryInterface $tholianWebRepository |
26
|
|
|
) { |
27
|
1 |
|
$this->shipRepository = $shipRepository; |
28
|
1 |
|
$this->shipSystemRepository = $shipSystemRepository; |
29
|
1 |
|
$this->tholianWebRepository = $tholianWebRepository; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function createSystemData( |
33
|
|
|
int $systemType, |
34
|
|
|
ShipWrapperFactoryInterface $shipWrapperFactory |
35
|
|
|
): AbstractSystemData { |
36
|
|
|
switch ($systemType) { |
37
|
|
|
case ShipSystemTypeEnum::SYSTEM_HULL: |
38
|
|
|
return new HullSystemData(); |
39
|
|
|
case ShipSystemTypeEnum::SYSTEM_SHIELDS: |
40
|
|
|
return new ShieldSystemData(); |
41
|
|
|
case ShipSystemTypeEnum::SYSTEM_EPS: |
42
|
|
|
return new EpsSystemData($this->shipSystemRepository); |
43
|
|
|
case ShipSystemTypeEnum::SYSTEM_TRACKER: |
44
|
|
|
return new TrackerSystemData( |
45
|
|
|
$this->shipRepository, |
46
|
|
|
$this->shipSystemRepository, |
47
|
|
|
$shipWrapperFactory |
48
|
|
|
); |
49
|
|
|
case ShipSystemTypeEnum::SYSTEM_THOLIAN_WEB: |
50
|
|
|
return new WebEmitterSystemData( |
51
|
|
|
$this->shipSystemRepository, |
52
|
|
|
$this->tholianWebRepository |
53
|
|
|
); |
54
|
|
|
case ShipSystemTypeEnum::SYSTEM_WARPDRIVE: |
55
|
|
|
return new WarpDriveSystemData($this->shipSystemRepository); |
56
|
|
|
case ShipSystemTypeEnum::SYSTEM_WARPCORE: |
57
|
|
|
return new WarpCoreSystemData($this->shipSystemRepository); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
throw new InvalidSystemException(sprintf('no system data present for systemType: %d', $systemType)); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|