php-whois
php-whois copied to clipboard
[feature] using library as a parser via StringLoader
Is it possible for you to add another loader, something like below, so that the library can be used as a parser without doing actual whois query.
<?php
namespace Iodev\Whois\Loaders;
class StringLoader implements ILoader
{
private $whoisText;
public function loadText($whoisHost, $query)
{
return $this->whoisText;
}
public function setWhoisText($whoisText)
{
$this->whoisText = $whoisText;
}
}
which can be used as:
$whoisClient = Factory::get()->createWhois(new StringLoader());
foreach ($records as $record) {
$whoisClient->getLoader()->setWhoisText($record['raw_whois_text']);
$whois = $whoisClient->loadDomainInfo($record['domain']);
// app logic
}
Bit late @deepika-maj, but you could do that with a custom loader as is. Just set your text on the loader and call the loadDomainInfo()
with a generic domain.
https://github.com/io-developer/php-whois/blob/master/tests/Iodev/Whois/Loaders/FakeSocketLoader.php