DotAtStart example

if ($thereIsNoDomain) {
            return new InvalidEmail(new NoDomainPart()$this->lexer->current->value);
        }

        return new ValidEmail();
    }

    private function checkInvalidTokensAfterAT(): Result
    {
        if ($this->lexer->current->isA(EmailLexer::S_DOT)) {
            return new InvalidEmail(new DotAtStart()$this->lexer->current->value);
        }
        if ($this->lexer->current->isA(EmailLexer::S_HYPHEN)) {
            return new InvalidEmail(new DomainHyphened('After AT')$this->lexer->current->value);
        }
        return new ValidEmail();
    }

    protected function parseComments(): Result
    {
        $commentParser = new Comment($this->lexer, new DomainComment());
        $result = $commentParser->parse();
        

    private $localPart = '';


    public function parse(): Result
    {
        $this->lexer->startRecording();

        while (!$this->lexer->current->isA(EmailLexer::S_AT) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) {
            if ($this->hasDotAtStart()) {
                return new InvalidEmail(new DotAtStart()$this->lexer->current->value);
            }

            if ($this->lexer->current->isA(EmailLexer::S_DQUOTE)) {
                $dquoteParsingResult = $this->parseDoubleQuote();

                //Invalid double quote parsing                 if ($dquoteParsingResult->isInvalid()) {
                    return $dquoteParsingResult;
                }
            }

            
Home | Imprint | This part of the site doesn't use cookies.