organizrnginxsonarrradarrplexdashboardcouchpotatonzbgetbookmarkapplication-dashboardmuximuxlandingpagestartpagelandinghtpcserverhomepagesabnzbdheimdallemby
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
957 B
50 lines
957 B
7 years ago
|
<?php
|
||
|
|
||
|
namespace Egulias\EmailValidator\Validation;
|
||
|
|
||
|
use Egulias\EmailValidator\EmailLexer;
|
||
|
use Egulias\EmailValidator\EmailParser;
|
||
|
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||
|
|
||
|
class RFCValidation implements EmailValidation
|
||
|
{
|
||
|
/**
|
||
|
* @var EmailParser
|
||
|
*/
|
||
|
private $parser;
|
||
|
|
||
|
/**
|
||
|
* @var array
|
||
|
*/
|
||
|
private $warnings = [];
|
||
|
|
||
|
/**
|
||
|
* @var InvalidEmail
|
||
|
*/
|
||
|
private $error;
|
||
|
|
||
|
public function isValid($email, EmailLexer $emailLexer)
|
||
|
{
|
||
|
$this->parser = new EmailParser($emailLexer);
|
||
|
try {
|
||
|
$this->parser->parse((string)$email);
|
||
|
} catch (InvalidEmail $invalid) {
|
||
|
$this->error = $invalid;
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
$this->warnings = $this->parser->getWarnings();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public function getError()
|
||
|
{
|
||
|
return $this->error;
|
||
|
}
|
||
|
|
||
|
public function getWarnings()
|
||
|
{
|
||
|
return $this->warnings;
|
||
|
}
|
||
|
}
|