17
17
18
18
use Pdp \Exception \CouldNotLoadRules ;
19
19
use Pdp \Exception \CouldNotResolvePublicSuffix ;
20
+ use Pdp \Exception \InvalidDomain ;
20
21
use function array_reverse ;
21
22
use function count ;
22
23
use function fclose ;
@@ -104,7 +105,7 @@ public static function createFromPath(
104
105
105
106
$ resource = @fopen (...$ args );
106
107
if (false === $ resource ) {
107
- throw new CouldNotLoadRules (sprintf ('`%s`: failed to open stream: No such file or directory ' , $ path ));
108
+ throw new CouldNotLoadRules (sprintf ('`%s`: failed to open stream: No such file or directory. ' , $ path ));
108
109
}
109
110
110
111
/** @var string $content */
@@ -193,7 +194,7 @@ public function getPublicSuffix($domain, string $section = self::ALL_DOMAINS): P
193
194
}
194
195
195
196
if (!$ domain ->isResolvable ()) {
196
- throw new CouldNotResolvePublicSuffix (sprintf ('The domain `%s` can not contain a public suffix ' , $ domain ->getContent ()));
197
+ throw new CouldNotResolvePublicSuffix (sprintf ('The domain `%s` can not contain a public suffix. ' , $ domain ->getContent ()));
197
198
}
198
199
199
200
return PublicSuffix::createFromDomain ($ domain ->resolve ($ this ->findPublicSuffix ($ domain , $ section )));
@@ -262,9 +263,12 @@ public function privateResolve($domain): Domain
262
263
}
263
264
264
265
/**
265
- * Returns PSL info for a given domain .
266
+ * Assert the domain is valid and is resolvable .
266
267
*
267
268
* @param mixed $domain
269
+ *
270
+ * @throws InvalidDomain if the domain is invalid
271
+ * @throws CouldNotResolvePublicSuffix if the domain is not resolvable
268
272
*/
269
273
private function validateDomain ($ domain ): Domain
270
274
{
@@ -273,7 +277,7 @@ private function validateDomain($domain): Domain
273
277
}
274
278
275
279
if (!$ domain ->isResolvable ()) {
276
- throw new CouldNotResolvePublicSuffix (sprintf ('The domain `%s` can not contain a public suffix ' , $ domain ->getContent ()));
280
+ throw new CouldNotResolvePublicSuffix (sprintf ('The domain `%s` can not contain a public suffix. ' , $ domain ->getContent ()));
277
281
}
278
282
279
283
return $ domain ;
@@ -298,7 +302,7 @@ private function validateSection(string $section): string
298
302
return $ section ;
299
303
}
300
304
301
- throw new CouldNotResolvePublicSuffix (sprintf ('%s is an unknown Public Suffix List section ' , $ section ));
305
+ throw new CouldNotResolvePublicSuffix (sprintf ('%s is an unknown Public Suffix List section. ' , $ section ));
302
306
}
303
307
304
308
/**
0 commit comments