Skip to content

Commit

Permalink
Use _getStation()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Aug 13, 2016
1 parent 010009d commit 5e610be
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions framework/Service_Weather/lib/Horde/Service/Weather/Metar.php
Expand Up @@ -222,9 +222,13 @@ public function searchLocations(
$location,
$type = Horde_Service_Weather::SEARCHTYPE_STANDARD)
{
return new Horde_Service_Weather_Station(array(
'code' => $location
));
try {
return $this->_getStation($location);
} catch (Horde_Exception_NotFound $e) {
return new Horde_Service_Weather_Station(array(
'code' => $location
));
}
}

/**
Expand Down Expand Up @@ -319,6 +323,7 @@ protected function _getLocations()
*
* @return Horde_Service_Weather_Station The station object.
* @throws Horde_Service_Weather_Exception
* @throws Horde_Exception_NotFound
*/
protected function _getStation($code)
{
Expand All @@ -336,6 +341,10 @@ protected function _getStation($code)
throw new Horde_Service_Weather_Exception($e);
}

if (empty($result)) {
throw new Horde_Exception_NotFound();
}

return new Horde_Service_Weather_Station(array(
'name' => $result['name'],
'code' => $code,
Expand Down

0 comments on commit 5e610be

Please sign in to comment.