| Conditions | 3 | 
| Paths | 3 | 
| Total Lines | 23 | 
| Code Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); | ||
| 43 | protected function validateNameServers(Hostname $hostname) | ||
| 44 |     { | ||
| 45 | $info = $this->whois->loadDomainInfo($hostname->domainName()); | ||
| 46 |         if (!$info instanceof DomainInfo) { | ||
|  | |||
| 47 |             throw new \Exception("Could not load domain info of $hostname"); | ||
| 48 | } | ||
| 49 | $nameServers = $info->getNameServers(); | ||
| 50 | Assertion::isArray( | ||
| 51 | $nameServers, | ||
| 52 | "Expected array. Got: ".var_export($nameServers, true) | ||
| 53 | ); | ||
| 54 | Assertion::greaterThan( | ||
| 55 | count($nameServers), | ||
| 56 | 0, | ||
| 57 | "Expected 1 or more name servers. Got ".count($nameServers) | ||
| 58 | ); | ||
| 59 |         foreach ($nameServers as $nameServer) { | ||
| 60 | $nameServer = Hostname::parse($nameServer); | ||
| 61 | Assertion::regex( | ||
| 62 | $nameServer->toString(), | ||
| 63 | "/ns[0-9]\.digitalocean\.com/", | ||
| 64 |                 "'{$nameServer->toString()}' is not a Digital Ocean's name server in the ". | ||
| 65 | "form of ns[0-9].digitalocean.com" | ||
| 66 | ); | ||
| 70 |