本文整理汇总了PHP中Zend\Mail\Headers::removeHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Headers::removeHeader方法的具体用法?PHP Headers::removeHeader怎么用?PHP Headers::removeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Headers
的用法示例。
在下文中一共展示了Headers::removeHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemoveHeaderWithInstanceWillRemoveThatInstance
public function testRemoveHeaderWithInstanceWillRemoveThatInstance()
{
$headers = new Mail\Headers();
$headers->addHeaders(array(array('Foo' => 'foo'), array('Foo' => 'bar'), 'Baz' => 'baz'));
$header = $headers->get('foo')->current();
$this->assertEquals(3, $headers->count());
$headers->removeHeader($header);
$this->assertEquals(2, $headers->count());
$this->assertTrue($headers->has('foo'));
$this->assertNotSame($header, $headers->get('foo'));
}
示例2: testHeadersCanRemoveHeader
public function testHeadersCanRemoveHeader()
{
$headers = new Headers();
$headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz'));
$header = $headers->get('foo');
$this->assertEquals(2, $headers->count());
$headers->removeHeader($header);
$this->assertEquals(1, $headers->count());
$this->assertFalse($headers->get('foo'));
}
示例3: mergeDuplicateHeader
/**
* Merge duplicate header fields into single headers field.
* The headers must be AbstractAddressList.
*
* @param Headers $headerBag
* @param HeaderInterface|AbstractAddressList[] $headers
*/
private function mergeDuplicateHeader(Headers $headerBag, $headers)
{
if ($headers instanceof HeaderInterface) {
// all good
return;
}
// use first headers as base and collect addresses there
$header = $headers[0];
unset($headers[0]);
if (!$header instanceof AbstractAddressList) {
throw new DomainException(sprintf('Cannot grab address list from headers of type "%s"; not an AbstractAddressList implementation', get_class($header)));
}
$addressList = $header->getAddressList();
foreach ($headers as $h) {
$addressList->merge($h->getAddressList());
}
$headerBag->removeHeader($header->getFieldName());
$headerBag->addHeader($header);
}