Passed
Push — 3.x ( 451b43...8e526a )
by Eduardo Gulias
02:05
created

IDRightPart::validateTokens()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 3
Ratio 18.75 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 3
loc 16
ccs 4
cts 5
cp 0.8
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.032
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 IDRightPart extends DomainPart
12
{
13 6
    protected function validateTokens(bool $hasComments) : Result
14
    {
15
        $invalidDomainTokens = array(
16 6
            EmailLexer::S_DQUOTE => true,
17
            EmailLexer::S_SQUOTE => true,
18
            EmailLexer::S_BACKTICK => true,
19
            EmailLexer::S_SEMICOLON => true,
20
            EmailLexer::S_GREATERTHAN => true,
21
            EmailLexer::S_LOWERTHAN => true,
22
        );
23
    
24 6 View Code Duplication
        if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
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...
25
            return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']);
26
        }
27 6
        return new ValidEmail();
28
    }
29
}