You are here

protected function LocalPart::parseDoubleQuote in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/LocalPart.php \Egulias\EmailValidator\Parser\LocalPart::parseDoubleQuote()
1 call to LocalPart::parseDoubleQuote()
LocalPart::parse in vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/LocalPart.php

File

vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/LocalPart.php, line 56

Class

LocalPart

Namespace

Egulias\EmailValidator\Parser

Code

protected function parseDoubleQuote() {
  $parseAgain = true;
  $special = array(
    EmailLexer::S_CR => true,
    EmailLexer::S_HTAB => true,
    EmailLexer::S_LF => true,
  );
  $invalid = array(
    EmailLexer::C_NUL => true,
    EmailLexer::S_HTAB => true,
    EmailLexer::S_CR => true,
    EmailLexer::S_LF => true,
  );
  $setSpecialsWarning = true;
  $this->lexer
    ->moveNext();
  while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && $this->lexer->token) {
    $parseAgain = false;
    if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
      $this->warnings[] = EmailValidator::CFWS_FWS;
      $setSpecialsWarning = false;
    }
    $this->lexer
      ->moveNext();
    if (!$this
      ->escaped() && isset($invalid[$this->lexer->token['type']])) {
      throw new InvalidArgumentException("ERR_EXPECTED_ATEXT");
    }
  }
  $prev = $this->lexer
    ->getPrevious();
  if ($prev['type'] === EmailLexer::S_BACKSLASH) {
    if (!$this
      ->checkDQUOTE(false)) {
      throw new \InvalidArgumentException("ERR_UNCLOSED_DQUOTE");
    }
  }
  if (!$this->lexer
    ->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) {
    throw new \InvalidArgumentException("ERR_EXPECED_AT");
  }
  return $parseAgain;
}