本文整理匯總了PHP中GuzzleHttp\Url::combine方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::combine方法的具體用法?PHP Url::combine怎麽用?PHP Url::combine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GuzzleHttp\Url
的用法示例。
在下文中一共展示了Url::combine方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildEndpoint
/**
* Builds the URI template for a REST based request.
*
* @param Operation $operation
* @param array $args
*
* @return array
*/
private function buildEndpoint(Operation $operation, array $args)
{
$varspecs = [];
if ($operation->getInput()->getType() !== 'list') {
// Create an associative array of varspecs used in expansions
foreach ($operation->getInput()->getMembers() as $name => $member) {
if ($member['location'] == 'uri') {
$varspecs[$member['locationName'] ?: $name] = isset($args[$name]) ? $args[$name] : null;
}
}
}
// Expand path place holders using Amazon's slightly different URI
// template syntax.
return $this->endpoint->combine(preg_replace_callback('/\\{([^\\}]+)\\}/', function (array $matches) use($varspecs) {
$isGreedy = substr($matches[1], -1, 1) == '+';
$k = $isGreedy ? substr($matches[1], 0, -1) : $matches[1];
if (!isset($varspecs[$k])) {
return '';
} elseif ($isGreedy) {
return str_replace('%2F', '/', rawurlencode($varspecs[$k]));
} else {
return rawurlencode($varspecs[$k]);
}
}, $operation['http']['requestUri']));
}