Skip to content

Commit c6d6624

Browse files
committed
Improve CouldNotResolvePublicSuffix usage
1 parent 31463b4 commit c6d6624

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Exception/CouldNotResolvePublicSuffix.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public static function dueToUnresolvableDomain(?Domain $domain): self
3939
return $exception;
4040
}
4141

42+
public static function dueToUnSupportedSection(string $section): self
43+
{
44+
return new self('`'.$section.'` is an unknown Public Suffix List section.');
45+
}
46+
4247
public function hasDomain(): bool
4348
{
4449
return null !== $this->domain;

src/Rules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function getPublicSuffix($domain, string $section = self::ALL_DOMAINS): P
194194
}
195195

196196
if (!$domain->isResolvable()) {
197-
throw new CouldNotResolvePublicSuffix(sprintf('The domain `%s` can not contain a public suffix.', $domain->getContent()));
197+
throw CouldNotResolvePublicSuffix::dueToUnresolvableDomain($domain);
198198
}
199199

200200
return PublicSuffix::createFromDomain($domain->resolve($this->findPublicSuffix($domain, $section)));
@@ -309,7 +309,7 @@ private function validateSection(string $section): string
309309
return $section;
310310
}
311311

312-
throw new CouldNotResolvePublicSuffix(sprintf('%s is an unknown Public Suffix List section.', $section));
312+
throw CouldNotResolvePublicSuffix::dueToUnSupportedSection($section);
313313
}
314314

315315
/**

0 commit comments

Comments
 (0)