1: <?php
2: /**
3: * This file contains the Horde_Service_Weather_Forecast class for abstracting
4: * access to forecast data from Google.
5: *
6: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
7: *
8: * @author Michael J Rubinsky <mrubinsk@horde.org>
9: * @license http://www.horde.org/licenses/bsd BSD
10: * @category Horde
11: * @package Service_Weather
12: */
13:
14: /**
15: * Horde_Service_Weather_Forecast_Google
16: *
17: * @author Michael J Rubinsky <mrubinsk@horde.org>
18: * @category Horde
19: * @package Service_Weather
20: */
21: class Horde_Service_Weather_Forecast_Google extends Horde_Service_Weather_Forecast_Base
22: {
23:
24: public $fields = array();
25:
26: /**
27: * Const'r
28: *
29: * @see Horde_Service_Weather_Forecast_Base#__construct
30: */
31: public function __construct(
32: $properties,
33: Horde_Service_Weather_Base $weather,
34: $type = Horde_Service_Weather::FORECAST_TYPE_STANDARD)
35: {
36: parent::__construct($properties, $weather, $type);
37: $this->_parseStd();
38: }
39:
40: public function getForecastTime()
41: {
42: return new Horde_Date($this->weather->getStation()->time);
43: }
44:
45: /**
46: * Parse standard forecast data.
47: *
48: * @throws Horde_Service_Weather_Exception
49: */
50: protected function _parseStd()
51: {
52: if (empty($this->_properties)) {
53: throw new Horde_Service_Weather_Exception('No forecast data to parse.');
54: }
55: $day = 0;
56: foreach ($this->_properties as $item) {
57: foreach ($item->forecast_conditions as $period) {
58: $this->_periods[] = new Horde_Service_Weather_Period_Google($period, $this, $day++);
59: }
60: }
61: }
62:
63: }