PHP code example of daveearley / daves-email-validation-tool

1. Go to this page and download the library: Download daveearley/daves-email-validation-tool library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daveearley / daves-email-validation-tool example snippets


// Include the composer autoloader
lValidatorFactory::create('[email protected]');

$jsonResult = $validator->getValidationResults()->asJson();
$arrayResult = $validator->getValidationResults()->asArray();

echo $jsonResult;




namespace EmailValidation\Validations;

class GmailValidator extends Validator
{
    public function getValidatorName(): string
    {
        return 'is_gmail';
    }

    public function getResultResponse(): bool
    {
        $hostName = $this->getEmailAddress()->getHostPart();
        return strpos($hostName, 'gmail.com') !== false;
    }
}



use EmailValidation\Validations\GmailValidator;

eate('[email protected]');

$validator->registerValidator(new GmailValidator());

echo $validator->getValidationResults()->asJson();



declare(strict_types=1);

namespace EmailValidation;

class CustomEmailDataProvider implements EmailDataProviderInterface
{
    public function getEmailProviders(): array
    {
        return ['custom.com'];
    }

    public function getTopLevelDomains(): array
    {
        return ['custom'];
    }

    public function getDisposableEmailProviders(): array
    {
        return ['custom.com', 'another.com'];
    }

    public function getRoleEmailPrefixes(): array
    {
        return ['custom'];
    }
}
shell
./scripts/update-dispsable-email-providers.php