Conditions | 2 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2.1481 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | public function getRecords(string $host, int $type): DNSRecords |
||
14 | 12 | { |
|
15 | 12 | // A workaround to fix https://bugs.php.net/bug.php?id=73149 |
|
16 | /** @psalm-suppress InvalidArgument */ |
||
17 | 12 | set_error_handler( |
|
18 | 12 | static function (int $errorLevel, string $errorMessage): never { |
|
19 | throw new \RuntimeException("Unable to get DNS record for the host: $errorMessage"); |
||
20 | } |
||
21 | 12 | ); |
|
22 | try { |
||
23 | // Get all MX, A and AAAA DNS records for host |
||
24 | return new DNSRecords(dns_get_record($host, $type)); |
||
25 | 12 | } catch (\RuntimeException $exception) { |
|
26 | return new DNSRecords([], true); |
||
27 | } finally { |
||
28 | restore_error_handler(); |
||
29 | } |
||
32 |