mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +02:00
N°4307 Replace SwiftMailer with Laminas-mail
This commit is contained in:
55
lib/laminas/laminas-mail/src/Header/GenericMultiHeader.php
Normal file
55
lib/laminas/laminas-mail/src/Header/GenericMultiHeader.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-mail for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-mail/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-mail/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
|
||||
namespace Laminas\Mail\Header;
|
||||
|
||||
/**
|
||||
* Generic class for Headers with multiple occurs in the same message
|
||||
*/
|
||||
class GenericMultiHeader extends GenericHeader implements MultipleHeadersInterface
|
||||
{
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
|
||||
$fieldValue = HeaderWrap::mimeDecodeValue($fieldValue);
|
||||
|
||||
if (strpos($fieldValue, ',')) {
|
||||
$headers = [];
|
||||
foreach (explode(',', $fieldValue) as $multiValue) {
|
||||
$headers[] = new static($fieldName, $multiValue);
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
return new static($fieldName, $fieldValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = [$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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user