setEncoding($encoding); } return $headers; } else { $header = new static($fieldName, $fieldValue); if ($decodedLine != $headerLine) { $header->setEncoding('UTF-8'); } return $header; } } /** * Cast multiple header objects to a single string header * * @param array $headers * @throws Exception\InvalidArgumentException * @return string */ public function toStringMultipleHeaders(array $headers) { $name = $this->getFieldName(); $values = array($this->getFieldValue(HeaderInterface::FORMAT_ENCODED)); foreach ($headers as $header) { if (!$header instanceof static) { throw new Exception\InvalidArgumentException( 'This method toStringMultipleHeaders was expecting an array of headers of the same type' ); } $values[] = $header->getFieldValue(HeaderInterface::FORMAT_ENCODED); } return $name . ': ' . implode(',', $values); } }