public function AbstractMessage::setTokenizedHeader

Set a tokenized header on the request that implodes a Collection of data into a string separated by a token.

Parameters

string $header Header to set:

array|Collection $data Header data:

string $token Token delimiter:

Return value

MessageInterface

Throws

InvalidArgumentException if data is not an array or Collection

Overrides MessageInterface::setTokenizedHeader

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/AbstractMessage.php, line 218

Class

AbstractMessage
Abstract HTTP request/response message

Namespace

Guzzle\Http\Message

Code

public function setTokenizedHeader($header, $data, $token = ';') {
  if (!$data instanceof Collection && !is_array($data)) {
    throw new InvalidArgumentException('Data must be a Collection or array');
  }
  $values = array();
  foreach ($data as $key => $value) {
    foreach ((array) $value as $v) {
      $values[] = is_int($key) ? $v : $key . '=' . $v;
    }
  }
  return $this
    ->setHeader($header, implode($token, $values));
}