Code Duplication    Length = 3-5 lines in 6 locations

EmailValidator/Parser/FoldingWhiteSpace.php 1 location

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

EmailValidator/Parser/LocalPart.php 2 locations

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

EmailValidator/Parser/DomainPart.php 2 locations

@@ 234-236 (lines=3) @@
231
            return new InvalidEmail(new ReasonExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token['value']);
232
        }
233
234
        if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
235
            return new InvalidEmail(new ReasonDomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
236
        }
237
238
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
239
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
@@ 238-241 (lines=4) @@
235
            return new InvalidEmail(new ReasonDomainHyphened('Hypen found near DOT'), $this->lexer->token['value']);
236
        }
237
238
        if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
239
            && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
240
            return new InvalidEmail(new ReasonExpectingATEXT('Escaping following "ATOM"'), $this->lexer->token['value']);
241
        }
242
243
        return new ValidEmail();
244
    }

EmailValidator/Parser/Parser.php 1 location

@@ 56-58 (lines=3) @@
53
54
    protected function checkConsecutiveDots() : Result
55
    {
56
        if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
57
            return new InvalidEmail(new ConsecutiveDot(), $this->lexer->token['value']);
58
        }
59
60
        return new ValidEmail();
61
    }