class CheckDnsService in Check DNS 8
Defines the CheckDns service.
Hierarchy
- class \Drupal\check_dns\CheckDnsService
Expanded class hierarchy of CheckDnsService
1 string reference to 'CheckDnsService'
1 service uses CheckDnsService
File
- src/
CheckDnsService.php, line 8
Namespace
Drupal\check_dnsView source
class CheckDnsService {
/**
* Constructs a new CheckDnsService.
*/
public function __construct() {
}
/**
* Validate email id and its DNS record.
*
* @param string $mail
* A mail to check.
*
* @return bool
* TRUE if email is valid and any records are found, FALSE otherwise.
*/
public function validateEmail($mail) {
// Validate e-mail.
if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
$mail = explode('@', $mail);
return $this
->validateHost(end($mail));
}
else {
return FALSE;
}
}
/**
* Validate whether a domain name exists or not.
*
* @param string $host
* A host to check.
*
* @return bool
* TRUE if any records are found, FALSE otherwise.
*/
public function validateHost(string $host) {
// Check the DNS records corresponding to the hostname or IP address.
$result = dns_check_record($host);
return $result;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CheckDnsService:: |
public | function | Validate email id and its DNS record. | |
CheckDnsService:: |
public | function | Validate whether a domain name exists or not. | |
CheckDnsService:: |
public | function | Constructs a new CheckDnsService. |