comparison vendor/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php
2
3 namespace Egulias\EmailValidator\Validation;
4
5 use Egulias\EmailValidator\EmailLexer;
6 use Egulias\EmailValidator\Exception\InvalidEmail;
7 use Egulias\EmailValidator\Validation\Error\SpoofEmail;
8 use \Spoofchecker;
9
10 class SpoofCheckValidation implements EmailValidation
11 {
12 /**
13 * @var InvalidEmail
14 */
15 private $error;
16
17 public function __construct()
18 {
19 if (!extension_loaded('intl')) {
20 throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));
21 }
22 }
23
24 public function isValid($email, EmailLexer $emailLexer)
25 {
26 $checker = new Spoofchecker();
27 $checker->setChecks(Spoofchecker::SINGLE_SCRIPT);
28
29 if ($checker->isSuspicious($email)) {
30 $this->error = new SpoofEmail();
31 }
32
33 return $this->error === null;
34 }
35
36 public function getError()
37 {
38 return $this->error;
39 }
40
41 public function getWarnings()
42 {
43 return [];
44 }
45 }