You are here

public function LocalPart::parse in Zircon Profile 8.0

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

Overrides Parser::parse

File

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

Class

LocalPart

Namespace

Egulias\EmailValidator\Parser

Code

public function parse($localPart) {
  $parseDQuote = true;
  $closingQuote = false;
  while ($this->lexer->token['type'] !== EmailLexer::S_AT && $this->lexer->token) {
    if ($this->lexer->token['type'] === EmailLexer::S_DOT && !$this->lexer
      ->getPrevious()) {
      throw new \InvalidArgumentException('ERR_DOT_START');
    }
    $closingQuote = $this
      ->checkDQUOTE($closingQuote);
    if ($closingQuote && $parseDQuote) {
      $parseDQuote = $this
        ->parseDoubleQuote();
    }
    if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
      $this
        ->parseComments();
    }
    $this
      ->checkConsecutiveDots();
    if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer
      ->isNextToken(EmailLexer::S_AT)) {
      throw new \InvalidArgumentException('ERR_DOT_END');
    }
    $this
      ->warnEscaping();
    $this
      ->isInvalidToken($this->lexer->token, $closingQuote);
    if ($this
      ->isFWS()) {
      $this
        ->parseFWS();
    }
    $this->lexer
      ->moveNext();
  }
  $prev = $this->lexer
    ->getPrevious();
  if (strlen($prev['value']) > EmailValidator::RFC5322_LOCAL_TOOLONG) {
    $this->warnings[] = EmailValidator::RFC5322_LOCAL_TOOLONG;
  }
}