addOption( 'cityName', 'c', InputOption::VALUE_REQUIRED, 'City name' ); } public function doExecute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('cityName') !== null) { $latLon = $this->geoPointResolverService->getGeoPointFromCityName($input->getOption('cityName')); if ($latLon === null) { $this->logger->error( "Invalid city name {cityName}", [ 'cityName' => $input->getOption('cityName'), ] ); return self::INVALID; } $cities = [$latLon]; } else { $cities = $this->geoPointResolverService->getCitiesWithPoints(); } foreach ($cities as $city) { $this->fetchDataForCity($city); } return self::SUCCESS; } protected function fetchDataForCity(GEOPoint $geoPoint): void { $fromDate = new \DateTime(); $toDate = new \DateTime(); $toDate->add(new \DateInterval($this->forecastForDays)); $weather = $this->weatherProvider->fetchWeather( $geoPoint, WeatherInterval::DAILY, $fromDate, $toDate ); // handle granularity $granularityService = $this->weatherGranularityFactory->createWeatherGranularityByInterval(WeatherInterval::DAILY); $granularForCastByDay = $granularityService->calculateFromMultipleRecords($weather); // store data $this->weatherStorageStore->storeWeatherForPointByDay($geoPoint, $granularForCastByDay); } }