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 (PSL) into a structure usable in PHP
@@ -80,11 +81,25 @@ final class Rules
80
81
const ICANN_DOMAINS = 'ICANN_DOMAINS';
81
82
const PRIVATE_DOMAINS = 'PRIVATE_DOMAINS';
82
83
84
+
public static function createFromPath(string $path, $context = null): self
85
+
public static function createFromString(string $content): self
83
86
public function __construct(array $rules)
84
87
public function resolve(string $domain = null, string $section = self::ALL_DOMAINS): Domain
85
88
}
86
89
~~~
87
90
91
+
Starting with version 5.1.0, the following named constructors arre added to ease `Rules` instantiation.
92
+
93
+
-`Rules::createFromString` expects a string content which follows [the PSL format](https://publicsuffix.org/list/#list-format);
94
+
95
+
-`Rules::createFromPath` expects a valid path to a readable PSL. You can optionnally submit a context resource as defined in PHP's `fopen` function;
96
+
97
+
Both named constructors:
98
+
99
+
- uses internally a `Pdp\Converter` object to convert the raw content into a suitable array to instantiate a valid `Pdp\Rules`;
100
+
- do not have any cache functionnality;
101
+
102
+
88
103
Domain name resolution is done using the `Pdp\Rules::resolve` method which expects at most two parameters:
89
104
90
105
-`$domain` a domain name as a string
@@ -95,6 +110,7 @@ Domain name resolution is done using the `Pdp\Rules::resolve` method which expec
95
110
96
111
By default, the `$section` argument is equal to `Rules::ALL_DOMAINS`. If an unsupported section is submitted a `Pdp\Exception` exception will be thrown.
97
112
113
+
**WARNING: The `Pdp\Rules::resolve` does not validate the submitted host. You are require to use a host validator prior to using this library.**
98
114
99
115
The `Pdp\Rules::resolve` returns a `Pdp\Domain` object.
100
116
@@ -133,12 +149,9 @@ If the domain name or some of its part are seriously malformed or unrecognized,
0 commit comments