Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
namespace Egulias\EmailValidator\Validation;
3
 
4
class DNSGetRecordWrapper
5
{
6
    /**
7
     * @param string $host
8
     * @param int $type
9
     */
10
    public function getRecords(string $host, int $type) : DNSRecords
11
    {
12
        // A workaround to fix https://bugs.php.net/bug.php?id=73149
13
        /** @psalm-suppress InvalidArgument */
14
        set_error_handler(
15
            static function (int $errorLevel, string $errorMessage): ?bool {
16
                throw new \RuntimeException("Unable to get DNS record for the host: $errorMessage");
17
            }
18
        );
19
        try {
20
            // Get all MX, A and AAAA DNS records for host
21
            return new DNSRecords(dns_get_record($host, $type));
22
        } catch (\RuntimeException $exception) {
23
            return new DNSRecords([], true);
24
        } finally {
25
            restore_error_handler();
26
        }
27
    }
28
}