1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 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:
37:
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: }