Skip to content

Commit 77e760a

Browse files
author
Dave Earley
authored
Merge pull request #10 from k00ni/k00ni-feature-use-disposable-email-domains
Use latest index.json from ivolo/disposable-email-domains instead of manually updating it
2 parents dea5ef8 + 80422ae commit 77e760a

File tree

3 files changed

+13
-5328
lines changed

3 files changed

+13
-5328
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"disposable email check"
1111
],
1212
"require": {
13-
"php": "^7.0"
13+
"php": "^7.0",
14+
"ivolo/disposable-email-domains": "^1.0"
1415
},
1516
"require-dev": {
1617
"mockery/mockery": "^0.9.9",

src/EmailDataProvider.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ class EmailDataProvider implements EmailDataProviderInterface
88
{
99
const EMAIL_PROVIDERS = __DIR__ . '/data/email-providers.php';
1010
const TOP_LEVEL_DOMAINS = __DIR__ . '/data/top-level-domains.php';
11-
const DISPOSABLE_EMAIL_PROVIDERS = __DIR__ . '/data/disposable-email-providers.php';
1211
const ROLE_BASED_EMAIL_PREFIXES = __DIR__ . '/data/role-based-email-prefixes.php';
1312

13+
protected $disposable_email_providers = null;
14+
1415
/**
1516
* {@inheritdoc}
1617
*/
@@ -32,7 +33,14 @@ public function getTopLevelDomains(): array
3233
*/
3334
public function getDisposableEmailProviders(): array
3435
{
35-
return include self::DISPOSABLE_EMAIL_PROVIDERS;
36+
if (null == $this->disposable_email_providers) {
37+
// load index with known disposable email providers
38+
$index = \file_get_contents(__DIR__.'/../vendor/ivolo/disposable-email-domains/index.json');
39+
40+
$this->disposable_email_providers = \json_decode($index, true);
41+
}
42+
43+
return $this->disposable_email_providers;
3644
}
3745

3846
/**
@@ -42,4 +50,4 @@ public function getRoleEmailPrefixes(): array
4250
{
4351
return include self::ROLE_BASED_EMAIL_PREFIXES;
4452
}
45-
}
53+
}

0 commit comments

Comments
 (0)