Skip to content

Commit 800bb9e

Browse files
Updated SingleValidation.php
Formatted the code to follow PSR standards.
1 parent 3f56069 commit 800bb9e

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/SingleValidation.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
<?php // MBV codeigniter and yii need to be updated as well
1+
<?php
22
namespace MailboxValidator;
33

44
class EmailValidation {
5-
private $apikey = '';
6-
private $singlevalidationapiurl = 'https://api.mailboxvalidator.com/v1/validation/single';
7-
private $disposableemailapiurl = 'https://api.mailboxvalidator.com/v1/email/disposable';
8-
private $freeemailapiurl = 'https://api.mailboxvalidator.com/v1/email/free';
5+
private $apiKey = '';
6+
private $singleValidationApiUrl = 'https://api.mailboxvalidator.com/v1/validation/single';
7+
private $disposableEmailApiUrl = 'https://api.mailboxvalidator.com/v1/email/disposable';
8+
private $freeEmailApiUrl = 'https://api.mailboxvalidator.com/v1/email/free';
99

1010
public function __construct($key) {
11-
$this->apikey = $key;
11+
$this->apiKey = $key;
1212
}
1313

1414
public function __destruct() {
1515

1616
}
1717

18+
/*
19+
* Validate whether an email address is a valid email or not.
20+
*/
1821
public function validateEmail($email) {
19-
/*
20-
* Validate whether an email address is a valid email or not.
21-
*/
2222
try {
23-
$params = [ 'email' => $email, 'key' => $this->apikey, 'format' => 'json' ];
23+
$params = [ 'email' => $email, 'key' => $this->apiKey, 'format' => 'json' ];
2424
$params2 = [];
2525
foreach ($params as $key => $value) {
2626
$params2[] = $key . '=' . rawurlencode($value);
2727
}
2828
$params = implode('&', $params2);
2929

30-
$results = file_get_contents($this->singlevalidationapiurl . '?' . $params);
30+
$results = file_get_contents($this->singleValidationApiUrl . '?' . $params);
3131

3232
if ($results !== false) {
3333
return json_decode($results);
3434
}
3535
else {
36-
return false;
36+
return null;
3737
}
3838
} catch (Exception $e) {
39-
return false;
39+
return null;
4040
}
4141
}
4242

43+
/*
44+
* Validate whether an email address is a disposable email or not.
45+
*/
4346
public function isDisposableEmail($email) {
44-
/*
45-
* Validate whether an email address is a disposable email or not.
46-
*/
4747
try {
48-
$params = [ 'email' => $email, 'key' => $this->apikey, 'format' => 'json' ];
48+
$params = [ 'email' => $email, 'key' => $this->apiKey, 'format' => 'json' ];
4949
$params2 = [];
5050
foreach ($params as $key => $value) {
5151
$params2[] = $key . '=' . rawurlencode($value);
5252
}
5353
$params = implode('&', $params2);
5454

55-
$results = file_get_contents($this->disposableemailapiurl . '?' . $params);
55+
$results = file_get_contents($this->disposableEmailApiUrl . '?' . $params);
5656

5757
if ($results !== false) {
5858
return json_decode($results);
@@ -65,19 +65,19 @@ public function isDisposableEmail($email) {
6565
}
6666
}
6767

68+
/*
69+
* Validate whether an email address is a free email or not.
70+
*/
6871
public function isFreeEmail($email) {
69-
/*
70-
* Validate whether an email address is a free email or not.
71-
*/
7272
try {
73-
$params = [ 'email' => $email, 'key' => $this->apikey, 'format' => 'json' ];
73+
$params = [ 'email' => $email, 'key' => $this->apiKey, 'format' => 'json' ];
7474
$params2 = [];
7575
foreach ($params as $key => $value) {
7676
$params2[] = $key . '=' . rawurlencode($value);
7777
}
7878
$params = implode('&', $params2);
7979

80-
$results = file_get_contents($this->freeemailapiurl . '?' . $params);
80+
$results = file_get_contents($this->freeEmailApiUrl . '?' . $params);
8181

8282
if ($results !== false) {
8383
return json_decode($results);

0 commit comments

Comments
 (0)