You are here

protected function DomainPart::checkDomainPartExceptions in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/DomainPart.php \Egulias\EmailValidator\Parser\DomainPart::checkDomainPartExceptions()
1 call to DomainPart::checkDomainPartExceptions()
DomainPart::doParseDomainPart in vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/DomainPart.php

File

vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/DomainPart.php, line 244

Class

DomainPart

Namespace

Egulias\EmailValidator\Parser

Code

protected function checkDomainPartExceptions($prev) {
  $invalidDomainTokens = array(
    EmailLexer::S_DQUOTE => true,
    EmailLexer::S_SEMICOLON => true,
    EmailLexer::S_GREATERTHAN => true,
    EmailLexer::S_LOWERTHAN => true,
  );
  if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
    throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
  }
  if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
    throw new \InvalidArgumentException('ERR_COMMA_IN_DOMAIN');
  }
  if ($this->lexer->token['type'] === EmailLexer::S_AT) {
    throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
  }
  if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
    throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
  }
  if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer
    ->isNextToken(EmailLexer::S_DOT)) {
    throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
  }
  if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer
    ->isNextToken(EmailLexer::GENERIC)) {
    throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
  }
}