本文整理匯總了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);
}