| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | 3 | public function create( |
|
| 29 | int $anomalyType, |
||
| 30 | MapInterface|StarSystemMapInterface $map |
||
| 31 | ): AnomalyInterface { |
||
| 32 | 3 | $type = $this->anomalyTypeRepository->find($anomalyType); |
|
| 33 | |||
| 34 | 3 | if ($type === null) { |
|
| 35 | 1 | throw new RuntimeException(sprintf('no anomaly type defined for: %d', $anomalyType)); |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | $anomaly = $this->anomalyRepository->prototype(); |
|
| 39 | 2 | $anomaly->setAnomalyType($type); |
|
| 40 | 2 | $anomaly->setRemainingTicks($type->getLifespanInTicks()); |
|
| 41 | |||
| 42 | 2 | if ($map instanceof MapInterface) { |
|
| 43 | 1 | $anomaly->setMap($map); |
|
| 44 | } else { |
||
| 45 | 1 | $anomaly->setStarsystemMap($map); |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | $this->anomalyRepository->save($anomaly); |
|
| 49 | |||
| 50 | 2 | return $anomaly; |
|
| 51 | } |
||
| 53 |