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_Current class for abstracting
 4:  * access to current observations from WorldWeatherOnline.
 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_Current_Wwo class
16:  *
17:  * @author   Michael J Rubinsky <mrubinsk@horde.org>
18:  * @category Horde
19:  * @package  Service_Weather
20:  */
21:  class Horde_Service_Weather_Current_Wwo extends Horde_Service_Weather_Current_Base
22:  {
23:     protected $_map = array(
24:         'humidity' => 'humidity',
25:         'wind_direction' => 'winddir16Point',
26:         'wind_degrees' => 'winddirDegree'
27:     );
28: 
29:     public function __isset($property)
30:     {
31:         return !empty($this->_properties->$property);
32:     }
33: 
34:     public function __get($property)
35:     {
36:         // Maybe someday I can add a better $_map array with 'type' fields etc..
37:         // for now, just as easy to manually check for these exceptions.
38:         switch ($property) {
39:         case 'wind_gust':
40:         case 'dewpoint':
41:         case 'heat_index':
42:         case 'wind_chill':
43:         case 'pressure_trend':
44:         case 'logo_url':
45:             return null;
46: 
47:         case 'condition':
48:             return Horde_Service_Weather_Translation::t($this->_properties->weatherDesc[0]->value);
49: 
50:         case 'time':
51:             return new Horde_Date($this->_properties->observation_time);
52: 
53:         case 'temp':
54:             if ($this->_weather->units == Horde_Service_Weather::UNITS_STANDARD) {
55:                 return $this->_properties->temp_F;
56:             }
57:             return $this->_properties->temp_C;
58: 
59:         case 'wind_speed':
60:             if ($this->_weather->units == Horde_Service_Weather::UNITS_STANDARD) {
61:                 return $this->_properties->windspeedMiles;
62:             }
63:             return $this->_properties->windspeedKmph;
64: 
65:         case 'visibility':
66:             if ($this->_weather->units == Horde_Service_Weather::UNITS_METRIC) {
67:                 return $this->_properties->visibility;
68:             } else {
69:                 return round($this->_properties->visibility * Horde_Service_Weather::CONVERSION_KPH_TO_MPH);
70:             }
71: 
72:         case 'pressure':
73:             if ($this->_weather->units == Horde_Service_Weather::UNITS_STANDARD) {
74:                 return round($this->_properties->pressure * Horde_Service_Weather::CONVERSION_MB_TO_INCHES, 2);
75:             }
76:             return $this->_properties->pressure;
77: 
78:         case 'icon':
79:            return $this->_weather->iconMap[
80:                 str_replace('.png', '', basename($this->_properties->weatherIconUrl[0]->value))
81:             ];
82: 
83:         default:
84:             if (empty($this->_map[$property])) {
85:                 throw new Horde_Service_Weather_Exception_InvalidProperty();
86:             }
87:             return Horde_Service_Weather_Translation::t($this->_properties->{$this->_map[$property]});
88:         }
89:     }
90: 
91:  }
API documentation generated by ApiGen