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

Breadcrumb

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

function FoldingWhiteSpace::parse

Overrides PartParser::parse

File

vendor/egulias/email-validator/src/Parser/FoldingWhiteSpace.php, line 27

Class

FoldingWhiteSpace

Namespace

Egulias\EmailValidator\Parser

Code

public function parse() : Result {
    if (!$this->isFWS()) {
        return new ValidEmail();
    }
    $previous = $this->lexer
        ->getPrevious();
    $resultCRLF = $this->checkCRLFInFWS();
    if ($resultCRLF->isInvalid()) {
        return $resultCRLF;
    }
    if ($this->lexer->current
        ->isA(EmailLexer::S_CR)) {
        return new InvalidEmail(new CRNoLF(), $this->lexer->current->value);
    }
    if ($this->lexer
        ->isNextToken(EmailLexer::GENERIC) && !$previous->isA(EmailLexer::S_AT)) {
        return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->current->value);
    }
    if ($this->lexer->current
        ->isA(EmailLexer::S_LF) || $this->lexer->current
        ->isA(EmailLexer::C_NUL)) {
        return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->current->value);
    }
    if ($this->lexer
        ->isNextToken(EmailLexer::S_AT) || $previous->isA(EmailLexer::S_AT)) {
        $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
    }
    else {
        $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
    }
    return new ValidEmail();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal