NoRFCWarningsValidation.php 794 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Egulias\EmailValidator\Validation;
  3. use Egulias\EmailValidator\EmailLexer;
  4. use Egulias\EmailValidator\Exception\InvalidEmail;
  5. use Egulias\EmailValidator\Validation\Error\RFCWarnings;
  6. class NoRFCWarningsValidation extends RFCValidation
  7. {
  8. /**
  9. * @var InvalidEmail
  10. */
  11. private $error;
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function isValid($email, EmailLexer $emailLexer)
  16. {
  17. if (!parent::isValid($email, $emailLexer)) {
  18. return false;
  19. }
  20. if (empty($this->getWarnings())) {
  21. return true;
  22. }
  23. $this->error = new RFCWarnings();
  24. return false;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function getError()
  30. {
  31. return $this->error ?: parent::getError();
  32. }
  33. }