Code Duplication    Length = 3-5 lines in 7 locations

src/Parser/DomainLiteral.php 1 location

@@ 54-56 (lines=3) @@
51
                return new InvalidEmail(new CRNoLF(), $this->lexer->token['value']);
52
            }
53
54
            if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
55
                return new InvalidEmail(new UnusualElements($this->lexer->token['value']), $this->lexer->token['value']);
56
            }
57
            if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) {
58
                $IPv6TAG = true;
59
            }

src/Parser/FoldingWhiteSpace.php 1 location

@@ 39-41 (lines=3) @@
36
            return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->token['value']);
37
        }
38
39
        if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) {
40
            return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->token['value']);
41
        }
42
43
        if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type']  === EmailLexer::S_AT) {
44
            $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();

src/Parser/LocalPart.php 2 locations

@@ 52-54 (lines=3) @@
49
                }
50
            }
51
52
            if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
53
                return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
54
            }
55
56
            if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
57
                $this->lexer->isNextToken(EmailLexer::S_AT)
@@ 56-60 (lines=5) @@
53
                return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
54
            }
55
56
            if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
57
                $this->lexer->isNextToken(EmailLexer::S_AT)
58
            ) {
59
                return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']);
60
            }
61
62
            $resultEscaping = $this->validateEscaping();
63
            if ($resultEscaping->isInvalid()) {

src/Parser/DomainPart.php 2 locations

@@ 247-249 (lines=3) @@
244
            return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']);
245
        }
246
247
        if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
248
            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
249
        }
250
251
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
252
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
@@ 251-254 (lines=4) @@
248
            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
249
        }
250
251
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
252
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
253
            return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']);
254
        }
255
256
        return $this->validateTokens($hasComments);
257
    }

src/Parser/PartParser.php 1 location

@@ 48-50 (lines=3) @@
45
46
    protected function checkConsecutiveDots() : Result
47
    {
48
        if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
49
            return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
50
        }
51
52
        return new ValidEmail();
53
    }