| Total Complexity | 11 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class Location |
||
| 14 | { |
||
| 15 | private MapInterface|StarSystemMapInterface $location; |
||
| 16 | |||
| 17 | public function __construct(?MapInterface $map, ?StarSystemMapInterface $sysMap) |
||
| 18 | { |
||
| 19 | if ( |
||
| 20 | $map === null && $sysMap === null |
||
|
|
|||
| 21 | || $map !== null && $sysMap !== null |
||
| 22 | ) { |
||
| 23 | throw new InvalidArgumentException('Either map or systemMap has to be filled'); |
||
| 24 | } |
||
| 25 | |||
| 26 | $this->location = $map !== null ? $map : $sysMap; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return Collection<int, ShipInterface> |
||
| 31 | */ |
||
| 32 | public function getShips(): Collection |
||
| 33 | { |
||
| 34 | return $this->location->getShips(); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function getSectorString(): string |
||
| 38 | { |
||
| 39 | return $this->location->getSectorString(); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function hasAnomaly(int $anomalyType): bool |
||
| 51 | } |
||
| 52 | } |
||
| 53 |