Overview

Packages

  • Service
    • Weather

Classes

  • Horde_Service_Weather
  • Horde_Service_Weather_Base
  • Horde_Service_Weather_Current_Base
  • Horde_Service_Weather_Current_Google
  • Horde_Service_Weather_Current_WeatherUnderground
  • Horde_Service_Weather_Current_Wwo
  • Horde_Service_Weather_Exception
  • Horde_Service_Weather_Exception_InvalidProperty
  • Horde_Service_Weather_Forecast_Base
  • Horde_Service_Weather_Forecast_Google
  • Horde_Service_Weather_Forecast_WeatherUnderground
  • Horde_Service_Weather_Forecast_Wwo
  • Horde_Service_Weather_Google
  • Horde_Service_Weather_Period_Base
  • Horde_Service_Weather_Period_Google
  • Horde_Service_Weather_Period_WeatherUnderground
  • Horde_Service_Weather_Period_Wwo
  • Horde_Service_Weather_Station
  • Horde_Service_Weather_Translation
  • Horde_Service_Weather_WeatherUnderground
  • Horde_Service_Weather_Wwo
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * This file contains the Horde_Service_Weather_Period class for abstracting
  4:  * access to a single forecast period from Wwo.
  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_Period_Wwo
 16:  *
 17:  * @author   Michael J Rubinsky <mrubinsk@horde.org>
 18:  * @category Horde
 19:  * @package  Service_Weather
 20:  */
 21: class Horde_Service_Weather_Period_Wwo extends Horde_Service_Weather_Period_Base
 22: {
 23:     /**
 24:      * Property Map
 25:      *
 26:      * @TODO Figure out what to do with the 'skyicon' value - which is sometimes
 27:      *       different than the icon and icon_url. Also, should add a icon set
 28:      *       property to allow using other icon sets e.g., {icon_set_url}/{icon}.gif
 29:      *
 30:      * @var array
 31:      */
 32:      protected $_map = array();
 33: 
 34:     /**
 35:      * Accessor so we can lazy-parse the results.
 36:      *
 37:      * @param string $property  The property name.
 38:      *
 39:      * @return mixed  The value of requested property
 40:      * @throws Horde_Service_Weather_Exception_InvalidProperty
 41:      */
 42:     public function __get($property)
 43:     {
 44:         switch ($property) {
 45:         case 'humidity':
 46:         case 'precipitation_percent':
 47:         case 'wind_gust':
 48:         case 'snow_total':
 49:         case 'rain_total':
 50:             return false;
 51: 
 52:         case 'conditions':
 53:             return Horde_Service_Weather_Translation::t($this->_properties->weatherDesc[0]->value);
 54: 
 55:         case 'icon_url':
 56:             return $this->_properties->weatherIconUrl[0]->value;
 57: 
 58:         case 'is_pm':
 59:             return false;
 60: 
 61:         case 'hour':
 62:             return false;
 63: 
 64:         case 'date':
 65:             return new Horde_Date($this->_properties->date);
 66: 
 67:         case 'high':
 68:             if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
 69:                 return $this->_properties->tempMaxF ;
 70:             }
 71:             return $this->_properties->tempMaxC;
 72: 
 73:         case 'low':
 74:             if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
 75:                 return $this->_properties->tempMinF;
 76:             }
 77:             return $this->_properties->tempMinC;
 78: 
 79:         case 'icon':
 80:             return $this->_forecast->weather->iconMap[
 81:                 str_replace('.png', '', basename($this->_properties->weatherIconUrl[0]->value))
 82:             ];
 83: 
 84:         case 'wind_direction':
 85:             return $this->_properties->winddirection;
 86: 
 87:         case 'wind_degrees':
 88:             return $this->_properties->winddirDegree;
 89: 
 90:         case 'wind_speed':
 91:            if ($this->_forecast->weather->units == Horde_Service_Weather::UNITS_STANDARD) {
 92:                return $this->_properties->windspeedMiles;
 93:            }
 94:            return $this->_properties->windspeedKmph;
 95: 
 96:         default:
 97:             throw new Horde_Service_Weather_Exception_InvalidProperty('This provider does not support the "' . $property . '" property');
 98:         }
 99:     }
100: 
101: }
API documentation generated by ApiGen