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
Copy file name to clipboardExpand all lines: README.md
+28-10Lines changed: 28 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,10 +47,10 @@ Documentation
47
47
### Domain name resolution
48
48
49
49
50
-
In order to resolve a domain name we must:
50
+
In order to resolve a domain name one we must:
51
51
52
52
- Convert the Public Suffix List (PSL) into a structure usable in PHP
53
-
- Resolve the domain against the given PSL rules
53
+
- Resolve the domain name against the PSL rules
54
54
55
55
Conversion is done using the `Pdp\Converter` class.
56
56
@@ -67,7 +67,7 @@ final class Converter
67
67
68
68
The `Pdp\Converter::convert` method expects the raw content of a PSL and returns its `array` representation.
69
69
70
-
Once the PSL has been converted we can feed its data to a `Pdp\Rules` object which is responsable for resolving a given domain name against the PSL rules.
70
+
Once the PSL has been converted we can feed its data to a `Pdp\Rules` object which is responsable for resolving a given domain name against its rules.
71
71
72
72
~~~php
73
73
<?php
@@ -87,7 +87,7 @@ final class Rules
87
87
88
88
The `Rules` constructor expects the result of the PSL conversion by the `Pdp\Converter` class.
89
89
90
-
Domain name resolution is done using the `Rules::resolve` method which returns a `Pdp\Domain` object. The method expects
90
+
Domain name resolution is done using the `Rules::resolve`. The method expects
91
91
92
92
- a valid domain name as a string
93
93
- a string to optionnally specify which section of the PSL you want to validate the given domain against. The possible values are:
@@ -97,6 +97,9 @@ Domain name resolution is done using the `Rules::resolve` method which returns a
97
97
98
98
By default, the `$type` argument equals `Rules::ALL_DOMAINS`. If an unrecognized section is submitted otherwise, a `Pdp\Exception` exception will be thrown.
99
99
100
+
101
+
`Rules::resolve` returns a `Domain` object.
102
+
100
103
~~~php
101
104
<?php
102
105
@@ -112,7 +115,22 @@ final class Domain implements JsonSerializable
112
115
}
113
116
~~~
114
117
115
-
The `Domain` getters method always return normalized value according to the domain status against the PSL rules.
118
+
The `Domain` getter methods returns:
119
+
120
+
- the submitted domain name using `Domain::getDomain`
121
+
- the public suffix part normalized according to the domain using `Domain::getPublicSuffix`
122
+
- the registrable domain part using `Domain::getRegistrableDomain`
123
+
- the subdomain part usung `Domain::getSubDomain`.
124
+
125
+
If the domain name of some of its part are seriously malformed or unrecognized, the getter methods will return `null`.
126
+
127
+
**The Domain name public status status depends on the PSL section used to resolve them:**
128
+
129
+
-`Domain::isICANN` returns `true` if the domain name resolution is done against a PSL which includes the ICANN DOMAINS section and its public suffix is found in it;
130
+
-`Domain::isPrivate` returns `true` if the domain name resolution is done against a PSL which includes the PRIVATE DOMAINS section and its public suffix is found in it;
131
+
-`Domain::isKnown` returns `true` if the public suffix is found in the selected PSL
132
+
133
+
**THIS EXAMPLE ILLUSTRATE HOW EACH OBJECT IS USED BUT SHOULD BE AVOID IN A PRODUCTIVE ENVIRONMENT**
**Warning: While the above example works it is highly discouraged to use the library in a productive application this way, without a caching mechanism to load the PSL.**
181
+
**WARNING:**
164
182
165
-
**Warning: `Domain::isKnown`, `Domain::isICANN` status depends on the PSL rules used. For the same domain, depending on the rules used a domain public suffix status may be known or not, may be ICANN or not.**
183
+
**Yous should never user the library this way in a productive application, without at least a caching mechanism to load the PSL.**
166
184
167
-
**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.**
185
+
**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.**
168
186
169
187
### Public Suffix List Maintenance
170
188
171
-
**Directly fetching the PSL without caching the result is not recommend**. For that reason, the library comes bundle with a `Pdp\Manager` class. This class is a service which enables resolving domain name without the constant network overhead of continously downloading the PSL. The class retrieves, converts and caches the PSL as well as creates the corresponding `Pdp\Rules` object on demand. It uses internally a `Pdp\Converter` object to convert the fetched PSL into its `array` representation when required.
189
+
Since **directly fetching the PSL without caching the result is not recommend**, the library comes bundle with a `Pdp\Manager` class. This class is a service which enables resolving domain name without the constant network overhead of continously downloading the PSL. The class retrieves, converts and caches the PSL as well as creates the corresponding `Pdp\Rules` object on demand. It internally uses a `Pdp\Converter` object to convert the fetched PSL into its `array` representation when required.
0 commit comments