validation-bugsnag-email

This commit is contained in:
RafficMohammed
2023-01-31 13:17:59 +05:30
parent 2ec836b447
commit 9dd3f53910
769 changed files with 20242 additions and 14060 deletions

View File

@@ -22,22 +22,22 @@ abstract class Parser
/**
* id-left "@" id-right
*/
abstract protected function parseRightFromAt() : Result;
abstract protected function parseLeftFromAt() : Result;
abstract protected function preLeftParsing() : Result;
abstract protected function parseRightFromAt(): Result;
abstract protected function parseLeftFromAt(): Result;
abstract protected function preLeftParsing(): Result;
public function __construct(EmailLexer $lexer)
{
$this->lexer = $lexer;
$this->lexer = $lexer;
}
public function parse(string $str) : Result
public function parse(string $str): Result
{
$this->lexer->setInput($str);
if ($this->lexer->hasInvalidTokens()) {
return new InvalidEmail(new ExpectingATEXT("Invalid tokens found"), $this->lexer->token["value"]);
return new InvalidEmail(new ExpectingATEXT("Invalid tokens found"), $this->lexer->current->value);
}
$preParsingResult = $this->preLeftParsing();
@@ -51,7 +51,7 @@ abstract class Parser
return $localPartResult;
}
$domainPartResult = $this->parseRightFromAt();
$domainPartResult = $this->parseRightFromAt();
if ($domainPartResult->isInvalid()) {
return $domainPartResult;
@@ -63,16 +63,16 @@ abstract class Parser
/**
* @return Warning\Warning[]
*/
public function getWarnings() : array
public function getWarnings(): array
{
return $this->warnings;
}
protected function hasAtToken() : bool
protected function hasAtToken(): bool
{
$this->lexer->moveNext();
$this->lexer->moveNext();
return $this->lexer->token['type'] !== EmailLexer::S_AT;
return !$this->lexer->current->isA(EmailLexer::S_AT);
}
}