Skip to content

Commit b9bd8f8

Browse files
committed
improvements on some lines of code.
1 parent eda0b57 commit b9bd8f8

File tree

5 files changed

+52
-13
lines changed

5 files changed

+52
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ vendor
66
docs
77
*~
88
build
9+
.idea

src/Pdp/Parser.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,19 @@ protected function getRawPublicSuffix($host)
205205
public function getPublicSuffix($host)
206206
{
207207
if (strpos($host, '.') === 0) {
208-
return;
208+
return null;
209209
}
210210

211211
// Fixes #22: If a single label domain makes it this far (e.g.,
212212
// localhost, foo, etc.), this stops it from incorrectly being set as
213213
// the public suffix.
214214
if (!$this->isMutliLabelDomain($host)) {
215-
return;
215+
return null;
216216
}
217217

218218
// Fixes #43
219219
if ($this->isIpv4Address($host)) {
220-
return;
220+
return null;
221221
}
222222

223223
$suffix = $this->getRawPublicSuffix($host);
@@ -254,18 +254,18 @@ public function isSuffixValid($host)
254254
*
255255
* @param string $host host
256256
*
257-
* @return string registerable domain
257+
* @return string|null registerable domain
258258
*/
259259
public function getRegisterableDomain($host)
260260
{
261261
if (strpos($host, '.') === false) {
262-
return;
262+
return null;
263263
}
264264

265265
$publicSuffix = $this->getPublicSuffix($host);
266266

267267
if ($publicSuffix === null || $host == $publicSuffix) {
268-
return;
268+
return null;
269269
}
270270

271271
$publicSuffixParts = array_reverse(explode('.', $publicSuffix));
@@ -280,14 +280,14 @@ public function getRegisterableDomain($host)
280280
*
281281
* @param string $host host
282282
*
283-
* @return string subdomain
283+
* @return string|null subdomain
284284
*/
285285
public function getSubdomain($host)
286286
{
287287
$registerableDomain = $this->getRegisterableDomain($host);
288288

289289
if ($registerableDomain === null || $host === $registerableDomain) {
290-
return;
290+
return null;
291291
}
292292

293293
$registerableDomainParts = array_reverse(explode('.', $registerableDomain));

src/Pdp/PublicSuffixListManager.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Pdp;
1313

14-
use Pdp\HttpAdapter\HttpAdapterInterface;
15-
1614
/**
1715
* Public Suffix List Manager.
1816
*

src/Pdp/Uri/Url.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ public function toArray()
169169
'user' => $this->user,
170170
'pass' => $this->pass,
171171
'host' => $this->host->__toString(),
172-
'subdomain' => $this->host->subdomain,
173-
'registerableDomain' => $this->host->registerableDomain,
174-
'publicSuffix' => $this->host->publicSuffix,
172+
'subdomain' => $this->host->getSubdomain(),
173+
'registerableDomain' => $this->host->getRegisterableDomain(),
174+
'publicSuffix' => $this->host->getPublicSuffix(),
175175
'port' => $this->port,
176176
'path' => $this->path,
177177
'query' => $this->query,

src/Pdp/Uri/Url/Host.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,44 @@ public function __get($name)
9898
{
9999
return $this->$name;
100100
}
101+
102+
/**
103+
* Get Subdomain.
104+
*
105+
* @return null|string
106+
*/
107+
public function getSubdomain()
108+
{
109+
return $this->subdomain;
110+
}
111+
112+
/**
113+
* Get Registerable domain.
114+
*
115+
* @return null|string
116+
*/
117+
public function getRegisterableDomain()
118+
{
119+
return $this->registerableDomain;
120+
}
121+
122+
/**
123+
* Get Public suffix.
124+
*
125+
* @return null|string
126+
*/
127+
public function getPublicSuffix()
128+
{
129+
return $this->publicSuffix;
130+
}
131+
132+
/**
133+
* Get Entire host part.
134+
*
135+
* @return null|string
136+
*/
137+
public function getHost()
138+
{
139+
return $this->host;
140+
}
101141
}

0 commit comments

Comments
 (0)