Total Complexity | 7 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
10 | class DnsValidator |
||
11 | { |
||
12 | /** |
||
13 | * @var Whois |
||
14 | */ |
||
15 | private $whois; |
||
16 | /** |
||
17 | * @var Env |
||
18 | */ |
||
19 | private $env; |
||
20 | |||
21 | public function __construct(Whois $whois, Env $env) |
||
22 | { |
||
23 | $this->whois = $whois; |
||
24 | $this->env = $env; |
||
25 | } |
||
26 | |||
27 | public function validateHost(Hostname $hostname) |
||
28 | { |
||
29 | if ($this->env->get(SkipDnsValidation::SKIP_DNS_VALIDATION)) { |
||
30 | return; |
||
31 | } |
||
32 | |||
33 | try { |
||
34 | $this->validateNameServers($hostname->toRoot()); |
||
35 | } catch (\Throwable $domainException) { |
||
36 | $message = []; |
||
37 | $message[] = "Failed to validate name servers for '$hostname':"; |
||
38 | $message[] = $domainException->getMessage(); |
||
39 | throw new \Exception(implode("\n", $message)); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | protected function validateNameServers(Hostname $hostname) |
||
66 | ); |
||
67 | } |
||
68 | } |
||
70 |