/** * Return true if the points of the given ship are all hit * * @param Ship $ship * @return bool */ public function isShipSunk(Ship $ship) { $hitsOnShip = 0; foreach ($this->shots as $shot) { if ($ship->hasPoint($shot)) { if (++$hitsOnShip >= $ship->getSize()) { return true; } } } return false; }