Passed
Pull Request — 3.x (#348)
by
unknown
01:48
created

IDRightPart   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 17
ccs 11
cts 12
cp 0.9167
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateTokens() 0 15 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 IDRightPart extends DomainPart
12
{
13 6
    protected function validateTokens(bool $hasComments) : Result
14
    {
15 6
        $invalidDomainTokens = [
16 6
            EmailLexer::S_DQUOTE => true,
17 6
            EmailLexer::S_SQUOTE => true,
18 6
            EmailLexer::S_BACKTICK => true,
19 6
            EmailLexer::S_SEMICOLON => true,
20 6
            EmailLexer::S_GREATERTHAN => true,
21 6
            EmailLexer::S_LOWERTHAN => true,
22 6
        ];
23
    
24 6
        if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
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
}
30