Set a tokenized header on the request that implodes a Collection of data into a string separated by a token.
string $header Header to set:
array|Collection $data Header data:
string $token Token delimiter:
InvalidArgumentException if data is not an array or Collection
Overrides MessageInterface::setTokenizedHeader
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));
}