Code Duplication    Length = 7-10 lines in 5 locations

src/Parser/LocalPart.php 3 locations

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

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
    {

src/Parser/DomainPart.php 1 location

@@ 139-146 (lines=8) @@
136
        return $this->domainPart;
137
    }
138
139
    protected function parseComments(): Result
140
    {
141
        $commentParser = new Comment($this->lexer, new DomainComment());
142
        $result = $commentParser->parse();
143
        $this->warnings = array_merge($this->warnings, $commentParser->getWarnings());
144
145
        return $result;
146
    }
147
148
    protected function doParseDomainPart() : Result
149
    {