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

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

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

@@ 265-267 (lines=3) @@
262
            return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']);
263
        }
264
265
        if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
266
            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
267
        }
268
269
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
270
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
@@ 269-272 (lines=4) @@
266
            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
267
        }
268
269
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
270
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
271
            return new InvalidEmail(new ExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']);
272
        }
273
274
        if (!isset($validDomainTokens[$this->lexer->token['type']])) {
275
            return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']);

src/Parser/LocalPart.php 2 locations

@@ 62-64 (lines=3) @@
59
                }
60
            }
61
62
            if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
63
                return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
64
            }
65
66
            if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
67
                $this->lexer->isNextToken(EmailLexer::S_AT)
@@ 66-70 (lines=5) @@
63
                return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
64
            }
65
66
            if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
67
                $this->lexer->isNextToken(EmailLexer::S_AT)
68
            ) {
69
                return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']);
70
            }
71
72
            $resultEscaping = $this->validateEscaping();
73
            if ($resultEscaping->isInvalid()) {