Set parser to use for the given markup

@param string $parser Parser name (use Validator::PARSER_*)
@return Validator Returns current instance
@throws UnknownParserException If parser specified is not known
967049
public function setParser($parser) {
        switch ($parser) {
            case self::PARSER_XML:
            case self::PARSER_XMLDTD:
            case self::PARSER_HTML:
            case self::PARSER_HTML5:
            case self::PARSER_HTML4:
            case self::PARSER_HTML4TR:
                $this->parser = $parser;
                return $this;
            default:
                throw new UnknownParserException('Unknown parser "' . $parser . '"');
        }
    }
195144
public static function fromParser(TopListItemParser $parser): self
    {
        $instance = new self();
        $instance->rank = $parser->getRank();
        $instance->malId = $parser->getMalUrl()->getMalId();
        $instance->title = $parser->getMalUrl()->getTitle();
        $instance->url = $parser->getMalUrl()->getUrl();
        $instance->nameKanji = $parser->getKanjiName();
        $instance->animeography = $parser->getAnimeography();
        $instance->mangaography = $parser->getMangaography();
        $instance->favorites = $parser->getFavorites();
        $instance->imageUrl = $parser->getImage();

        return $instance;
    }
592711
protected function get_parser() {
        $parser = xml_parser_create();
        xml_set_object($parser, $this);
        xml_set_element_handler($parser, 'tag_open', 'tag_close');
        xml_set_character_data_handler($parser, 'cdata');
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
        return $parser;
    }
119026
public function add(TextParser $parser)
    {
        $objectHash = $this->objectHash($parser);

        if (isset($this->parserIds[$objectHash])) {
            return $this;
        }

        $this->parsers[] = $parser;

        $this->parserIds[$objectHash] = true;

        return $this;
    }
976053
public function init(Parser $parser, Lexer $lexer) {
        $parser->setStartRule($this->startRule);

        foreach ($this->rules as $rule) {
            $parser->addRule($rule);
        }

        $parser->setLexer($lexer);
        $lexer->setParser($parser);

        return $this;
    }
630394
public static function fromParser(MoreInfoParser $parser): self
    {
        $instance = new self();
        $instance->moreInfo = $parser->getMoreInfo();

        return $instance;
    }
1151794
public final <R> Parser<R> next(Parser<R> parser) {
    return Parsers.sequence(this, parser);
  }
330577
public function usingParser( $recordParser )
    {
        if (is_callable( $recordParser )) {
            $this->recordParser = new CallbackRecordParser( $recordParser );

            return $this;
        }

        if (!$recordParser instanceof RecordParser) {
            throw new InvalidArgumentException( 'Parser should implement RecordParser interface' );
        }

        $this->recordParser = $recordParser;

        return $this;
    }
87510
public function setRenderer($renderer)
    {
        $this->renderer = $renderer instanceof AbstractRenderer ?: $this->getRendererManager()->getRenderer((string) $renderer);

        return $this;
    }
1260119
public function addValidator($validator)
    {
        if (!$validator instanceof ValidatorInterface) {
            if (!is_callable($validator)) {
                throw new \InvalidArgumentException('Validator should be callable or ValidatorInterface.');
            }

            $validator = new CallbackValidator($validator);
        }

        $this->validators[] = $validator;

        return $this;
    }
1241509
public static function fromParser(Parser\Search\AnimeSearchParser $parser): self
    {
        $instance = new self();

        $instance->results = $parser->getResults();
        $instance->lastPage = $parser->getLastPage();

        return $instance;
    }
1222866
public static function fromPersonParser(Parser\Person\PersonParser $parser): self
    {
        $instance = new self();

        $instance->url = $parser->getPersonURL();
        $instance->malId = \Jikan\Helper\Parser::idFromUrl($instance->url);
        $instance->imageUrl = $parser->getPersonImageUrl();
        $instance->name = $parser->getPersonName();
        $instance->alternativeNames = $parser->getPersonAlternateNames();

        return $instance;
    }
884119
public static function fromParser(AnimeRecentlyUpdatedByUsersListParser $parser): self
    {
        $instance = new self();

        $instance->username = $parser->getUsername();
        $instance->url = $parser->getUrl();
        $instance->imageUrl = $parser->getImageUrl();
        $instance->score = $parser->getScore();
        $instance->status = $parser->getStatus();
        $instance->episodesSeen = $parser->getEpisodesSeen();
        $instance->episodesTotal = $parser->getEpisodesTotal();
        $instance->date = $parser->getDate();

        return $instance;
    }
221024
public function setValidator($validator)
    {
        $this->callBeforeListeners('setValidator', [$validator]);
        $this->validator = $validator;
        $this->callAfterListeners('setValidator', [$validator]);
    }
663037
public function parseToObj($parser)
	{
        /** @var CheckoutApi_Lib_RespondObj $respondObj */
        $respondObj = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');

		if($parser && is_string ($parser)) {
			$encoding = mb_detect_encoding($parser);
			
			if($encoding =="ASCII") {
				$parser = iconv('ASCII', 'UTF-8', $parser);
			}else {
				$parser =  mb_convert_encoding($parser, "UTF-8", $encoding);
			}
			
			$jsonObj = json_decode($parser,true);
			$jsonObj['rawOutput'] = $parser;

			$respondObj->setConfig($jsonObj);


		}
        $respondObj->setConfig($this->getResourceInfo());
		return $respondObj;
	}
91560
public static function validator($validator = null)
    {
        if (func_num_args()) {
            static::$_validators[static::class] = $validator;
            return;
        }
        $self = static::class;
        if (isset(static::$_validators[$self])) {
            return static::$_validators[$self];
        }
        $class = static::$_classes['validator'];
        $validator = static::$_validators[$self] = new $class();
        static::_rules($validator);
        return $validator;
    }
1202449
public static function fromParser(TopListItemParser $parser): self
    {
        $instance = new self();
        $instance->rank = $parser->getRank();
        $instance->malId = $parser->getMalUrl()->getMalId();
        $instance->title = $parser->getMalUrl()->getTitle();
        $instance->url = $parser->getMalUrl()->getUrl();
        $instance->nameKanji = $parser->getKanjiName();
        $instance->favorites = $parser->getPeopleFavorites();
        $instance->imageUrl = $parser->getImage();
        $instance->birthday = $parser->getBirthday();

        return $instance;
    }