You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo (new Domain('www.xn--bb-bjab.example.com'))->toAscii() // www.bébé.example.com
153
+
$domain->getAsciiIDNAOption(); // IDNA_DEFAULT
154
+
$domain->getUnicodeIDNAOption(); // IDNA_DEFAULT
155
155
~~~
156
156
157
157
The `Pdp\Domain` and `Pdp\PublicSuffix` objects are an immutable value object representing a valid domain name. These objects let's you access the domain properties.
@@ -175,8 +175,6 @@ public function Domain::withUnicodeIDNAOption(int $option): Domain
175
175
~~~
176
176
177
177
~~~php
178
-
<?php
179
-
180
178
use Pdp\Domain;
181
179
182
180
$domain = new Domain('www.bébé.be');
@@ -202,8 +200,6 @@ Because the `Pdp\Domain` object is immutable:
202
200
The `Pdp\Domain` object can tell whether a public suffix can be attached to it using the `Pdp\Domain::isResolvable` method.
203
201
204
202
~~~php
205
-
<?php
206
-
207
203
use Pdp\Domain;
208
204
209
205
$domain = new Domain('www.ExAmple.com');
@@ -258,21 +254,25 @@ namespace Pdp;
258
254
259
255
final class Rules
260
256
{
257
+
public function __construct(
258
+
array $rules,
259
+
int $asciiIDNAOption = IDNA_DEFAULT,
260
+
int $unicodeIDNAOption = IDNA_DEFAULT
261
+
): void
262
+
261
263
public static function createFromPath(
262
-
string $path, $context = null,
264
+
string $path,
265
+
resource $context = null,
263
266
int $asciiIDNAOption = IDNA_DEFAULT,
264
267
int $unicodeIDNAOption = IDNA_DEFAULT
265
268
): Rules
269
+
266
270
public static function createFromString(
267
271
string $content,
268
272
int $asciiIDNAOption = IDNA_DEFAULT,
269
273
int $unicodeIDNAOption = IDNA_DEFAULT
270
274
): Rules
271
-
public function __construct(
272
-
array $rules,
273
-
int $asciiIDNAOption = IDNA_DEFAULT,
274
-
int $unicodeIDNAOption = IDNA_DEFAULT
275
-
): void
275
+
276
276
public function resolve($domain, string $section = ''): Domain
277
277
public function getPublicSuffix($domain, string $section = ''): PublicSuffix
278
278
public function getAsciiIDNAOption(): int
@@ -356,9 +356,17 @@ namespace Pdp;
356
356
357
357
final class TopLevelDomains implements Countable, IteratorAggregate
358
358
{
359
+
public function __construct(
360
+
array $records,
361
+
string $version,
362
+
DateTimeInterface $modifiedDate,
363
+
int $asciiIDNAOption = IDNA_DEFAULT,
364
+
int $unicodeIDNAOption = IDNA_DEFAULT
365
+
): void
366
+
359
367
public static function createFromPath(
360
368
string $path,
361
-
$context = null,
369
+
resource $context = null,
362
370
int $asciiIDNAOption = IDNA_DEFAULT,
363
371
int $unicodeIDNAOption = IDNA_DEFAULT
364
372
): TopLevelDomains
@@ -369,14 +377,6 @@ final class TopLevelDomains implements Countable, IteratorAggregate
369
377
int $unicodeIDNAOption = IDNA_DEFAULT
370
378
): TopLevelDomains
371
379
372
-
public function __construct(
373
-
array $records,
374
-
string $version,
375
-
DateTimeInterface $modifiedDate,
376
-
int $asciiIDNAOption = IDNA_DEFAULT,
377
-
int $unicodeIDNAOption = IDNA_DEFAULT
378
-
)
379
-
380
380
public function resolve($domain): Domain
381
381
public function contains($domain): bool
382
382
public function isEmpty(): bool
@@ -392,12 +392,12 @@ The `Pdp\TopLevelDomains` object is responsible for top level domain resolution
392
392
**THIS EXAMPLE ILLUSTRATES HOW THE OBJECT WORK BUT SHOULD BE AVOIDED IN PRODUCTON**
@@ -477,8 +477,6 @@ The package comes bundle with:
477
477
#### Refreshing the cached PSL and TLD data
478
478
479
479
~~~php
480
-
<?php
481
-
482
480
public Manager::refreshRules(string $source_url = self::PSL_URL, $ttl = null): bool
483
481
public Manager::refreshTLD(string $source_url = self::RZD_URL, $ttl = null): bool
484
482
~~~
@@ -500,17 +498,15 @@ if ($retval) {
500
498
#### Returning `Pdp\Rules` and `Pdp\TopLevelDomains` objects
501
499
502
500
~~~php
503
-
<?php
504
-
505
501
public Manager::getRules(
506
-
string $source_url = self::PSL_URL,
502
+
string $url = self::PSL_URL,
507
503
$ttl = null,
508
504
int $asciiIDNAOption = IDNA_DEFAULT,
509
505
int $unicodeIDNAOption = IDNA_DEFAULT
510
506
): Rules
511
507
512
508
public Manager::getTLDs(
513
-
string $source_url = self::RZD_URL,
509
+
string $url = self::RZD_URL,
514
510
$ttl = null,
515
511
int $asciiIDNAOption = IDNA_DEFAULT,
516
512
int $unicodeIDNAOption = IDNA_DEFAULT
@@ -519,14 +515,14 @@ public Manager::getTLDs(
519
515
520
516
These methods returns a `Pdp\Rules` or `Pdp\TopLevelDomains` objects seeded with their corresponding data fetch from the cache or from the external resources depending on the submitted `$ttl` argument.
521
517
522
-
These methods take an optional `$source_url` argument which specifies the PSL source URL. If no local cache exists for the submitted source URL, the method will:
518
+
These methods take an optional `$url` argument which specifies the PSL source URL. If no local cache exists for the submitted source URL, the method will:
523
519
524
520
1. call `Manager::refreshRules` with the given URL and `$ttl` argument to update its local cache
525
521
2. instantiate the `Rules` or the `TopLevelDomains` objects with the newly cached data.
526
522
527
523
On error, theses methods will throw an `Pdp\Exception`.
528
524
529
-
**since 5.5***
525
+
**since version 5.5**
530
526
531
527
the following optional arguments are added to the methods:
532
528
@@ -540,8 +536,6 @@ They are used when instantiated the returned object.
540
536
**THIS IS THE RECOMMENDED WAY OF USING THE LIBRARY**
541
537
542
538
~~~php
543
-
<?php
544
-
545
539
$manager = new Pdp\Manager(new Pdp\Cache(), new Pdp\CurlHttpClient());
0 commit comments