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

Breadcrumb

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

function DomainPart::checkDomainPartExceptions

Parameters

Token<int, string> $prev:

bool $hasComments:

Return value

Result

1 call to DomainPart::checkDomainPartExceptions()
DomainPart::doParseDomainPart in vendor/egulias/email-validator/src/Parser/DomainPart.php

File

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

Class

DomainPart

Namespace

Egulias\EmailValidator\Parser

Code

protected function checkDomainPartExceptions(Token $prev, bool $hasComments) : Result {
    if ($this->lexer->current
        ->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) {
        return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->current->value);
    }
    if ($this->lexer->current
        ->isA(EmailLexer::S_HYPHEN) && $this->lexer
        ->isNextToken(EmailLexer::S_DOT)) {
        return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->current->value);
    }
    if ($this->lexer->current
        ->isA(EmailLexer::S_BACKSLASH) && $this->lexer
        ->isNextToken(EmailLexer::GENERIC)) {
        return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->current->value);
    }
    return $this->validateTokens($hasComments);
}
RSS feed
Powered by Drupal