Skip to content

Commit 2426336

Browse files
committed
Improve Rules static code analysis
1 parent 27ed872 commit 2426336

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

src/Rules.php

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ public function getUnicodeIDNAOption(): int
185185
*/
186186
public function getPublicSuffix($domain, string $section = self::ALL_DOMAINS): PublicSuffix
187187
{
188-
$section = $this->validateSection($section);
189188
if (!$domain instanceof Domain) {
190189
$domain = new Domain($domain, null, $this->asciiIDNAOption, $this->unicodeIDNAOption);
191190
}
@@ -194,7 +193,45 @@ public function getPublicSuffix($domain, string $section = self::ALL_DOMAINS): P
194193
throw CouldNotResolvePublicSuffix::dueToUnresolvableDomain($domain);
195194
}
196195

197-
return PublicSuffix::createFromDomain($domain->resolve($this->findPublicSuffix($domain, $section)));
196+
$publicSuffix = $this->findPublicSuffix($domain, $this->validateSection($section));
197+
198+
return PublicSuffix::createFromDomain($domain->resolve($publicSuffix));
199+
}
200+
201+
/**
202+
* Determines the public suffix for a given domain against the PSL rules for cookie domain detection..
203+
*
204+
* @param mixed $domain
205+
*
206+
* @throws CouldNotResolvePublicSuffix If the PublicSuffix can not be resolve.
207+
*/
208+
public function getCookieEffectiveTLD($domain): PublicSuffix
209+
{
210+
return $this->getPublicSuffix($domain, '');
211+
}
212+
213+
/**
214+
* Determines the public suffix for a given domain against the PSL rules for ICANN domain detection..
215+
*
216+
* @param mixed $domain
217+
*
218+
* @throws CouldNotResolvePublicSuffix If the PublicSuffix can not be resolve.
219+
*/
220+
public function getICANNEffectiveTLD($domain): PublicSuffix
221+
{
222+
return $this->getPublicSuffix($domain, self::ICANN_DOMAINS);
223+
}
224+
225+
/**
226+
* Determines the public suffix for a given domain against the PSL rules for private domain detection..
227+
*
228+
* @param mixed $domain
229+
*
230+
* @throws CouldNotResolvePublicSuffix If the PublicSuffix can not be resolve.
231+
*/
232+
public function getPrivateEffectiveTLD($domain): PublicSuffix
233+
{
234+
return $this->getPublicSuffix($domain, self::PRIVATE_DOMAINS);
198235
}
199236

200237
/**

0 commit comments

Comments
 (0)