Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

SpoofCheckValidation.php

Namespace

Egulias\EmailValidator\Validation\Extra

File

vendor/egulias/email-validator/src/Validation/Extra/SpoofCheckValidation.php

View source
<?php

namespace Egulias\EmailValidator\Validation\Extra;

use Spoofchecker;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Result\SpoofEmail;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Validation\EmailValidation;
class SpoofCheckValidation implements EmailValidation {
    
    /**
     * @var InvalidEmail|null
     */
    private $error;
    public function __construct() {
        if (!extension_loaded('intl')) {
            throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));
        }
    }
    
    /**
     * @psalm-suppress InvalidArgument
     */
    public function isValid(string $email, EmailLexer $emailLexer) : bool {
        $checker = new Spoofchecker();
        $checker->setChecks(Spoofchecker::SINGLE_SCRIPT);
        if ($checker->isSuspicious($email)) {
            $this->error = new SpoofEmail();
        }
        return $this->error === null;
    }
    public function getError() : ?InvalidEmail {
        return $this->error;
    }
    public function getWarnings() : array {
        return [];
    }

}

Classes

Title Deprecated Summary
SpoofCheckValidation

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal