public function Url::combine

Combine the URL with another URL. Parts specified in the passed URL will supersede parts in the current URL.

Parameters

string $url Relative URL to combine with:

Return value

Url

Throws

InvalidArgumentException

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Url.php, line 493

Class

Url
Parses and generates URLs based on URL parts. In favor of performance, URL parts are not validated.

Namespace

Guzzle\Http

Code

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;
}