mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-25 15:38:27 +00:00
better reading with isInvalid as method
This commit is contained in:
@@ -17,7 +17,7 @@ class DoubleQuote extends Parser
|
||||
{
|
||||
|
||||
$validQuotedString = $this->checkDQUOTE();
|
||||
if(!$validQuotedString->isValid()) return $validQuotedString;
|
||||
if($validQuotedString->isInvalid()) return $validQuotedString;
|
||||
|
||||
$special = array(
|
||||
EmailLexer::S_CR => true,
|
||||
@@ -55,7 +55,7 @@ class DoubleQuote extends Parser
|
||||
|
||||
if ($prev['type'] === EmailLexer::S_BACKSLASH) {
|
||||
$validQuotedString = $this->checkDQUOTE();
|
||||
if(!$validQuotedString->isValid()) return $validQuotedString;
|
||||
if($validQuotedString->isInvalid()) return $validQuotedString;
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) {
|
||||
|
||||
@@ -28,7 +28,7 @@ class LocalPart extends Parser
|
||||
$dquoteParsingResult = $this->parseDoubleQuote();
|
||||
|
||||
//Invalid double quote parsing
|
||||
if(!$dquoteParsingResult->isValid()) {
|
||||
if($dquoteParsingResult->isInvalid()) {
|
||||
return $dquoteParsingResult;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class LocalPart extends Parser
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS ) {
|
||||
$result = $commentParser->parse('remove');
|
||||
if(!$result->isValid()) {
|
||||
if($result->isInvalid()) {
|
||||
return $result;
|
||||
}
|
||||
$warns = $commentParser->getWarnings();
|
||||
@@ -55,7 +55,7 @@ class LocalPart extends Parser
|
||||
|
||||
//$this->warnEscaping();
|
||||
$resultEscaping = $this->validateEscaping();
|
||||
if (!$resultEscaping->isValid()) {
|
||||
if ($resultEscaping->isInvalid()) {
|
||||
return $resultEscaping;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ class InvalidEmail implements Result
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isInvalid(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return $this->reason->description() . " in char " . $this->token;
|
||||
|
||||
@@ -9,6 +9,12 @@ interface Result
|
||||
*/
|
||||
public function isValid() : bool;
|
||||
|
||||
/**
|
||||
* Is validation result invalid?
|
||||
* Usually the inverse of isValid()
|
||||
*/
|
||||
public function isInvalid() : bool;
|
||||
|
||||
/**
|
||||
* Short description of the result, human readable.
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,11 @@ class ValidEmail implements Result
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isInvalid(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return "Valid email";
|
||||
|
||||
Reference in New Issue
Block a user