acymailing
/
vendor
/
zbateson
/
mail-mime-parser
/
src
/
Parser
/
Proxy
/
ParserUUEncodedPartProxyFactory.php
ParserUUEncodedPartProxyFactory.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress trunk, at vendor/zbateson/mail-mime-parser/src/Parser/Proxy/ParserUUEncodedPartProxyFactory.php
| 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\Parser\Proxy; |
| 9 | |
| 10 | use ZBateson\MailMimeParser\Message\UUEncodedPart; |
| 11 | use ZBateson\MailMimeParser\Parser\IParser; |
| 12 | use ZBateson\MailMimeParser\Parser\Part\ParserPartStreamContainerFactory; |
| 13 | use ZBateson\MailMimeParser\Parser\PartBuilder; |
| 14 | use ZBateson\MailMimeParser\Stream\StreamFactory; |
| 15 | |
| 16 | /** |
| 17 | * Responsible for creating proxied IUUEncodedPart instances wrapped in a |
| 18 | * ParserUUEncodedPartProxy and used by NonMimeParser. |
| 19 | * |
| 20 | * @author Zaahid Bateson |
| 21 | */ |
| 22 | class ParserUUEncodedPartProxyFactory extends ParserPartProxyFactory |
| 23 | { |
| 24 | /** |
| 25 | * @var StreamFactory the StreamFactory instance |
| 26 | */ |
| 27 | protected $streamFactory; |
| 28 | |
| 29 | /** |
| 30 | * @var ParserPartStreamContainerFactory |
| 31 | */ |
| 32 | protected $parserPartStreamContainerFactory; |
| 33 | |
| 34 | public function __construct(StreamFactory $sdf, ParserPartStreamContainerFactory $parserPartStreamContainerFactory) |
| 35 | { |
| 36 | $this->streamFactory = $sdf; |
| 37 | $this->parserPartStreamContainerFactory = $parserPartStreamContainerFactory; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Constructs a new ParserUUEncodedPartProxy wrapping an IUUEncoded object. |
| 42 | * |
| 43 | * @return ParserPartProxy |
| 44 | */ |
| 45 | public function newInstance(PartBuilder $partBuilder, IParser $parser) |
| 46 | { |
| 47 | $parserProxy = new ParserUUEncodedPartProxy($partBuilder, $parser); |
| 48 | $streamContainer = $this->parserPartStreamContainerFactory->newInstance($parserProxy); |
| 49 | |
| 50 | $part = new UUEncodedPart( |
| 51 | $parserProxy->getUnixFileMode(), |
| 52 | $parserProxy->getFileName(), |
| 53 | $partBuilder->getParent()->getPart(), |
| 54 | $streamContainer |
| 55 | ); |
| 56 | $parserProxy->setPart($part); |
| 57 | |
| 58 | $streamContainer->setStream($this->streamFactory->newMessagePartStream($part)); |
| 59 | $part->attach($streamContainer); |
| 60 | return $parserProxy; |
| 61 | } |
| 62 | } |
| 63 |