mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-01 04:59:18 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 01002fa052 | |||
| 8edbe450f1 | |||
| c14d12ee17 | |||
| 9320624d03 | |||
| ab22322b82 | |||
| 44d20e3440 | |||
| c5d6b8c16a | |||
| b03e9c935f | |||
| 8fb7a88965 | |||
| 06579b96ca | |||
| b79cd8f033 | |||
| 07464f87c8 | |||
| b80f568f75 | |||
| 03a062e9e4 | |||
| 1cb5b2a402 |
@@ -280,9 +280,9 @@ class DomainPart extends PartParser
|
||||
{
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT || $isEndOfDomain) {
|
||||
if ($this->isLabelTooLong($this->label)) {
|
||||
$this->label = '';
|
||||
return new InvalidEmail(new LabelTooLong(), $this->lexer->token['value']);
|
||||
}
|
||||
$this->label = '';
|
||||
}
|
||||
$this->label .= $this->lexer->token['value'];
|
||||
return new ValidEmail();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Egulias\EmailValidator\Result;
|
||||
|
||||
use Egulias\EmailValidator\Result\Reason\EmptyReason;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\Reason;
|
||||
|
||||
/**
|
||||
@@ -34,9 +34,7 @@ class MultipleErrors extends InvalidEmail
|
||||
|
||||
public function reason() : Reason
|
||||
{
|
||||
return 0 !== count($this->reasons)
|
||||
? current($this->reasons)
|
||||
: new EmptyReason();
|
||||
return $this->reasons[0];
|
||||
}
|
||||
|
||||
public function description() : string
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Result\Reason;
|
||||
|
||||
class EmptyReason implements Reason
|
||||
{
|
||||
public function code() : int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function description() : string
|
||||
{
|
||||
return 'Empty reason';
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ interface EmailValidation
|
||||
/**
|
||||
* Returns the validation error.
|
||||
*
|
||||
* @return InvalidEmail|null
|
||||
* @return InvalidEmail
|
||||
*/
|
||||
public function getError() : ?InvalidEmail;
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Reason;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Egulias\EmailValidator\Result\MultipleErrors;
|
||||
use Egulias\EmailValidator\Result\Reason\EmptyReason;
|
||||
use Egulias\EmailValidator\Tests\EmailValidator\Dummy\AnotherDummyReason;
|
||||
use Egulias\EmailValidator\Tests\EmailValidator\Dummy\DummyReason;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MultipleErrorsTest extends TestCase
|
||||
{
|
||||
@@ -36,31 +35,4 @@ class MultipleErrorsTest extends TestCase
|
||||
$this->assertEquals($expectedReason, $multiError->description());
|
||||
$this->assertEquals($error1, $multiError->reason());
|
||||
}
|
||||
|
||||
public function testRetrieveFirstReasonWithReasonCodeEqualsZero(): void
|
||||
{
|
||||
$error1 = new DummyReason();
|
||||
|
||||
$multiError = new MultipleErrors();
|
||||
$multiError->addReason($error1);
|
||||
|
||||
$this->assertEquals($error1, $multiError->reason());
|
||||
}
|
||||
|
||||
public function testRetrieveFirstReasonWithReasonCodeDistinctToZero(): void
|
||||
{
|
||||
$error1 = new AnotherDummyReason();
|
||||
|
||||
$multiError = new MultipleErrors();
|
||||
$multiError->addReason($error1);
|
||||
|
||||
$this->assertEquals($error1, $multiError->reason());
|
||||
}
|
||||
|
||||
public function testRetrieveFirstReasonWithNoReasonAdded()
|
||||
{
|
||||
$emptyReason = new EmptyReason();
|
||||
$multiError = new MultipleErrors();
|
||||
$this->assertEquals($emptyReason, $multiError->reason());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ class RFCValidationDomainPartTest extends TestCase
|
||||
['validipv4@[127.0.0.0]'],
|
||||
['validipv4@127.0.0.0'],
|
||||
['withhyphen@domain-exam.com'],
|
||||
['valid_long_domain@71846jnrsoj91yfhc18rkbrf90ue3onl8y46js38kae8inz0t1.5a-xdycuau.na49.le.example.com']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user