Code Duplication    Length = 7-10 lines in 5 locations

src/Parser/DomainPart.php 1 location

@@ 114-121 (lines=8) @@
111
        return $this->domainPart;
112
    }
113
114
    protected function parseComments(): Result
115
    {
116
        $commentParser = new Comment($this->lexer, new DomainComment());
117
        $result = $commentParser->parse();
118
        $this->warnings = array_merge($this->warnings, $commentParser->getWarnings());
119
120
        return $result;
121
    }
122
123
    protected function doParseDomainPart() : Result
124
    {

src/Parser/LocalPart.php 3 locations

@@ 92-101 (lines=10) @@
89
        return new ValidEmail();
90
    }
91
92
    private function parseLocalFWS() : Result 
93
    {
94
        //use $this->parseFWS()
95
        $foldingWS = new FoldingWhiteSpace($this->lexer);
96
        $resultFWS = $foldingWS->parse();
97
        if ($resultFWS->isValid()) {
98
            $this->warnings = array_merge($this->warnings, $foldingWS->getWarnings());
99
        }
100
        return $resultFWS;
101
    }
102
103
    private function hasDotAtStart() : bool
104
    {
@@ 108-115 (lines=8) @@
105
            return $this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type'];
106
    }
107
108
    private function parseDoubleQuote() : Result
109
    {
110
        $dquoteParser = new DoubleQuote($this->lexer);
111
        $parseAgain = $dquoteParser->parse();
112
        $this->warnings = array_merge($this->warnings, $dquoteParser->getWarnings());
113
114
        return $parseAgain;
115
    }
116
117
    private function parseComments(): Result
118
    {
@@ 117-126 (lines=10) @@
114
        return $parseAgain;
115
    }
116
117
    private function parseComments(): Result
118
    {
119
        $commentParser = new Comment($this->lexer, new LocalComment());
120
        $result = $commentParser->parse();
121
        $this->warnings = array_merge($this->warnings, $commentParser->getWarnings());
122
        if($result->isInvalid()) {
123
            return $result;
124
        }
125
        return $result;
126
    }
127
128
    private function validateEscaping() : Result
129
    {

src/Parser/Parser.php 1 location

@@ 38-44 (lines=7) @@
35
36
    abstract public function parse() : Result;
37
38
    protected function parseFWS() : Result
39
    {
40
        $foldingWS = new FoldingWhiteSpace($this->lexer);
41
        $resultFWS = $foldingWS->parse();
42
        $this->warnings = array_merge($this->warnings, $foldingWS->getWarnings());
43
        return $resultFWS;
44
    }
45
46
    protected function checkConsecutiveDots() : Result
47
    {