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 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_Current_Google class
16:  *
17:  * @author   Michael J Rubinsky <mrubinsk@horde.org>
18:  * @category Horde
19:  * @package  Service_Weather
20:  */
21: class Horde_Service_Weather_Current_Google extends Horde_Service_Weather_Current_Base
22: {
23:     protected $_map = array(
24:         'condition' => 'condition',
25:         'humidity' => 'humidity',
26:         'wind' => 'wind_condition',
27:         'icon_url' => 'icon',
28:     );
29: 
30:     public $time;
31: 
32:     /**
33:      * Accessor
34:      *
35:      * @param string $property  The  property to retrieve.
36:      *
37:      * @return mixed  The property value.
38:      */
39:     public function __get($property)
40:     {
41:         // Maybe someday I can add a better $_map array with 'type' fields etc..
42:         // for now, just as easy to manually check for these exceptions.
43:         switch ($property) {
44:         case 'pressure':
45:         case 'pressure_trend':
46:         case 'logo_url':
47:         case 'dewpoint':
48:         case 'wind_direction':
49:         case 'wind_degrees':
50:         case 'wind_speed':
51:         case 'wind_gust':
52:         case 'visibility':
53:         case 'heat_index':
54:         case 'wind_chill':
55:             return null;
56: 
57:         case 'temp':
58:             if ($this->_weather->units == Horde_Service_Weather::UNITS_STANDARD) {
59:                 return (float)$this->_properties->temp_f['data'];
60:             }
61:             return (float)$this->_properties->temp_c['data'];
62: 
63:         case 'icon':
64:            return $this->_weather->iconMap[basename((string)$this->_properties->icon['data'], '.gif')];
65: 
66: 
67:         default:
68:             if (empty($this->_map[$property])) {
69:                 throw new Horde_Service_Weather_Exception_InvalidProperty();
70:             }
71: 
72:             return (string)$this->_properties->{$this->_map[$property]}['data'];
73:         }
74:     }
75: 
76:  }
API documentation generated by ApiGen