commit
39e146c40e
1 changed files with 23 additions and 3 deletions
|
@ -38,7 +38,16 @@ class GooglePlaces
|
||||||
$url = implode('/', array($this->base_url, $method, $this->output));
|
$url = implode('/', array($this->base_url, $method, $this->output));
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
// Loops through all of our variables to make a parameter list
|
$parameters = $this->parameterBuilder($parameters);
|
||||||
|
$parameters = $this->methodChecker($parameters, $method);
|
||||||
|
|
||||||
|
return $this->queryGoogle($url, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loops through all of our variables to make a parameter list
|
||||||
|
*/
|
||||||
|
private function parameterBuilder($parameters){
|
||||||
foreach (get_object_vars($this) as $variable => $value)
|
foreach (get_object_vars($this) as $variable => $value)
|
||||||
{
|
{
|
||||||
// Except these variables
|
// Except these variables
|
||||||
|
@ -98,7 +107,14 @@ class GooglePlaces
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* takes the parameters and method to throw exceptions or modify parameters as needed
|
||||||
|
* @todo Method to sanity check passed types
|
||||||
|
*/
|
||||||
|
private function methodChecker($parameters, $method){
|
||||||
if (!isset($parameters['pagetoken']))
|
if (!isset($parameters['pagetoken']))
|
||||||
{
|
{
|
||||||
switch ($method)
|
switch ($method)
|
||||||
|
@ -172,7 +188,13 @@ class GooglePlaces
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits request via curl, sets the response, then returns the response
|
||||||
|
*/
|
||||||
|
private function queryGoogle($url, $parameters){
|
||||||
if ($this->pagetoken !== null)
|
if ($this->pagetoken !== null)
|
||||||
{
|
{
|
||||||
$parameters['pagetoken'] = $this->pagetoken;
|
$parameters['pagetoken'] = $this->pagetoken;
|
||||||
|
@ -230,8 +252,6 @@ class GooglePlaces
|
||||||
|
|
||||||
return $this->response;
|
return $this->response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo Method to sanity check passed types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue