init
This commit is contained in:
18
vendor/egulias/email-validator/src/Parser/CommentStrategy/CommentStrategy.php
vendored
Normal file
18
vendor/egulias/email-validator/src/Parser/CommentStrategy/CommentStrategy.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser\CommentStrategy;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
|
||||
interface CommentStrategy
|
||||
{
|
||||
/**
|
||||
* Return "true" to continue, "false" to exit
|
||||
*/
|
||||
public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool;
|
||||
|
||||
public function endOfLoopValidations(EmailLexer $lexer) : Result;
|
||||
|
||||
public function getWarnings() : array;
|
||||
}
|
||||
37
vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php
vendored
Normal file
37
vendor/egulias/email-validator/src/Parser/CommentStrategy/DomainComment.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser\CommentStrategy;
|
||||
|
||||
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 DomainComment implements CommentStrategy
|
||||
{
|
||||
public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool
|
||||
{
|
||||
if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))){ // || !$internalLexer->moveNext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function endOfLoopValidations(EmailLexer $lexer) : Result
|
||||
{
|
||||
//test for end of string
|
||||
if (!$lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->token['value']);
|
||||
}
|
||||
//add warning
|
||||
//Address is valid within the message but cannot be used unmodified for the envelope
|
||||
return new ValidEmail();
|
||||
}
|
||||
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
37
vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php
vendored
Normal file
37
vendor/egulias/email-validator/src/Parser/CommentStrategy/LocalComment.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser\CommentStrategy;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
use Egulias\EmailValidator\Result\ValidEmail;
|
||||
use Egulias\EmailValidator\Warning\CFWSNearAt;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
|
||||
|
||||
class LocalComment implements CommentStrategy
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool
|
||||
{
|
||||
return !$lexer->isNextToken(EmailLexer::S_AT);
|
||||
}
|
||||
|
||||
public function endOfLoopValidations(EmailLexer $lexer) : Result
|
||||
{
|
||||
if (!$lexer->isNextToken(EmailLexer::S_AT)) {
|
||||
return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->token['value']);
|
||||
}
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
return new ValidEmail();
|
||||
}
|
||||
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user