/** * @param CoordsCollection $shipsCollection * @throws InvalidShipsException */ private function validateShipsLength(CoordsCollection $shipsCollection) { // if the number of masts is correct $mastCount = $shipsCollection->count(); if ($mastCount !== self::TOTAL_LENGTH) { throw new InvalidShipsException(sprintf('Number of ships\' masts is incorrect: %d (expected: %d)', $mastCount, self::TOTAL_LENGTH)); } }
public function testCount() { $coordsArray = ['A1', 'J10', 'J1', 'B2', 'A10']; $coordsCollection = new CoordsCollection($coordsArray); $this->assertEquals(count($coordsArray), $coordsCollection->count()); }