/** * Checks if ships are set correctly * * Validates coordinates of all ships' masts, checks the number, * sizes and shapes of the ships, and potential edge connections between them. * * @param array $ships Ships set by the player (Example: ['A1','B4','J10',...]) * @throws InvalidShipsException */ protected function validateShips(array $ships) { $shipsCollection = new CoordsCollection($ships); $shipsCollection->sort(); // required for validateEdgeConnections and validateShipsTypes $this->coordsManager->validateCoordsArray($shipsCollection->toArray()); $this->validateShipsLength($shipsCollection); $this->validateEdgeConnections($shipsCollection); $this->validateShipsTypes($shipsCollection); }
public function testToArray() { $coordsArray = ['A1', 'B2', 'J10', 'A10']; $coordsCollection = new CoordsCollection($coordsArray); $this->assertEquals($coordsArray, $coordsCollection->toArray()); }