mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-22 13:35:37 +00:00
8e526a57c1
* scafolding for MessageID validation * Improve domain valid tokens * Improved EmailParser to remove leaked logic. User of lexer recorder within parsers. * MessageIDParser passing tests. * change left for right, which is the right one * psaml errors * Better naming * comments are not allowed in IDLeft for message-id * Suppress psalm inheritance over tokens and dependencies * Update src/Parser.php Co-authored-by: Alexander M. Turek <me@derrabus.de> * Update src/Parser.php Co-authored-by: Alexander M. Turek <me@derrabus.de> * improve parser from comments Co-authored-by: Alexander M. Turek <me@derrabus.de>
29 lines
981 B
PHP
29 lines
981 B
PHP
<?php
|
|
|
|
namespace Egulias\EmailValidator\Parser;
|
|
|
|
use Egulias\EmailValidator\EmailLexer;
|
|
use Egulias\EmailValidator\Result\Result;
|
|
use Egulias\EmailValidator\Result\ValidEmail;
|
|
use Egulias\EmailValidator\Result\InvalidEmail;
|
|
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
|
|
|
|
class IDRightPart extends DomainPart
|
|
{
|
|
protected function validateTokens(bool $hasComments) : Result
|
|
{
|
|
$invalidDomainTokens = array(
|
|
EmailLexer::S_DQUOTE => true,
|
|
EmailLexer::S_SQUOTE => true,
|
|
EmailLexer::S_BACKTICK => true,
|
|
EmailLexer::S_SEMICOLON => true,
|
|
EmailLexer::S_GREATERTHAN => true,
|
|
EmailLexer::S_LOWERTHAN => true,
|
|
);
|
|
|
|
if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
|
|
return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->token['value']), $this->lexer->token['value']);
|
|
}
|
|
return new ValidEmail();
|
|
}
|
|
} |