function DomainPart::doParseDomainPart
1 call to DomainPart::doParseDomainPart()
- DomainPart::parse in vendor/
egulias/ email-validator/ src/ Parser/ DomainPart.php
File
-
vendor/
egulias/ email-validator/ src/ Parser/ DomainPart.php, line 145
Class
Namespace
Egulias\EmailValidator\ParserCode
protected function doParseDomainPart() : Result {
$tldMissing = true;
$hasComments = false;
$domain = '';
do {
$prev = $this->lexer
->getPrevious();
$notAllowedChars = $this->checkNotAllowedChars($this->lexer->current);
if ($notAllowedChars->isInvalid()) {
return $notAllowedChars;
}
if ($this->lexer->current
->isA(EmailLexer::S_OPENPARENTHESIS) || $this->lexer->current
->isA(EmailLexer::S_CLOSEPARENTHESIS)) {
$hasComments = true;
$commentsResult = $this->parseComments();
//Invalid comment parsing
if ($commentsResult->isInvalid()) {
return $commentsResult;
}
}
$dotsResult = $this->checkConsecutiveDots();
if ($dotsResult->isInvalid()) {
return $dotsResult;
}
if ($this->lexer->current
->isA(EmailLexer::S_OPENBRACKET)) {
$literalResult = $this->parseDomainLiteral();
$this->addTLDWarnings($tldMissing);
return $literalResult;
}
$labelCheck = $this->checkLabelLength();
if ($labelCheck->isInvalid()) {
return $labelCheck;
}
$FwsResult = $this->parseFWS();
if ($FwsResult->isInvalid()) {
return $FwsResult;
}
$domain .= $this->lexer->current->value;
if ($this->lexer->current
->isA(EmailLexer::S_DOT) && $this->lexer
->isNextToken(EmailLexer::GENERIC)) {
$tldMissing = false;
}
$exceptionsResult = $this->checkDomainPartExceptions($prev, $hasComments);
if ($exceptionsResult->isInvalid()) {
return $exceptionsResult;
}
$this->lexer
->moveNext();
} while (!$this->lexer->current
->isA(EmailLexer::S_EMPTY));
$labelCheck = $this->checkLabelLength(true);
if ($labelCheck->isInvalid()) {
return $labelCheck;
}
$this->addTLDWarnings($tldMissing);
$this->domainPart = $domain;
return new ValidEmail();
}