[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/composer/vendor/egulias/email-validator/EmailValidator/ -> EmailValidator.php (source)

   1  <?php
   2  
   3  namespace Egulias\EmailValidator;
   4  
   5  use Egulias\EmailValidator\Exception\InvalidEmail;
   6  use Egulias\EmailValidator\Validation\EmailValidation;
   7  
   8  class EmailValidator
   9  {
  10      /**
  11       * @var EmailLexer
  12       */
  13      private $lexer;
  14  
  15      /**
  16       * @var array
  17       */
  18      protected $warnings;
  19  
  20      /**
  21       * @var InvalidEmail
  22       */
  23      protected $error;
  24  
  25      public function __construct()
  26      {
  27          $this->lexer = new EmailLexer();
  28      }
  29  
  30      /**
  31       * @param                 $email
  32       * @param EmailValidation $emailValidation
  33       * @return bool
  34       */
  35      public function isValid($email, EmailValidation $emailValidation)
  36      {
  37          $isValid = $emailValidation->isValid($email, $this->lexer);
  38          $this->warnings = $emailValidation->getWarnings();
  39          $this->error = $emailValidation->getError();
  40  
  41          return $isValid;
  42      }
  43  
  44      /**
  45       * @return boolean
  46       */
  47      public function hasWarnings()
  48      {
  49          return !empty($this->warnings);
  50      }
  51  
  52      /**
  53       * @return array
  54       */
  55      public function getWarnings()
  56      {
  57          return $this->warnings;
  58      }
  59  
  60      /**
  61       * @return InvalidEmail
  62       */
  63      public function getError()
  64      {
  65          return $this->error;
  66      }
  67  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1