city = new OpenWeatherMap\Util\City($weatherHistory['city_id'], (is_string($query)) ? $query : null, (isset($query['lon'])) ? $query['lon'] : null, (isset($query['lat'])) ? $query['lat'] : null, $country, $population); $this->calctime = $weatherHistory['calctime']; foreach ($weatherHistory['list'] as $history) { if (isset($history['rain'])) { $units = array_keys($history['rain']); } else { $units = array(0 => null); } $this->histories[] = new History($this->city, $history['weather'][0], array('now' => $history['main']['temp'], 'min' => $history['main']['temp_min'], 'max' => $history['main']['temp_max']), $history['main']['pressure'], $history['main']['humidity'], $history['clouds']['all'], isset($history['rain']) ? array('val' => $history['rain'][($units[0])], 'unit' => $units[0]) : null, $history['wind'], \DateTime::createFromFormat('U', $history['dt'])); } } /** * @internal */ public function rewind() { $this->position = 0; } /** * @internal */ public function current() { return $this->histories[$this->position]; } /** * @internal */ public function key() { return $this->position; } /** * @internal */ public function next() { ++$this->position; } /** * @internal */ public function valid() { return isset($this->histories[$this->position]); } }