Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/demo.cartinsight.co/vendor/zbateson/mail-mime-parser/src/Parser/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/demo.cartinsight.co/vendor/zbateson/mail-mime-parser/src/Parser/ParserManager.php
<?php
/**
 * This file is part of the ZBateson\MailMimeParser project.
 *
 * @license http://opensource.org/licenses/bsd-license.php BSD
 */

namespace ZBateson\MailMimeParser\Parser;

use ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy;

/**
 * Manages a prioritized list of IParser objects for parsing messages and parts
 * and creating proxied parts.
 *
 * The default ParserManager sets up a MimeParser in priority 0, and a
 * NonMimeParser in priority 1.
 *
 * @author Zaahid Bateson
 */
class ParserManager
{
    /**
     * @var IParser[] List of parsers in order of priority (0 is highest
     *      priority).
     */
    protected $parsers = [];

    public function __construct(MimeParser $mimeParser, NonMimeParser $nonMimeParser)
    {
        $this->setParsers([$mimeParser, $nonMimeParser]);
    }

    /**
     * Overrides the internal prioritized list of parses with the passed list,
     * calling $parser->setParserManager($this) on each one.
     *
     */
    public function setParsers(array $parsers) : self
    {
        foreach ($parsers as $parser) {
            $parser->setParserManager($this);
        }
        $this->parsers = $parsers;
        return $this;
    }

    /**
     * Adds an IParser at the highest priority (up front), calling
     * $parser->setParserManager($this) on it.
     *
     * @param IParser $parser The parser to add.
     */
    public function prependParser(IParser $parser) : self
    {
        $parser->setParserManager($this);
        \array_unshift($this->parsers, $parser);
        return $this;
    }

    /**
     * Creates a ParserPartProxy for the passed $partBuilder using a compatible
     * IParser.
     *
     * Loops through registered IParsers calling 'canParse()' on each with the
     * passed PartBuilder, then calling either 'getParserMessageProxyFactory()'
     * or 'getParserPartProxyFactory()' depending on if the PartBuilder has a
     * parent, and finally calling 'newInstance' on the returned
     * ParserPartProxyFactory passing it the IParser, and returning the new
     * ParserPartProxy instance that was created.
     *
     * @param PartBuilder $partBuilder The PartBuilder to wrap in a proxy with
     *        an IParser
     * @return ?ParserPartProxy The created ParserPartProxy tied to a new
     *         IMessagePart and associated IParser.
     */
    public function createParserProxyFor(PartBuilder $partBuilder)
    {
        foreach ($this->parsers as $parser) {
            if ($parser->canParse($partBuilder)) {
                $factory = ($partBuilder->getParent() === null) ?
                    $parser->getParserMessageProxyFactory() :
                    $parser->getParserPartProxyFactory();
                return $factory->newInstance($partBuilder, $parser);
            }
        }
        return null;
    }
}

Spamworldpro Mini