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
- Convert the Public Suffix List into a structure usable in PHP
53
+
- Resolve the domain against the given PSL rules
54
+
55
+
Conversion is done using the `Pdp\Converter` class.
48
56
49
57
~~~php
50
58
<?php
@@ -57,21 +65,19 @@ final class Converter
57
65
}
58
66
~~~
59
67
60
-
To resolve the submitted domain name we must first convert the Public Suffix List into a structure consommable by the library. This is done using the `Pdp\Converter` class which converts the list into an `array` representation that can be then used by the `Pdp\Rules` object.
68
+
The `Pdp\Converter::convert` method expect the raw content of a public suffix list and returns its `array` representation.
Once the PSL has been converted we can feed its data to a `Pdp\Rules` object which is responsible for resolving a given domain name against the PSL rules.
75
81
76
82
~~~php
77
83
<?php
@@ -91,11 +97,17 @@ final class Rules
91
97
92
98
The `Rules` constructor expects a `array` representation of the Public Suffix List. This `array` representation is constructed using the `Pdp\Converter` class.
93
99
94
-
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 `Pdp\Domain` object. The method expects
100
+
Domain name resolution is done using the `Rules::resolve` method which returns a `Pdp\Domain` object. The method expects
95
101
96
102
- a valid domain name as a string
97
-
- a string to optionnally specify which section of the PSL you want to validate the given domain against.
98
-
By default all sections are used `Rules::ALL_DOMAINS` but you can validate your domain against the ICANN only section (`Rules::ICANN_DOMAINS` or the private section (`Rules::PRIVATE_DOMAINS`) of the PSL.
103
+
- a string to optionnally specify which section of the PSL you want to validate the given domain against. The possible values are:
104
+
-`Rules::ALL_DOMAINS`, will validate the domain name against the full PSL.
105
+
-`Rules::ICANN_DOMAINS`, will validate the domain name againts the PSL ICANN section only.
106
+
-`Rules::PRIVATE_DOMAINS`, will validate the domain name againts the PSL PRIVATE section only.
107
+
108
+
By default, the full PSL is used.
109
+
110
+
An exception will be thrown if an undefined section is submitted otherwise, a `Pdp\Domain` object is returned.
99
111
100
112
~~~php
101
113
<?php
@@ -114,7 +126,8 @@ final class Domain implements JsonSerializable
114
126
115
127
The `Domain` getters method always return normalized value according to the domain status against the PSL rules.
116
128
117
-
<pclass="message-notice"><code>Domain::isKnown</code> status depends on the PSL rules used. For the same domain, depending on the rules used a domain public suffix may be known or not.</p>
129
+
**Warning:**`Domain::isKnown`, `Domain::isICANN` status depends on the PSL rules used.
130
+
For the same domain, depending on the rules used a domain public suffix status may be known or not, may be ICANN or not.
<pclass="message-warning"><strong>Warning:</strong> Some people use the PSL to determine what is a valid domain name and what isn't. This is dangerous, particularly in these days where new gTLDs are arriving at a rapid pace, if your software does not regularly receive PSL updates, it may erroneously think new gTLDs are not known. The DNS is the proper source for this information. If you must use it for this purpose, please do not bake static copies of the PSL into your software with no update mechanism.</p>
174
+
**Warning:** Some people use the PSL to determine what is a valid domain name and what isn't. This is dangerous, particularly in these days where new gTLDs are arriving at a rapid pace, if your software does not regularly receive PSL updates, it may erroneously think new gTLDs are not known. The DNS is the proper source for this information. If you must use it for this purpose, please do not bake static copies of the PSL into your software with no update mechanism.
162
175
163
176
### Public Suffix List Maintenance
164
177
165
-
**Directly fetching the Public Suffix List without caching the result is not recommend** . For that reason, the package comes bundle with a `Pdp\Manager` class which retrieves, convert and cache the Public Suffix List for you.
166
-
178
+
**Directly fetching the Public Suffix List without caching the result is not recommend**. For that reason, the package comes bundle with a `Pdp\Manager` class which retrieves, converts and caches the Public Suffix List for you as well as create a `Pdp\Rules` object on demand.
167
179
168
180
~~~php
169
181
<?php
@@ -212,8 +224,6 @@ interface HttpClient
212
224
}
213
225
~~~
214
226
215
-
For advance usages you are free to use your own cache and/or http implementation.
216
-
217
227
By default and out of the box, the package uses:
218
228
219
229
- a file cache PSR-16 implementation based on the excellent [FileCache](https://github.com/kodus/file-cache) which **caches the local copy for a maximum of 7 days**.
@@ -283,7 +293,6 @@ If you prefer using your own implementations you should:
283
293
1. Copy the `Pdp\Installer` class
284
294
2. Adapt its code to reflect your requirements.
285
295
286
-
287
296
In any cases your are required to update regularly your PSL information with your chosen script to keep your data up to date.
0 commit comments