PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / trunk
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress vtrunk
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / vendor / zbateson / mail-mime-parser / src / Header / MimeEncodedHeader.php

MimeEncodedHeader.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress trunk, at vendor/zbateson/mail-mime-parser/src/Header/MimeEncodedHeader.php

55 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file is part of the ZBateson\MailMimeParser project.
4 *
5 * @license http://opensource.org/licenses/bsd-license.php BSD
6 */
7
8 namespace ZBateson\MailMimeParser\Header;
9
10 use ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer;
11 use ZBateson\MailMimeParser\Header\Consumer\ConsumerService;
12 use ZBateson\MailMimeParser\Header\Part\MimeLiteralPart;
13 use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory;
14
15 /**
16 * Allows a header to be mime-encoded and be decoded with a consumer after
17 * decoding.
18 *
19 * @author Zaahid Bateson
20 */
21 abstract class MimeEncodedHeader extends AbstractHeader
22 {
23 /**
24 * @var MimeLiteralPartFactory for mime decoding.
25 */
26 protected $mimeLiteralPartFactory;
27
28 public function __construct(
29 MimeLiteralPartFactory $mimeLiteralPartFactory,
30 ConsumerService $consumerService,
31 $name,
32 $value
33 ) {
34 $this->mimeLiteralPartFactory = $mimeLiteralPartFactory;
35 parent::__construct($consumerService, $name, $value);
36 }
37
38 /**
39 * Mime-decodes any mime-encoded parts prior to invoking the passed
40 * consumer.
41 *
42 * @return static
43 */
44 protected function setParseHeaderValue(AbstractConsumer $consumer)
45 {
46 $value = $this->rawValue;
47 $matchp = '~' . MimeLiteralPart::MIME_PART_PATTERN . '~';
48 $value = \preg_replace_callback($matchp, function($matches) {
49 return $this->mimeLiteralPartFactory->newInstance($matches[0]);
50 }, $value);
51 $this->parts = $consumer($value);
52 return $this;
53 }
54 }
55