Skip to content

Commit

Permalink
Throw exception if we don't have a valid path.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Aug 13, 2016
1 parent c399725 commit 53447ad
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public function getCurrentConditions($location)
$pathinfo = parse_url($endpoint);
if (empty($pathinfo['scheme']) && file_exists($endpoint)) {
$pathinfo['scheme'] = 'file';
} elseif (empty($pathinfo['scheme'])) {
throw new Horde_Service_Weather_Exception('Invalid path to METAR data.');
}
switch ($pathinfo['scheme']) {
case 'http':
Expand Down Expand Up @@ -179,14 +181,16 @@ public function getForecast(
$pathinfo = parse_url($endpoint);
if (empty($pathinfo['scheme']) && file_exists($endpoint)) {
$pathinfo['scheme'] = 'file';
} elseif (empty($pathinfo['scheme'])) {
throw new Horde_Service_Weather_Exception('Invalid path to TAF data.');
}
switch ($pathinfo['scheme']) {
case 'http':
$url = sprintf('%s/%s.TXT', $this->_taf_path, $location);
$data = $this->_makeRequest($url);
break;
case 'file':
$data = file_get_contents(realpath($pathinfo['path']));
$data = file_get_contents(realpath($pathinfo['path']));
break;
}
if (empty($data)) {
Expand Down

0 comments on commit 53447ad

Please sign in to comment.