| 148 |
lars |
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 |
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 |
if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
|
|
|
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 |
}
|