cities = $cities; } public function addCity(City $city) { $this->cities[$city->getName() . $city->getLatitude() . $city->getLongitude()] = $city; } public function getCity($index) : City { return array_values($this->cities)[$index]; } public function getCities() : array { return $this->cities; } public function hasCity(City $city) : \bool { foreach ($this->cities as $c) { if ($c->equals($city)) { return true; } } return false; } public function count() : \int { return count($this->cities); } }