Skip to content

Commit 3c52d73

Browse files
committed
Update dependencies and refactor code for consistency and readability
1 parent 7c0aed9 commit 3c52d73

17 files changed

+153
-181
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"require-dev": {
3939
"phpunit/phpunit": "^9.3",
40-
"laravel/pint": "1.2.*",
40+
"laravel/pint": "1.25.*",
4141
"phpstan/phpstan": "1.9.x-dev"
4242
},
4343
"minimum-stability": "stable",

data/disposable-domains-manual.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
/**
44
* Manual Disposable Email Domains Configuration
5-
*
5+
*
66
* This file contains manually managed disposable email domains.
77
* You can add or remove domains here as needed.
8-
*
8+
*
99
* Last updated: 2024-01-01 00:00:00
1010
* Source: Manual configuration
1111
*/

data/disposable-domains.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
/**
44
* Disposable Email Domains
5-
*
5+
*
66
* This file contains a list of known Disposable Email Domains.
77
* Last updated: 2025-10-18 21:39:42
8-
*
8+
*
99
* Format: Indexed array of domain names
1010
*/
1111

data/free-domains.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
/**
44
* Free Email Domains
5-
*
5+
*
66
* This file contains a list of known Free Email Domains.
77
* Last updated: 2025-10-18 21:39:43
8-
*
8+
*
99
* Format: Indexed array of domain names
1010
*/
1111

import.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function fetchSource(string $sourceKey, array $sourceConfig, string $type): arra
307307
function fetchMartensonDomains(array $sourceConfig): array
308308
{
309309
try {
310-
$client = new \Utopia\Fetch\Client();
310+
$client = new \Utopia\Fetch\Client;
311311

312312
$response = $client->fetch(
313313
url: $sourceConfig['url'],
@@ -353,7 +353,7 @@ function fetchMartensonDomains(array $sourceConfig): array
353353
function fetchDisposableDomains(array $sourceConfig): array
354354
{
355355
try {
356-
$client = new \Utopia\Fetch\Client();
356+
$client = new \Utopia\Fetch\Client;
357357

358358
$response = $client->fetch(
359359
url: $sourceConfig['url'],
@@ -400,7 +400,7 @@ function fetchDisposableDomains(array $sourceConfig): array
400400
function fetchWesbosDomains(array $sourceConfig): array
401401
{
402402
try {
403-
$client = new \Utopia\Fetch\Client();
403+
$client = new \Utopia\Fetch\Client;
404404

405405
$response = $client->fetch(
406406
url: $sourceConfig['url'],
@@ -447,7 +447,7 @@ function fetchWesbosDomains(array $sourceConfig): array
447447
function fetchFakeFilterDomains(array $sourceConfig): array
448448
{
449449
try {
450-
$client = new \Utopia\Fetch\Client();
450+
$client = new \Utopia\Fetch\Client;
451451

452452
$response = $client->fetch(
453453
url: $sourceConfig['url'],
@@ -493,7 +493,7 @@ function fetchFakeFilterDomains(array $sourceConfig): array
493493
function fetchAdamLovingDomains(array $sourceConfig): array
494494
{
495495
try {
496-
$client = new \Utopia\Fetch\Client();
496+
$client = new \Utopia\Fetch\Client;
497497

498498
$response = $client->fetch(
499499
url: $sourceConfig['url'],
@@ -557,7 +557,7 @@ function loadManualDisposableDomains(array $sourceConfig): array
557557
function fetchKikobeatsDomains(array $sourceConfig): array
558558
{
559559
try {
560-
$client = new \Utopia\Fetch\Client();
560+
$client = new \Utopia\Fetch\Client;
561561

562562
$response = $client->fetch(
563563
url: $sourceConfig['url'],
@@ -855,7 +855,7 @@ function showPreview(array $currentDomains, array $newDomains): void
855855
}
856856

857857
// Setup CLI
858-
$cli = new CLI();
858+
$cli = new CLI;
859859

860860
// Disposable domains command
861861
$cli

src/Emails/Email.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ class Email
6464
public function __construct(string $email)
6565
{
6666
$this->email = \mb_strtolower(\trim($email));
67-
67+
6868
if (empty($this->email)) {
69-
throw new Exception("Email address cannot be empty");
69+
throw new Exception('Email address cannot be empty');
7070
}
7171

7272
$this->parts = \explode('@', $this->email);
7373

7474
if (count($this->parts) !== 2) {
75-
throw new Exception("'{$email}' must be a valid email address");
75+
throw new Exception('{$email} must be a valid email address');
7676
}
7777

7878
$this->local = $this->parts[0];
7979
$this->domain = $this->parts[1];
8080

8181
if (empty($this->local) || empty($this->domain)) {
82-
throw new Exception("'{$email}' must be a valid email address");
82+
throw new Exception('{$email} must be a valid email address');
8383
}
8484
}
8585

@@ -142,7 +142,7 @@ public function hasValidLocal(): bool
142142
}
143143

144144
// Check for valid characters in local part
145-
if (!preg_match('/^[a-zA-Z0-9._+-]+$/', $this->local)) {
145+
if (! preg_match('/^[a-zA-Z0-9._+-]+$/', $this->local)) {
146146
return false;
147147
}
148148

@@ -170,7 +170,7 @@ public function hasValidDomain(): bool
170170
}
171171

172172
// Check for valid domain format using filter_var
173-
if (!filter_var('test@' . $this->domain, FILTER_VALIDATE_EMAIL)) {
173+
if (! filter_var('test@'.$this->domain, FILTER_VALIDATE_EMAIL)) {
174174
return false;
175175
}
176176

@@ -183,7 +183,7 @@ public function hasValidDomain(): bool
183183
public function isDisposable(): bool
184184
{
185185
if (self::$disposableDomains === null) {
186-
self::$disposableDomains = include __DIR__ . '/../../data/disposable-domains.php';
186+
self::$disposableDomains = include __DIR__.'/../../data/disposable-domains.php';
187187
}
188188

189189
return in_array($this->domain, self::$disposableDomains);
@@ -195,7 +195,7 @@ public function isDisposable(): bool
195195
public function isFree(): bool
196196
{
197197
if (self::$freeDomains === null) {
198-
self::$freeDomains = include __DIR__ . '/../../data/free-domains.php';
198+
self::$freeDomains = include __DIR__.'/../../data/free-domains.php';
199199
}
200200

201201
return in_array($this->domain, self::$freeDomains);
@@ -206,7 +206,7 @@ public function isFree(): bool
206206
*/
207207
public function isCorporate(): bool
208208
{
209-
return !$this->isFree() && !$this->isDisposable();
209+
return ! $this->isFree() && ! $this->isDisposable();
210210
}
211211

212212
/**
@@ -215,7 +215,7 @@ public function isCorporate(): bool
215215
public function getProvider(): string
216216
{
217217
$domainParts = explode('.', $this->domain);
218-
218+
219219
if (count($domainParts) < 2) {
220220
return $this->domain;
221221
}
@@ -234,7 +234,7 @@ public function getProvider(): string
234234
public function getSubdomain(): string
235235
{
236236
$domainParts = explode('.', $this->domain);
237-
237+
238238
if (count($domainParts) <= 2) {
239239
return '';
240240
}
@@ -247,7 +247,7 @@ public function getSubdomain(): string
247247
*/
248248
public function hasSubdomain(): bool
249249
{
250-
return !empty($this->getSubdomain());
250+
return ! empty($this->getSubdomain());
251251
}
252252

253253
/**

src/Emails/Validator/Email.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class Email extends Validator
1616
* Get Description
1717
*
1818
* Returns validator description
19-
*
20-
* @return string
2119
*/
2220
public function getDescription(): string
2321
{
@@ -29,17 +27,17 @@ public function getDescription(): string
2927
*
3028
* Validation will pass when $value is a valid email address
3129
*
32-
* @param mixed $value
33-
* @return bool
30+
* @param mixed $value
3431
*/
3532
public function isValid($value): bool
3633
{
37-
if (!is_string($value)) {
34+
if (! is_string($value)) {
3835
return false;
3936
}
4037

4138
try {
4239
$email = new EmailParser($value);
40+
4341
return $email->isValid();
4442
} catch (\Exception $e) {
4543
return false;
@@ -50,8 +48,6 @@ public function isValid($value): bool
5048
* Is array
5149
*
5250
* Function will return true if object is array.
53-
*
54-
* @return bool
5551
*/
5652
public function isArray(): bool
5753
{
@@ -62,8 +58,6 @@ public function isArray(): bool
6258
* Get Type
6359
*
6460
* Returns validator type.
65-
*
66-
* @return string
6761
*/
6862
public function getType(): string
6963
{

src/Emails/Validator/EmailCorporate.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class EmailCorporate extends Validator
1616
* Get Description
1717
*
1818
* Returns validator description
19-
*
20-
* @return string
2119
*/
2220
public function getDescription(): string
2321
{
@@ -29,17 +27,17 @@ public function getDescription(): string
2927
*
3028
* Validation will pass when $value is a valid email address from a corporate domain
3129
*
32-
* @param mixed $value
33-
* @return bool
30+
* @param mixed $value
3431
*/
3532
public function isValid($value): bool
3633
{
37-
if (!is_string($value)) {
34+
if (! is_string($value)) {
3835
return false;
3936
}
4037

4138
try {
4239
$email = new Email($value);
40+
4341
return $email->isValid() && $email->isCorporate();
4442
} catch (\Exception $e) {
4543
return false;
@@ -50,8 +48,6 @@ public function isValid($value): bool
5048
* Is array
5149
*
5250
* Function will return true if object is array.
53-
*
54-
* @return bool
5551
*/
5652
public function isArray(): bool
5753
{
@@ -62,12 +58,9 @@ public function isArray(): bool
6258
* Get Type
6359
*
6460
* Returns validator type.
65-
*
66-
* @return string
6761
*/
6862
public function getType(): string
6963
{
7064
return self::TYPE_STRING;
7165
}
7266
}
73-

src/Emails/Validator/EmailDomain.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class EmailDomain extends Validator
1616
* Get Description
1717
*
1818
* Returns validator description
19-
*
20-
* @return string
2119
*/
2220
public function getDescription(): string
2321
{
@@ -29,17 +27,17 @@ public function getDescription(): string
2927
*
3028
* Validation will pass when $value is a valid email address with a valid domain
3129
*
32-
* @param mixed $value
33-
* @return bool
30+
* @param mixed $value
3431
*/
3532
public function isValid($value): bool
3633
{
37-
if (!is_string($value)) {
34+
if (! is_string($value)) {
3835
return false;
3936
}
4037

4138
try {
4239
$email = new Email($value);
40+
4341
return $email->isValid() && $email->hasValidDomain();
4442
} catch (\Exception $e) {
4543
return false;
@@ -50,8 +48,6 @@ public function isValid($value): bool
5048
* Is array
5149
*
5250
* Function will return true if object is array.
53-
*
54-
* @return bool
5551
*/
5652
public function isArray(): bool
5753
{
@@ -62,12 +58,9 @@ public function isArray(): bool
6258
* Get Type
6359
*
6460
* Returns validator type.
65-
*
66-
* @return string
6761
*/
6862
public function getType(): string
6963
{
7064
return self::TYPE_STRING;
7165
}
7266
}
73-

0 commit comments

Comments
 (0)