function DomainPart::parse
Overrides PartParser::parse
File
-
vendor/
egulias/ email-validator/ src/ Parser/ DomainPart.php, line 41
Class
Namespace
Egulias\EmailValidator\ParserCode
public function parse() : Result {
$this->lexer
->clearRecorded();
$this->lexer
->startRecording();
$this->lexer
->moveNext();
$domainChecks = $this->performDomainStartChecks();
if ($domainChecks->isInvalid()) {
return $domainChecks;
}
if ($this->lexer->current
->isA(EmailLexer::S_AT)) {
return new InvalidEmail(new ConsecutiveAt(), $this->lexer->current->value);
}
$result = $this->doParseDomainPart();
if ($result->isInvalid()) {
return $result;
}
$end = $this->checkEndOfDomain();
if ($end->isInvalid()) {
return $end;
}
$this->lexer
->stopRecording();
$this->domainPart = $this->lexer
->getAccumulatedValues();
$length = strlen($this->domainPart);
if ($length > self::DOMAIN_MAX_LENGTH) {
return new InvalidEmail(new DomainTooLong(), $this->lexer->current->value);
}
return new ValidEmail();
}