Combine the URL with another URL. Parts specified in the passed URL will supersede parts in the current URL.
string $url Relative URL to combine with:
public function combine($url) {
$absolutePath = $url[0] == '/';
$url = self::factory($url);
if ($buffer = $url
->getScheme()) {
$this->scheme = $buffer;
}
if ($buffer = $url
->getHost()) {
$this->host = $buffer;
}
if ($buffer = $url
->getPort()) {
$this->port = $buffer;
}
if ($buffer = $url
->getUsername()) {
$this->username = $buffer;
}
if ($buffer = $url
->getPassword()) {
$this->password = $buffer;
}
if ($buffer = $url
->getFragment()) {
$this->fragment = $buffer;
}
if ($absolutePath) {
// Replace the current URL and query if set
if ($buffer = $url
->getPath()) {
$this->path = $buffer;
}
if (count($url
->getQuery())) {
$this->query = clone $url
->getQuery();
}
}
else {
// Append to the current path and query string
if ($buffer = $url
->getPath()) {
$this
->addPath($buffer);
}
if ($buffer = $url
->getQuery()) {
$this->query
->merge($buffer);
}
}
return $this;
}