public function QueryString::__toString

Convert the query string parameters to a query string string

Return value

string

File

drupal/core/vendor/guzzle/http/Guzzle/Http/QueryString.php, line 81

Class

QueryString
Query string object to handle managing query string parameters and aggregating those parameters together as a string.

Namespace

Guzzle\Http

Code

public function __toString() {
  if (empty($this->data)) {
    return '';
  }
  $queryString = $this->prefix;
  $firstValue = true;
  foreach ($this
    ->encodeData($this->data) as $name => $value) {
    $value = $value === null ? array(
      '',
    ) : (array) $value;
    foreach ($value as $v) {
      if ($firstValue) {
        $firstValue = false;
      }
      else {
        $queryString .= $this->fieldSeparator;
      }
      $queryString .= $name;
      if ($v !== self::BLANK) {
        $queryString .= $this->valueSeparator . $v;
      }
    }
  }
  return $queryString;
}