| 148 |
lars |
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 |
protected function validateTokens(bool $hasComments) : Result
|
|
|
14 |
{
|
|
|
15 |
$invalidDomainTokens = [
|
|
|
16 |
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 |
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 |
return new ValidEmail();
|
|
|
28 |
}
|
|
|
29 |
}
|