DomainComment   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 25
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A exitCondition() 0 7 3
A endOfLoopValidations() 0 9 2
A getWarnings() 0 3 1
1
<?php
2
3
namespace Egulias\EmailValidator\Parser\CommentStrategy;
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 4
    public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool
14
    {
15 4
        if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))) { // || !$internalLexer->moveNext()) {
16 2
            return false;
17
        }
18
19 4
        return true;
20
    }
21
22 2
    public function endOfLoopValidations(EmailLexer $lexer): Result
23
    {
24
        //test for end of string
25 2
        if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
26
            return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->current->value);
27
        }
28
        //add warning
29
        //Address is valid within the message but cannot be used unmodified for the envelope
30 2
        return new ValidEmail();
31
    }
32
33 2
    public function getWarnings(): array
34
    {
35 2
        return [];
36
    }
37
}
38