Skip to content

Commit 36b27ff

Browse files
committed
Rename Interface name
1 parent 8492efe commit 36b27ff

21 files changed

+188
-193
lines changed

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ You can't regex that.
2222
PHP Domain Parser is compliant around:
2323

2424
- accurate Public Suffix List based parsing.
25-
- accurate Root Zone Database parsing.
25+
- accurate IANA Top Level Domain List parsing.
2626

2727
## Installation
2828

@@ -48,7 +48,7 @@ You need:
4848
This library can resolve a domain against:
4949

5050
- The [Public Suffix List](https://publicsuffix.org/)
51-
- The [IANA Root Zone Database](https://www.iana.org/domains/root/files)
51+
- The [IANA Top Level Domain List](https://www.iana.org/domains/root/files)
5252

5353
In both cases this is done using the `resolve` method implemented on the resource
5454
instance. The method returns a `Pdp\ResolvedDomain` object which represents the
@@ -72,15 +72,15 @@ echo $result->suffix()->toString(); //display 'okinawa.jp';
7272
$result->suffix()->isICANN(); //return true;
7373
~~~
7474

75-
For the [IANA Root Zone Database](https://www.iana.org/domains/root/files),
75+
For the [IANA Top Level Domain List](https://www.iana.org/domains/root/files),
7676
the `Pdp\TopLevelDomains` class is use instead:
7777

7878
~~~php
7979
use Pdp\TopLevelDomains;
8080

81-
$rootZoneDatabase = TopLevelDomains::fromPath('/path/to/cache/tlds-alpha-by-domain.txt');
81+
$topLevelDomains = TopLevelDomains::fromPath('/path/to/cache/tlds-alpha-by-domain.txt');
8282

83-
$result = $rootZoneDatabase->resolve('www.PreF.OkiNawA.jP');
83+
$result = $topLevelDomains->resolve('www.PreF.OkiNawA.jP');
8484
echo $result->domain()->toString(); //display 'www.pref.okinawa.jp';
8585
echo $result->suffix()->toString(); //display 'jp';
8686
echo $result->secondLevelDomain()->toString(); //display 'okinawa';
@@ -100,8 +100,8 @@ namely:
100100
- `Rules::getICANNDomain`
101101
- `Rules::getPrivateDomain`
102102

103-
for the Public Suffix List and the following method for the Root Zone
104-
Database:
103+
for the Public Suffix List and the following method for the Top Level
104+
Domain List:
105105

106106
- `TopLevelDomains::getIANADomain`
107107

@@ -132,8 +132,8 @@ $result->suffix()->value(); // returns null
132132
$result->suffix()->isKnown(); // returns false
133133
// will not throw but its public suffix value equal to NULL
134134

135-
$rootZoneDatabase = TopLevelDomains::fromPath('/path/to/cache/public-suffix-list.dat');
136-
$rootZoneDatabase->getIANADomain('com');
135+
$topLevelDomains = TopLevelDomains::fromPath('/path/to/cache/public-suffix-list.dat');
136+
$topLevelDomains->getIANADomain('com');
137137
// will not throw because the domain syntax is invalid (ie: does not support public suffix)
138138
~~~
139139

@@ -150,16 +150,16 @@ resolver exposes the `JsonSerialize` method.
150150

151151
**WARNING:**
152152

153-
**You should never use resolve domain name this way in production, without, at
153+
**You should never resolve domain name this way in production, without, at
154154
least, a caching mechanism to reduce PSL downloads.**
155155

156156
**Using the Public Suffix List to determine what is a valid domain name and what
157157
isn't is dangerous, particularly in these days when new gTLDs are arriving at a
158158
rapid pace.**
159159

160160
**If you are looking to know the validity of a Top Level Domain, the
161-
IANA Root Zone Database is the proper source for this information or alternatively
162-
consider using directly the DNS.**
161+
IANA Top Level Domain List is the proper source for this information or
162+
alternatively consider using directly the DNS.**
163163

164164
**If you must use this library for any of the above purposes, please consider
165165
integrating an updating mechanism into your software.**
@@ -172,13 +172,13 @@ Whichever methods chosen to resolve the domain on success, the package will
172172
return a `Pdp\ResolvedDomain` instance.
173173

174174
The `Pdp\ResolvedDomain` decorates the `Pdp\Domain` class resolved but also
175-
gives access as separate methods to the domain different components.
175+
gives access as separate methods to the domain different components.
176176

177177
~~~php
178-
use Pdp\RootZoneDatabase;
178+
use Pdp\TopLevelDomains;
179179

180-
/** @var RootZoneDatabase $rootZoneDatabase */
181-
$result = $rootZoneDatabase->resolve('www.PreF.OkiNawA.jP');
180+
/** @var TopLevelDomains $topLevelDomains */
181+
$result = $topLevelDomains->resolve('www.PreF.OkiNawA.jP');
182182
echo $result->domain()->toString(); //display 'www.pref.okinawa.jp';
183183
echo $result->suffix()->toString(); //display 'jp';
184184
echo $result->secondLevelDomain()->toString(); //display 'okinawa';
@@ -192,9 +192,9 @@ You can modify the returned `Pdp\ResolvedDomain` instance using the following me
192192
~~~php
193193
<?php
194194

195-
use Pdp\PublicSuffixList;
195+
use Pdp\Rules;
196196

197-
/** @var PublicSuffixList $publicSuffixList */
197+
/** @var Rules $publicSuffixList */
198198
$result = $publicSuffixList->resolve('shop.example.com');
199199
$altResult = $result
200200
->withSubDomain('foo.bar')
@@ -221,9 +221,9 @@ origin.
221221

222222
~~~php
223223
<?php
224-
use Pdp\PublicSuffixList;
224+
use Pdp\Rules;
225225

226-
/** @var PublicSuffixList $publicSuffixList */
226+
/** @var Rules $publicSuffixList */
227227
$suffix = $publicSuffixList->resolve('example.github.io')->suffix();
228228

229229
echo $suffix->domain()->toString(); //display 'github.io';
@@ -237,7 +237,7 @@ $suffix->isKnown(); //will return true
237237
The public suffix state depends on its origin:
238238

239239
- `isKnown` returns `true` if the value is present in the data resource.
240-
- `isIANA` returns `true` if the value is present in the Root Zone Database.
240+
- `isIANA` returns `true` if the value is present in the IANA Top Level Domain List.
241241
- `isPublicSuffix` returns `true` if the value is present in the Public Suffix List.
242242
- `isICANN` returns `true` if the value is present in the Public Suffix List ICANN section.
243243
- `isPrivate` returns `true` if the value is present in the Public Suffix List private section.
@@ -279,9 +279,9 @@ manipulating domain labels. You can access the object using the following method
279279

280280
~~~php
281281
<?php
282-
use Pdp\PublicSuffixList;
282+
use Pdp\Rules;
283283

284-
/** @var PublicSuffixList $publicSuffixList */
284+
/** @var Rules $publicSuffixList */
285285
$result = $publicSuffixList->resolve('www.bbc.co.uk');
286286
$domain = $result->domain();
287287
echo $domain->toString(); // display 'www.bbc.co.uk'
@@ -307,9 +307,9 @@ following methods:
307307

308308
~~~php
309309
<?php
310-
use Pdp\PublicSuffixList;
310+
use Pdp\Rules;
311311

312-
/** @var PublicSuffixList $publicSuffixList */
312+
/** @var Rules $publicSuffixList */
313313
$domain = $publicSuffixList->resolve('www.ExAmpLE.cOM')->domain();
314314

315315
$newDomain = $domain
@@ -353,9 +353,9 @@ IDNA Compatibility Processing. Domain objects expose a `toAscii` and a
353353

354354
~~~php
355355
<?php
356-
use Pdp\PublicSuffixList;
356+
use Pdp\Rules;
357357

358-
/** @var PublicSuffixList $publicSuffixList */
358+
/** @var Rules $publicSuffixList */
359359
$unicodeDomain = $publicSuffixList->resolve('bébé.be')->domain();
360360
echo $unicodeDomain->toString(); // returns 'bébé.be'
361361

@@ -416,15 +416,15 @@ nevertheless, the library comes bundle with a **optional service** which
416416
enables resolving domain name without the constant network overhead of
417417
continuously downloading the remote databases.
418418

419-
The interfaces defined under the `Pdp\Storage` namespace enable
420-
integrating a database managing system and provide an implementation example
419+
The interfaces and classes defined under the `Pdp\Storage` namespace enable
420+
integrating a resource managing system and provide an implementation example
421421
using PHP-FIG PSR interfaces.
422422

423423
#### Using PHP-FIG interfaces
424424

425425
The `Pdp\Storage\PsrStorageFactory` enables returning storage instances that
426-
retrieve, convert and cache the Public Suffix List and the IANA Root
427-
Zone Database using standard interfaces published by the PHP-FIG.
426+
retrieve, convert and cache the Public Suffix List and the IANA Top Level
427+
Domain List using standard interfaces published by the PHP-FIG.
428428

429429
To work as intended, the `Pdp\Storage\PsrStorageFactory` constructor requires:
430430

@@ -465,7 +465,7 @@ For the purpose of this example we will use our PSR powered solution with:
465465
We will cache both external sources for 24 hours in a PostgreSQL database.
466466

467467
You are free to use other libraries/solutions/settings as long as they
468-
implement the required PSR interfaces.
468+
implement the required PSR interfaces.
469469

470470
~~~php
471471
<?php
@@ -496,7 +496,7 @@ $cachePrefix = 'pdp_';
496496
$cacheTtl = new DateInterval('P1D');
497497
$factory = new PsrStorageFactory($cache, $client, $requestFactory);
498498
$pslStorage = $factory->createPublicSuffixListStorage($cachePrefix, $cacheTtl);
499-
$rzdStorage = $factory->createRootZoneDatabaseStorage($cachePrefix, $cacheTtl);
499+
$rzdStorage = $factory->createTopLevelDomainListStorage($cachePrefix, $cacheTtl);
500500

501501
// if you need to force refreshing the rules
502502
// before calling them (to use in a refresh script)
@@ -507,8 +507,8 @@ $publicSuffixList = $pslStorage->get(PsrStorageFactory::PUBLIC_SUFFIX_LIST_URI);
507507
// if you need to force refreshing the rules
508508
// before calling them (to use in a refresh script)
509509
// uncomment this part or adapt it to you script logic
510-
// $rzdStorage->delete(PsrStorageFactory::ROOT_ZONE_DATABASE_URI);
511-
$rootZoneDatabase = $rzdStorage->get(PsrStorageFactory::ROOT_ZONE_DATABASE_URI);
510+
// $rzdStorage->delete(PsrStorageFactory::TOP_LEVEL_DOMAIN_LIST_URI);
511+
$topLevelDomains = $rzdStorage->get(PsrStorageFactory::TOP_LEVEL_DOMAIN_LIST_URI);
512512
~~~
513513

514514
**Be sure to adapt the following code to your own application.
@@ -520,8 +520,8 @@ code in your application.**
520520

521521
### Automatic Updates
522522

523-
It is important to always have an up to date Public Suffix List and Root Zone
524-
Database.
523+
It is important to always have an up to date Public Suffix List and Top Level
524+
Domain List.
525525
This library no longer provide an out of the box script to do so as implementing
526526
such a job heavily depends on your application setup.
527527
You can use the above example script as a starting point to implement such a job.

src/EffectiveTopLevelDomain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface EffectiveTopLevelDomain extends Host, DomainNameProvider
1212
public function isKnown(): bool;
1313

1414
/**
15-
* Tells whether the effective TLD has a matching rule in the IANA Root Zone Database.
15+
* Tells whether the effective TLD has a matching rule in the IANA Top Level Domain List.
1616
*/
1717
public function isIANA(): bool;
1818

src/Storage/PsrStorageFactory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
use Psr\SimpleCache\CacheInterface;
1010

1111
final class PsrStorageFactory implements
12-
RemoteStorageURL,
12+
ResourceUri,
1313
PublicSuffixListStorageFactory,
14-
RootZoneDatabaseStorageFactory
14+
TopLevelDomainListStorageFactory
1515
{
1616
private CacheInterface $cache;
1717

@@ -40,11 +40,11 @@ public function createPublicSuffixListStorage(string $cachePrefix = '', $cacheTt
4040
/**
4141
* @param mixed $cacheTtl The cache TTL
4242
*/
43-
public function createRootZoneDatabaseStorage(string $cachePrefix = '', $cacheTtl = null): RootZoneDatabaseStorage
43+
public function createTopLevelDomainListStorage(string $cachePrefix = '', $cacheTtl = null): TopLevelDomainListStorage
4444
{
4545
return new TopLevelDomainsStorage(
46-
new RootZoneDatabasePsr16Cache($this->cache, $cachePrefix, $cacheTtl),
47-
new RootZoneDatabasePsr18Client($this->client, $this->requestFactory)
46+
new TopLevelDomainListPsr16Cache($this->cache, $cachePrefix, $cacheTtl),
47+
new TopLevelDomainListPsr18Client($this->client, $this->requestFactory)
4848
);
4949
}
5050
}

src/Storage/PsrStorageFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function setUp(): void
2424

2525
public function testItCanReturnARootZoneDatabaseStorageInstance(): void
2626
{
27-
$instance = $this->factory->createRootZoneDatabaseStorage('foobar', '1 DAY');
27+
$instance = $this->factory->createTopLevelDomainListStorage('foobar', '1 DAY');
2828

2929
self::assertInstanceOf(TopLevelDomainsStorage::class, $instance);
3030
}

src/Storage/RemoteStorageURL.php renamed to src/Storage/ResourceUri.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Pdp\Storage;
66

7-
interface RemoteStorageURL
7+
interface ResourceUri
88
{
99
public const PUBLIC_SUFFIX_LIST_URI = 'https://publicsuffix.org/list/public_suffix_list.dat';
1010

11-
public const ROOT_ZONE_DATABASE_URI = 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt';
11+
public const TOP_LEVEL_DOMAIN_LIST_URI = 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt';
1212
}

src/Storage/RootZoneDatabaseClient.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Storage/RootZoneDatabaseStorageFactory.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Storage/RootZoneDatabaseCache.php renamed to src/Storage/TopLevelDomainListCache.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55
namespace Pdp\Storage;
66

7-
use Pdp\RootZoneDatabase;
7+
use Pdp\TopLevelDomainList;
88

9-
interface RootZoneDatabaseCache
9+
interface TopLevelDomainListCache
1010
{
1111
/**
12-
* Retrieves the Root Zone Database from the Cache.
12+
* Retrieves the Top Level Domain List from the Cache.
1313
*/
14-
public function fetch(string $uri): ?RootZoneDatabase;
14+
public function fetch(string $uri): ?TopLevelDomainList;
1515

1616
/**
17-
* Cache the Root Zone Database.
17+
* Cache the Top Level Domain List.
1818
*
1919
* If a local cache already exists, it will be overwritten.
2020
*
2121
* Returns true if the action was successful, false otherwise
2222
*/
23-
public function remember(string $uri, RootZoneDatabase $rootZoneDatabase): bool;
23+
public function remember(string $uri, TopLevelDomainList $topLevelDomainList): bool;
2424

2525
/**
26-
* Deletes the Root Zone Database entry.
26+
* Deletes the Top Level Domain List entry.
2727
*
2828
* Returns true if the action was successful, false otherwise
2929
*/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Pdp\Storage;
6+
7+
use Pdp\TopLevelDomainList;
8+
use Pdp\UnableToLoadTopLevelDomainList;
9+
10+
interface TopLevelDomainListClient
11+
{
12+
/**
13+
* @throws UnableToLoadTopLevelDomainList
14+
*/
15+
public function get(string $uri): TopLevelDomainList;
16+
}

0 commit comments

Comments
 (0)