Test Setup Failed
Push — 3.0.0-dev ( 61798f...c8e7f0 )
by Eduardo Gulias
01:58
created

DomainComment::exitCondition()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 2
1
<?php
2
3
namespace Egulias\EmailValidator\Parser;
4
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\Result\Result;
7
use Egulias\EmailValidator\Result\ValidEmail;
8
use Egulias\EmailValidator\Result\InvalidEmail;
9
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
10
11
class DomainComment implements CommentStrategy
12
{
13
    public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool
14
    {
15
        if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))){ // || !$internalLexer->moveNext()) {
16
            return false;
17
        }
18
19
        return true;
20
    }
21
22
    public function endOfLoopValidations(EmailLexer $lexer) : Result
23
    {
24
        //test for end of string
25 View Code Duplication
        if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
            return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->token['value']);
27
        }
28
            //add warning
29
            //Address is valid within the message but cannot be used unmodified for the envelope
30
        return new ValidEmail();
31
    }
32
33
    public function getWarnings(): array
34
    {
35
        return [];
36
    }
37
}