| Total Complexity | 4 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | abstract class AbstractSystemData |
||
| 14 | { |
||
| 15 | protected SpacecraftInterface $spacecraft; |
||
| 16 | |||
| 17 | 23 | public function __construct( |
|
| 18 | private SpacecraftSystemRepositoryInterface $shipSystemRepository, |
||
| 19 | private StatusBarFactoryInterface $statusBarFactory |
||
| 20 | 23 | ) {} |
|
| 21 | |||
| 22 | 21 | public function setSpacecraft(SpacecraftInterface $spacecraft): void |
|
| 25 | } |
||
| 26 | |||
| 27 | abstract public function getSystemType(): SpacecraftSystemTypeEnum; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * updates the system metadata for this specific ship system |
||
| 31 | */ |
||
| 32 | 1 | public function update(): void |
|
| 33 | { |
||
| 34 | 1 | $system = $this->spacecraft->getSpacecraftSystem($this->getSystemType()); |
|
| 35 | 1 | $system->setData(json_encode($this, JSON_THROW_ON_ERROR)); |
|
| 36 | 1 | $this->shipSystemRepository->save($system); |
|
| 37 | } |
||
| 38 | |||
| 39 | 8 | protected function getStatusBar(string $label, int $value, int $maxValue, string $color): StatusBarInterface |
|
| 47 | } |
||
| 48 | } |
||
| 49 |