php-whois icon indicating copy to clipboard operation
php-whois copied to clipboard

[feature] using library as a parser via StringLoader

Open deepika-maj opened this issue 4 years ago • 1 comments

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
}

deepika-maj avatar Jun 03 '20 14:06 deepika-maj

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.

mewejo avatar Jan 07 '22 11:01 mewejo

https://github.com/io-developer/php-whois/blob/master/tests/Iodev/Whois/Loaders/FakeSocketLoader.php

io-developer avatar Jan 09 '23 15:01 io-developer