You are here

public function EmailValidator::isValid in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/egulias/email-validator/src/Egulias/EmailValidator/EmailValidator.php \Egulias\EmailValidator\EmailValidator::isValid()

File

vendor/egulias/email-validator/src/Egulias/EmailValidator/EmailValidator.php, line 76

Class

EmailValidator
EmailValidator

Namespace

Egulias\EmailValidator

Code

public function isValid($email, $checkDNS = false, $strict = false) {
  try {
    $this->parser
      ->parse((string) $email);
    $this->warnings = $this->parser
      ->getWarnings();
  } catch (\Exception $e) {
    $rClass = new \ReflectionClass($this);
    $this->error = $rClass
      ->getConstant($e
      ->getMessage());
    return false;
  }
  $dns = true;
  if ($checkDNS) {
    $dns = $this
      ->checkDNS();
  }
  if ($this
    ->hasWarnings() && (int) max($this->warnings) > $this->threshold) {
    $this->error = self::ERR_DEPREC_REACHED;
    return false;
  }
  return !$strict || !$this
    ->hasWarnings() && $dns;
}