--- layout: default title: Public Suffix Resolver redirect_from: - /publicsuffix/rules/ --- Public Suffix Resolver ======= ## Rules and Domain The `Rules` constructor expects a `array` representation of the Public Suffix List. This `array` representation is constructed by the `ICANNSectionManager` and stored using a PSR-16 compliant cache. The `Rules` class resolves the submitted domain against the parsed rules from the PSL. This is done using the `Rules::resolve` method which returns a `League\Uri\PublicSuffix\Domain` object. The `Domain` getters method always return normalized value according to the domain status against the PSL rules.
~~~php getRules('https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat'); //$icann_rules is a League\Uri\PublicSuffix\Rules object $domain = $icann_rules->resolve('www.bbc.co.uk'); $domain->getDomain(); //returns 'www.bbc.co.uk' $domain->getPublicSuffix(); //returns 'co.uk' $domain->getRegistrableDomain(); //returns 'bbc.co.uk' $domain->getSubDomain(); //returns 'www' $domain->isValid(); //returns true ~~~ ## Helper function ~~~php getDomain(); //returns 'www.bbc.co.uk' $domain->getPublicSuffix(); //returns 'co.uk' $domain->getRegistrableDomain(); //returns 'bbc.co.uk' $domain->getSubDomain(); //returns 'www' $domain->isValid(); //returns true ~~~