Added AuthServer::getParam() function to reduce repetitive code

This commit is contained in:
Alex Bilbie
2013-02-13 18:25:10 +00:00
parent 0f4546db47
commit 1e2d2b3d25
3 changed files with 25 additions and 22 deletions

View File

@@ -374,4 +374,24 @@ class AuthServer
return self::$grantTypes[$grantType];
}
/**
* Get a parameter from passed input parameters or the Request class
* @param string|array $param Requried parameter
* @param string $method Get/put/post/delete
* @param array $inputParams Passed input parameters
* @return mixed 'Null' if parameter is missing
*/
public static function getParam($param = '', $method = 'get', $inputParams = array())
{
if (is_string($param)) {
return (isset($inputParams[$param])) ? $inputParams['client_id'] : self::getRequest()->{$method}($param);
} else {
$response = array();
foreach ($param as $p) {
$response[$p] = self::getParam($p, $method, $inputParams);
}
return $response;
}
}
}