本文整理汇总了PHP中GuzzleHttp\Url::getPort方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getPort方法的具体用法?PHP Url::getPort怎么用?PHP Url::getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Url
的用法示例。
在下文中一共展示了Url::getPort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseConnections
protected function parseConnections($options, $defaultHost, $defaultPort)
{
if (isset($options['host']) || isset($options['port'])) {
$options['connections'][] = $options;
}
/** @var Url[] $toParse */
$toParse = [];
if (isset($options['connections'])) {
foreach ((array) $options['connections'] as $alias => $conn) {
if (is_string($conn)) {
$conn = ['host' => $conn];
}
$scheme = isset($conn['scheme']) ? $conn['scheme'] : 'tcp';
$host = isset($conn['host']) ? $conn['host'] : $defaultHost;
$url = new Url($scheme, $host);
$url->setPort(isset($conn['port']) ? $conn['port'] : $defaultPort);
if (isset($conn['path'])) {
$url->setPath($conn['path']);
}
if (isset($conn['password'])) {
$url->setPassword($conn['password']);
}
$url->getQuery()->replace($conn);
$toParse[] = $url;
}
} elseif (isset($options['save_path'])) {
foreach (explode(',', $options['save_path']) as $conn) {
$toParse[] = Url::fromString($conn);
}
}
$connections = [];
foreach ($toParse as $url) {
$connections[] = ['scheme' => $url->getScheme(), 'host' => $url->getHost(), 'port' => $url->getPort(), 'path' => $url->getPath(), 'alias' => $url->getQuery()->get('alias'), 'prefix' => $url->getQuery()->get('prefix'), 'password' => $url->getPassword(), 'database' => $url->getQuery()->get('database'), 'persistent' => $url->getQuery()->get('persistent'), 'weight' => $url->getQuery()->get('weight'), 'timeout' => $url->getQuery()->get('timeout')];
}
return $connections;
}