Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykendall committed Sep 28, 2017
2 parents 0ed5037 + c706854 commit 737f253
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Pdp/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,18 @@ public function getRegistrableDomain($host)
return implode('.', array_reverse($registrableDomainParts));
}

/**
* @see Parser::getRegistrableDomain
*
* @param string $host host
*
* @return string|null registrable domain
*/
public function getRegisterableDomain($host)
{
return $this->getRegistrableDomain($host);
}

/**
* Returns the subdomain portion of provided host.
*
Expand Down
15 changes: 14 additions & 1 deletion src/Pdp/Uri/Url/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ public function getRegistrableDomain()
return $this->registrableDomain;
}

/**
* @see Host::getRegistrableDomain
*
* @return string
*/
public function getRegisterableDomain()
{
return $this->getRegistrableDomain();
}

/**
* Get Public suffix.
*
Expand Down Expand Up @@ -116,9 +126,12 @@ public function __toString()
*/
public function toArray()
{
$registrableDomain = $this->getRegistrableDomain();

return array(
'subdomain' => $this->getSubdomain(),
'registrableDomain' => $this->getRegistrableDomain(),
'registrableDomain' => $registrableDomain,
'registerableDomain' => $registrableDomain,
'publicSuffix' => $this->getPublicSuffix(),
'host' => $this->getHost(),
);
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Pdp/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public function testGetPublicSuffixHandlesWrongCaseProperly()
/**
* @covers Pdp\Parser::parseUrl()
* @covers Pdp\Parser::getRegistrableDomain()
* @covers Pdp\Parser::getRegisterableDomain()
* @dataProvider parseDataProvider
*
* @param $url
Expand All @@ -162,7 +163,9 @@ public function testGetRegistrableDomain($url, $publicSuffix, $registrableDomain
{
$pdpUrl = $this->parser->parseUrl($url);
$this->assertSame($registrableDomain, $pdpUrl->getHost()->getRegistrableDomain());
$this->assertSame($registrableDomain, $this->parser->getRegistrableDomain($hostPart));
$this->assertSame($registrableDomain, $this->parser->getRegisterableDomain($hostPart));
$this->assertSame($registrableDomain, $pdpUrl->getHost()->getRegistrableDomain());
$this->assertSame($registrableDomain, $this->parser->getRegisterableDomain($hostPart));
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/src/Pdp/Uri/Url/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function testToArray($publicSuffix, $registrableDomain, $subdomain, $host
$parts = array(
'subdomain' => $subdomain,
'registrableDomain' => $registrableDomain,
'registerableDomain' => $registrableDomain,
'publicSuffix' => $publicSuffix,
'host' => $hostPart,
);
Expand Down

0 comments on commit 737f253

Please sign in to comment.