php-extended/php-tld-object

An implementation of the php-tld-interface library

7.0.2 2024-04-08 18:41 UTC

README

An implementation of the php-tld-interface library.

coverage build status

Installation

The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.

  • Download composer.phar from their website.
  • Then run the following command to install this library as dependency :
  • php composer.phar php-extended/php-tld-object ^7

Basic Usage

You may use this library this way to build a hierarchy :


use PhpExtended\Tld\TopLevelDomainHierarchy;
use PhpExtended\Tld\TopLevelDomainNode;

$hierarchy = new TopLevelDomainHierarchy();
$hierarchy->addNode(new TopLevelDomainNode('edu'));
$com = new TopLevelDomainNode('com');
$com->addNode(new TopLevelDomainNode('example');
$hierarchy->addNode($com);

$hierarchy->isTld('example.com'); // true
$hierarchy->isTld('example.edu'); // false

License

MIT (See license file).