Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DomainPart.php

function DomainPart::parse

Overrides PartParser::parse

File

vendor/egulias/email-validator/src/Parser/DomainPart.php, line 41

Class

DomainPart

Namespace

Egulias\EmailValidator\Parser

Code

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();
}
RSS feed
Powered by Drupal