public function get($uri, $args = [], $module = null)
{
if (is_array($uri)) {
$tmp = $uri;
$uri = $tmp[0];
if (isset($tmp[1])) {
$args = $tmp[1];
}
if (isset($tmp[2])) {
$module = $tmp[2];
}
}
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
if (is_string($args)) {
$module = $args;
$args = [];
}
if (!isset($this->_baseUrls[$module])) {
if (isset($this->_baseUrls[ucfirst($module)])) {
throw new UrlException('module name is case-sensitive: `:module`', ['module' => $module]);
} else {
throw new UrlException('`:module` is not exists', ['module' => $module]);
}
}
if ($uri === '' || $uri[0] !== '/') {
$baseUrl = $this->_baseUrls[$module];
$strUrl = (strpos($baseUrl, '://') ? parse_url($baseUrl, PHP_URL_PATH) : $baseUrl) . '/' . $uri;
} else {
$strUrl = $this->_baseUrls[$module] . $uri;
}
if (Text::contains($strUrl, ':')) {
foreach ($args as $k => $v) {
$count = 0;
$strUrl = str_replace(':' . $k, $v, $strUrl, $count);
if ($count !== 0) {
unset($args[$k]);
}
}
}
if (count($args) !== 0) {
$strUrl .= (Text::contains($strUrl, '?') ? '&' : '?') . http_build_query($args);
}
return $strUrl;
}