-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
100 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
namespace MallardDuck\Whois\WhoisServerList; | ||
|
||
use MallardDuck\Whois\Exceptions\MissingArgException; | ||
use MallardDuck\Whois\Exceptions\UnknownWhoisException; | ||
|
||
/** | ||
* Whois Server List Locator Class | ||
* | ||
* This class loads a TLD whois list and allows for easy look up. | ||
* | ||
* @author mallardduck <[email protected]> | ||
* | ||
* @copyright lucidinternets.com 2018 | ||
* | ||
* @version 1.0.0 | ||
*/ | ||
class DomainLocator extends AbstractLocator | ||
{ | ||
|
||
/** | ||
* The path where the tld json file exists. | ||
* | ||
* @var string | ||
*/ | ||
protected $whoisListPath = __DIR__ . '/../../blobs/tld.json'; | ||
|
||
/** | ||
* Finds and returns the last match looked up. | ||
* | ||
* @param string $domain Either an ID or a username. | ||
* | ||
* @return self Returns the same instance for fluent usage. | ||
*/ | ||
public function findWhoisServer($domain) | ||
{ | ||
if (empty($domain)) { | ||
throw new MissingArgException("Must provide domain argument."); | ||
} | ||
|
||
$tldInfo = $this->whoisCollection->filter(function ($item, $key) use ($domain) { | ||
return preg_match('/'.$key.'/', $domain); | ||
}); | ||
if (empty($tldInfo->all())) { | ||
throw new UnknownWhoisException("This domain doesn't have a valid TLD whois server."); | ||
} | ||
$this->lastMatch = $tldInfo->all(); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters