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/Parser.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
    }

src/Parser/DomainPart.php 2 locations

@@ 258-260 (lines=3) @@
255
            return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']);
256
        }
257
258
        if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
259
            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
260
        }
261
262
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
263
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
@@ 262-265 (lines=4) @@
259
            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
260
        }
261
262
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
263
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
264
            return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']);
265
        }
266
267
        return $this->validateTokens($hasComments);
268
    }

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()) {