Skip to content

Commit

Permalink
removes trailing spaces (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone authored and egulias committed Jan 25, 2017
1 parent 181a2fc commit c0c888a
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 34 deletions.
6 changes: 3 additions & 3 deletions EmailValidator/EmailValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EmailValidator
* @var EmailLexer
*/
private $lexer;

/**
* @var array
*/
Expand All @@ -21,7 +21,7 @@ class EmailValidator
* @var InvalidEmail
*/
protected $error;

public function __construct()
{
$this->lexer = new EmailLexer();
Expand All @@ -37,7 +37,7 @@ public function isValid($email, EmailValidation $emailValidation)
$isValid = $emailValidation->isValid($email, $this->lexer);
$this->warnings = $emailValidation->getWarnings();
$this->error = $emailValidation->getError();

return $isValid;
}

Expand Down
2 changes: 1 addition & 1 deletion EmailValidator/Exception/InvalidEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract class InvalidEmail extends \InvalidArgumentException
{
const REASON = "Invalid email";
const CODE = 0;

public function __construct()
{
parent::__construct(static::REASON, static::CODE);
Expand Down
2 changes: 1 addition & 1 deletion EmailValidator/Parser/DomainPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function doParseDomainPart()

return $domain;
}

private function checkNotAllowedChars($token)
{
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
Expand Down
2 changes: 1 addition & 1 deletion EmailValidator/Validation/DNSCheckValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function checkDNS($host)
{
$Aresult = true;
$MXresult = checkdnsrr($host, 'MX');

if (!$MXresult) {
$this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord();
$Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA');
Expand Down
4 changes: 2 additions & 2 deletions EmailValidator/Validation/MultipleErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class MultipleErrors extends InvalidEmail
* @var array
*/
private $errors = [];

public function __construct(array $errors)
{
$this->errors = $errors;
parent::__construct();
}

public function getErrors()
{
return $this->errors;
Expand Down
2 changes: 1 addition & 1 deletion EmailValidator/Validation/MultipleValidationWithAnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS)
if (count($validations) == 0) {
throw new EmptyValidationList();
}

$this->validations = $validations;
$this->mode = $mode;
}
Expand Down
4 changes: 2 additions & 2 deletions EmailValidator/Validation/RFCValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RFCValidation implements EmailValidation
* @var InvalidEmail
*/
private $error;

public function isValid($email, EmailLexer $emailLexer)
{
$this->parser = new EmailParser($emailLexer);
Expand All @@ -32,7 +32,7 @@ public function isValid($email, EmailLexer $emailLexer)
$this->error = $invalid;
return false;
}

$this->warnings = $this->parser->getWarnings();
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions EmailValidator/Validation/SpoofCheckValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public function isValid($email, EmailLexer $emailLexer)
{
$checker = new Spoofchecker();
$checker->setChecks(Spoofchecker::SINGLE_SCRIPT);

if ($checker->isSuspicious($email)) {
$this->error = new SpoofEmail();
}

return $this->error === null;
}

Expand Down
2 changes: 1 addition & 1 deletion EmailValidator/Warning/Warning.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function RFCNumber()
{
return $this->rfcNumber;
}

public function __toString()
{
return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE;
Expand Down
2 changes: 1 addition & 1 deletion Tests/EmailValidator/EmailValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testValidationIsUsed()

$this->assertTrue($validator->isValid("[email protected]", $validation));
}

public function testMultipleValidation()
{
$validator = new EmailValidator();
Expand Down
6 changes: 3 additions & 3 deletions Tests/EmailValidator/Validation/DNSCheckValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ public function testValidDNS($validEmail)
$validation = new DNSCheckValidation();
$this->assertTrue($validation->isValid($validEmail, new EmailLexer()));
}

public function testInvalidDNS()
{
$validation = new DNSCheckValidation();
$this->assertFalse($validation->isValid("[email protected]", new EmailLexer()));
}

public function testDNSWarnings()
{
$validation = new DNSCheckValidation();
$expectedWarnings = [NoDNSMXRecord::CODE => new NoDNSMXRecord()];
$validation->isValid("[email protected]", new EmailLexer());
$this->assertEquals($expectedWarnings, $validation->getWarnings());
}

public function testNoDNSError()
{
$validation = new DNSCheckValidation();
Expand Down
5 changes: 2 additions & 3 deletions Tests/EmailValidator/Validation/IsEmailFunctionTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function testAgainstIsEmailTestSuite($email)
public function isEmailTestSuite()
{
$testSuite = dirname(__FILE__) . '/../../resources/is_email_tests.xml';
$document = new \DOMDocument();
$document->load($testSuite);
$document = new \DOMDocument();
$document->load($testSuite);
$elements = $document->getElementsByTagName('test');
$tests = [];

Expand All @@ -40,5 +40,4 @@ public function isEmailTestSuite()

return $tests;
}

}
10 changes: 5 additions & 5 deletions Tests/EmailValidator/Validation/MultipleValidationWitAndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public function testAccumulatesWarnings()
DomainLiteral::CODE => new DomainLiteral()
];
$expectedResult = array_merge($warnings1, $warnings2);

$lexer = $this->getMock("Egulias\\EmailValidator\\EmailLexer");
$validation1 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation");
$validation1->expects($this->any())->method("isValid")->willReturn(true);
$validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1);

$validation2 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation");
$validation2->expects($this->any())->method("isValid")->willReturn(false);
$validation2->expects($this->once())->method("getWarnings")->willReturn($warnings2);

$multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2]);
$multipleValidation->isValid("[email protected]", $lexer);
$this->assertEquals($expectedResult, $multipleValidation->getWarnings());
Expand All @@ -73,11 +73,11 @@ public function testGathersAllTheErrors()
{
$error1 = new CommaInDomain();
$error2 = new NoDomainPart();

$expectedResult = new MultipleErrors([$error1, $error2]);

$lexer = $this->getMock("Egulias\\EmailValidator\\EmailLexer");

$validation1 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation");
$validation1->expects($this->any())->method("isValid")->willReturn(true);
$validation1->expects($this->once())->method("getWarnings")->willReturn([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NoRFCWarningsValidationTest extends \PHPUnit_Framework_TestCase
public function testInvalidEmailIsInvalid()
{
$validation = new NoRFCWarningsValidation();

$this->assertFalse($validation->isValid('non-email-string', new EmailLexer()));
$this->assertInstanceOf(NoDomainPart::class, $validation->getError());
}
Expand All @@ -24,7 +24,7 @@ public function testEmailWithWarningsIsInvalid()
$this->assertFalse($validation->isValid(str_repeat('x', 254).'@example.com', new EmailLexer())); // too long email
$this->assertInstanceOf(RFCWarnings::class, $validation->getError());
}

public function testEmailWithoutWarningsIsValid()
{
$validation = new NoRFCWarningsValidation();
Expand Down
6 changes: 3 additions & 3 deletions Tests/EmailValidator/Validation/RFCValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RFCValidationTest extends \PHPUnit_Framework_TestCase
* @var EmailLexer
*/
protected $lexer;

protected function setUp()
{
$this->validator = new RFCValidation();
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testInvalidUTF8Email()
$email = "\x80\x81\x82@\x83\x84\x85.\x86\x87\x88";
$this->assertFalse($this->validator->isValid($email, $this->lexer));
}

/**
* @dataProvider getInvalidEmails
*/
Expand Down Expand Up @@ -228,7 +228,7 @@ public function testInvalidEmailsWithWarningsCheck($expectedWarnings, $email)
$this->assertTrue(isset($expectedWarnings[$warning->code()]));
}
}

public function getInvalidEmailsWithWarnings()
{
return [
Expand Down
6 changes: 3 additions & 3 deletions Tests/EmailValidator/Validation/SpoofCheckValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ public function testUTF8EmailAreValid($email)
{
$this->markTestSkipped("Skipped for Travis CI since it is failing on this test for unknown reasons.");
$validation = new SpoofCheckValidation();

$this->assertTrue($validation->isValid($email, new EmailLexer()));
}

public function testEmailWithSpoofsIsInvalid()
{
$validation = new SpoofCheckValidation();

$this->assertFalse($validation->isValid("Кириллица"."latin漢字"."ひらがな"."カタカナ", new EmailLexer()));
}

public function validUTF8EmailsProvider()
{
return [
Expand Down

0 comments on commit c0c888a

Please sign in to comment.