Passed
Push — message-id-validator ( 1cb5b2...07464f )
by Eduardo Gulias
02:11
created

IDLeftPart   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 19
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateTokens() 0 16 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 IDLeftPart extends DomainPart
12
{
13 3
    protected function validateTokens(bool $hasComments) : Result
14
    {
15
        $invalidDomainTokens = array(
16 3
            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 3
        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 3
        return new ValidEmail();
28
    }
29
}