Updated exceptions to compensate for namespace

This commit is contained in:
Josh Sherman 2014-05-14 14:14:22 -04:00
parent e8d8689ce3
commit 204f0151c1

View file

@ -90,7 +90,7 @@ class GooglePlaces
if (!in_array($value, array('json', 'xml'))) if (!in_array($value, array('json', 'xml')))
{ {
throw new Exception('Invalid output, please specify either "json" or "xml".'); throw new \Exception('Invalid output, please specify either "json" or "xml".');
} }
break; break;
@ -100,7 +100,7 @@ class GooglePlaces
if (!in_array($value, array('prominence', 'distance'))) if (!in_array($value, array('prominence', 'distance')))
{ {
throw new Exception('Invalid rank by value, please specify either "prominence" or "distance".'); throw new \Exception('Invalid rank by value, please specify either "prominence" or "distance".');
} }
break; break;
@ -133,7 +133,7 @@ class GooglePlaces
case 'nearbysearch': case 'nearbysearch':
if (!isset($parameters['location'])) if (!isset($parameters['location']))
{ {
throw new Exception('You must specify a location before calling nearbysearch().'); throw new \Exception('You must specify a location before calling nearbysearch().');
} }
elseif (isset($parameters['rankby'])) elseif (isset($parameters['rankby']))
{ {
@ -142,7 +142,7 @@ class GooglePlaces
case 'distance': case 'distance':
if (!isset($parameters['keyword']) && !isset($parameters['name']) && !isset($parameters['types'])) if (!isset($parameters['keyword']) && !isset($parameters['name']) && !isset($parameters['types']))
{ {
throw new Exception('You much specify at least one of the following: keyword, name, types.'); throw new \Exception('You much specify at least one of the following: keyword, name, types.');
} }
if (isset($parameters['radius'])) if (isset($parameters['radius']))
@ -154,7 +154,7 @@ class GooglePlaces
case 'prominence': case 'prominence':
if (!isset($parameters['radius'])) if (!isset($parameters['radius']))
{ {
throw new Exception('You must specify a radius.'); throw new \Exception('You must specify a radius.');
} }
break; break;
} }
@ -165,15 +165,15 @@ class GooglePlaces
case 'radarsearch': case 'radarsearch':
if (!isset($parameters['location'])) if (!isset($parameters['location']))
{ {
throw new Exception('You must specify a location before calling nearbysearch().'); throw new \Exception('You must specify a location before calling nearbysearch().');
} }
elseif (!isset($parameters['radius'])) elseif (!isset($parameters['radius']))
{ {
throw new Exception('You must specify a radius.'); throw new \Exception('You must specify a radius.');
} }
elseif (empty($parameters['keyword']) && empty($parameters['name']) && empty($parameters['types'])) elseif (empty($parameters['keyword']) && empty($parameters['name']) && empty($parameters['types']))
{ {
throw new Exception('A Radar Search request must include at least one of keyword, name, or types.'); throw new \Exception('A Radar Search request must include at least one of keyword, name, or types.');
} }
if (isset($parameters['rankby'])) if (isset($parameters['rankby']))
@ -186,7 +186,7 @@ class GooglePlaces
case 'details': case 'details':
if (!isset($parameters['reference'])) if (!isset($parameters['reference']))
{ {
throw new Exception('You must specify a reference before calling details().'); throw new \Exception('You must specify a reference before calling details().');
} }
if (isset($parameters['rankby'])) if (isset($parameters['rankby']))
@ -239,7 +239,7 @@ class GooglePlaces
if ($error = curl_error($curl)) if ($error = curl_error($curl))
{ {
throw new Exception('CURL Error: ' . $error); throw new \Exception('CURL Error: ' . $error);
} }
if ($this->output == 'json') if ($this->output == 'json')
@ -248,12 +248,12 @@ class GooglePlaces
if ($response === null) if ($response === null)
{ {
throw new Exception('The returned JSON was malformed or nonexistent.'); throw new \Exception('The returned JSON was malformed or nonexistent.');
} }
} }
else else
{ {
throw new Exception('XML is terrible, don\'t use it, ever.'); throw new \Exception('XML is terrible, don\'t use it, ever.');
} }
curl_close($curl); curl_close($curl);
@ -286,7 +286,7 @@ class GooglePlaces
{ {
if (($this->radius % $this->subradius) || ($this->subradius < 200) || (($this->radius / $this->subradius) % 2)) if (($this->radius % $this->subradius) || ($this->subradius < 200) || (($this->radius / $this->subradius) % 2))
{ {
throw new Exception('Subradius should divide evenly into radius. Also, subradius should be 200 meters or so. (ex: 2000/200 = 10x10 grid. NOT 2000/33 = 60.6x60.6 grid. NOT 2000/16 = 125x125 grid)'); throw new \Exception('Subradius should divide evenly into radius. Also, subradius should be 200 meters or so. (ex: 2000/200 = 10x10 grid. NOT 2000/33 = 60.6x60.6 grid. NOT 2000/16 = 125x125 grid)');
} }
$center = explode(',', $this->location); $center = explode(',', $this->location);