Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
joannasese committed May 18, 2020
1 parent 79df4fd commit df49022
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/recurly/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,13 @@ protected static function _delete($uri, $client = null)
*/
public static function _safeUri(...$params) {
$uri = '';
// throws error if param is an empty string
foreach($params as $param) {
// throws error if param is an empty string
if (empty(trim($param))) {
throw new Recurly_Error("Resource code cannot be an empty value");
}
}
// first and every other following param is a resource index PATH, e.g. 'accounts'
for ($i = 0; $i <= count($params); $i+=2) {
if (isset($params[$i])){
$path = '/' . $params[$i];
$uri .= $path;
}
// resource code follows resource index, e.g. 'accounts/account_code'
if (isset($params[$i+1])){
$code = '/' . rawurlencode($params[$i+1]);
$uri .= $code;
}
$path = '/' . rawurlencode($param);
$uri .= $path;
}
return $uri;
}
Expand Down

0 comments on commit df49022

Please sign in to comment.