setRawHeader('New-Header', 'value'); * echo $part->getHeaderValue('New-Header'); // 'value' * * $part->setRawHeader('New-Header', 'second', 4); * echo is_null($part->getHeader('New-Header', 4)); // '1' (true) * echo $part->getHeader('New-Header', 1) * ->getValue(); // 'second' * ``` * * A new {@see \ZBateson\MailMimeParser\Header\IHeader} object is created * from the passed value. No processing on the passed string is performed, * and so the passed name and value must be formatted correctly according to * related RFCs. In particular, be careful to encode non-ascii data, to * keep lines under 998 characters in length, and to follow any special * formatting required for the type of header. * * @param string $name The name of the new header, e.g. 'Content-Type'. * @param ?string $value The raw value of the new header. * @param int $offset An optional offset, defaulting to '0' and therefore * overriding the first header of the given $name if one exists. * * @see IMimePart::addRawHeader() Adds a header to the part regardless of * whether or not a header with that name already exists. * @see IMimePart::removeHeader() Removes all headers on this part with the * passed name * @see IMimePart::removeSingleHeader() Removes a single header if more than * one with the passed name exists. */ public function setRawHeader(string $name, ?string $value, int $offset = 0); /** * Adds a header with the given $name and $value. * * Note: If a header with the passed name already exists, a new header is * created with the same name. This should only be used when that is * intentional - in most cases {@see IMimePart::setRawHeader()} should be * called instead. * * A new {@see \ZBateson\MailMimeParser\Header\IHeader} object is created * from the passed value. No processing on the passed string is performed, * and so the passed name and value must be formatted correctly according to * related RFCs. In particular, be careful to encode non-ascii data, to * keep lines under 998 characters in length, and to follow any special * formatting required for the type of header. * * @param string $name The name of the header * @param string $value The raw value of the header. * * @see IMimePart::removeSingleHeader() Removes a single header if more than * one with the passed name exists. * @see IMimePart::setRawHeader() Sets a header, potentially overwriting one * if it already exists. * @see IMimePart::removeHeader() Removes all headers on this part with the * passed name */ public function addRawHeader(string $name, string $value); /** * Removes all headers from this part with the passed name. * * @param string $name The name of the header(s) to remove. * * @see IMimePart::setRawHeader() Sets a header, potentially overwriting one * if it already exists. * @see IMimePart::removeSingleHeader() Removes a single header if more than * one with the passed name exists. * @see IMimePart::addRawHeader() Adds a header to the part regardless of * whether or not a header with that name already exists. */ public function removeHeader(string $name); /** * Removes a single header with the passed name (in cases where more than * one may exist, and others should be preserved). * * @param string $name The name of the header to remove * @param int $offset Optional offset of the header to remove (defaults to * 0 -- the first header). * * @see IMimePart::removeHeader() Removes all headers on this part with the * passed name * @see IMimePart::addRawHeader() Adds a header to the part regardless of * whether or not a header with that name already exists. * @see IMimePart::setRawHeader() Sets a header, potentially overwriting one * if it already exists. */ public function removeSingleHeader(string $name, int $offset = 0); }