Skip to content

Commit 0704aea

Browse files
nyamsprodjeremykendall
authored andcommitted
Adding v5 docblock (#197)
* Improve Test Suite - adding tests to cover all new Object and methods - improve docblocks - normalize class file headers - improve classes typehint and return type * typo fix between repo * bugfix files credits * Improve PublicSuffixList * Improve PublicSuffixList * Improve test suite - better covers for UnmatchedDomain and Matched - improve PublicSuffixList::query method - improve hasRegistrableDomain to look like isMatchable method - removed deprecated feature (parse_url and associated files and classes)
1 parent 89eb5fe commit 0704aea

21 files changed

+511
-586
lines changed

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
"autoload": {
3939
"psr-0": {
4040
"Pdp\\": "src/"
41-
},
42-
"files": [
43-
"src/pdp-parse-url.php"
44-
]
41+
}
4542
},
4643
"scripts": {
4744
"post-install-cmd": "php bin/update-psl"

example.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
2+
<phpunit
33
backupGlobals="false"
44
backupStaticAttributes="false"
5-
bootstrap="tests/bootstrap.php"
5+
bootstrap="tests/bootstrap.php"
66
colors="true">
77

88
<testsuite name="php-domain-parser">
@@ -16,14 +16,18 @@
1616
</filter>
1717

1818
<logging>
19-
<log type="coverage-html"
20-
target="build/coverage"
21-
charset="UTF-8"
22-
yui="true"
23-
highlight="true"
19+
<log type="coverage-html"
20+
target="build/coverage"
21+
charset="UTF-8"
22+
yui="true"
23+
highlight="true"
2424
lowUpperBound="40"
2525
highLowerBound="70" />
2626
<log type="testdox-html" target="build/coverage/log/testdox.html" />
27+
<log type="junit" target="build/report.junit.xml"/>
28+
<log type="coverage-text" target="build/coverage.txt"/>
29+
<log type="coverage-clover" target="build/clover.xml"/>
2730
</logging>
28-
31+
<logging>
32+
</logging>
2933
</phpunit>

src/Pdp/Domain.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?php
2-
declare(strict_types=1);
3-
42
/**
5-
* Public Suffix List PHP: Public Suffix List based URL parsing.
3+
* PHP Domain Parser: Public Suffix List based URL parsing.
64
*
7-
* @see http://github.com/jeremykendall/publicsuffixlist-php for the canonical source repository
5+
* @see http://github.com/jeremykendall/php-domain-parser for the canonical source repository
86
*
97
* @copyright Copyright (c) 2017 Jeremy Kendall (http://jeremykendall.net)
10-
* @license http://github.com/jeremykendall/publicsuffixlist-php/blob/master/LICENSE MIT License
8+
* @license http://github.com/jeremykendall/php-domain-parser/blob/master/LICENSE MIT License
119
*/
10+
declare(strict_types=1);
1211

1312
namespace Pdp;
1413

src/Pdp/Exception/PdpException.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Pdp/Exception/SeriouslyMalformedUrlException.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Pdp/HttpAdapter/CurlHttpAdapter.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
2-
32
/**
43
* PHP Domain Parser: Public Suffix List based URL parsing.
54
*
6-
* @link http://github.com/jeremykendall/php-domain-parser for the canonical source repository
5+
* @see http://github.com/jeremykendall/php-domain-parser for the canonical source repository
76
*
8-
* @copyright Copyright (c) 2014 Jeremy Kendall (http://about.me/jeremykendall)
7+
* @copyright Copyright (c) 2017 Jeremy Kendall (http://jeremykendall.net)
98
* @license http://github.com/jeremykendall/php-domain-parser/blob/master/LICENSE MIT License
109
*/
10+
declare(strict_types=1);
11+
1112
namespace Pdp\HttpAdapter;
1213

1314
/**
@@ -26,7 +27,7 @@ class CurlHttpAdapter implements HttpAdapterInterface
2627
/**
2728
* {@inheritdoc}
2829
*/
29-
public function getContent($url)
30+
public function getContent(string $url)
3031
{
3132
$ch = curl_init();
3233
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

src/Pdp/HttpAdapter/HttpAdapterInterface.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
2-
32
/**
43
* PHP Domain Parser: Public Suffix List based URL parsing.
54
*
6-
* @link http://github.com/jeremykendall/php-domain-parser for the canonical source repository
5+
* @see http://github.com/jeremykendall/php-domain-parser for the canonical source repository
76
*
8-
* @copyright Copyright (c) 2014 Jeremy Kendall (http://about.me/jeremykendall)
7+
* @copyright Copyright (c) 2017 Jeremy Kendall (http://jeremykendall.net)
98
* @license http://github.com/jeremykendall/php-domain-parser/blob/master/LICENSE MIT License
109
*/
10+
declare(strict_types=1);
11+
1112
namespace Pdp\HttpAdapter;
1213

1314
/**
@@ -30,5 +31,5 @@ interface HttpAdapterInterface
3031
*
3132
* @return string Retrieved content
3233
*/
33-
public function getContent($url);
34+
public function getContent(string $url);
3435
}

src/Pdp/LabelsTrait.php

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,61 @@
11
<?php
2-
3-
declare(strict_types=1);
4-
52
/**
6-
* Public Suffix List PHP: Public Suffix List based URL parsing.
3+
* PHP Domain Parser: Public Suffix List based URL parsing.
74
*
8-
* @see http://github.com/jeremykendall/publicsuffixlist-php for the canonical source repository
5+
* @see http://github.com/jeremykendall/php-domain-parser for the canonical source repository
96
*
107
* @copyright Copyright (c) 2017 Jeremy Kendall (http://jeremykendall.net)
11-
* @license http://github.com/jeremykendall/publicsuffixlist-php/blob/master/LICENSE MIT License
8+
* @license http://github.com/jeremykendall/php-domain-parser/blob/master/LICENSE MIT License
129
*/
10+
declare(strict_types=1);
11+
1312
namespace Pdp;
1413

1514
trait LabelsTrait
1615
{
16+
/**
17+
* Returns labels from input
18+
*
19+
* @param string $input
20+
*
21+
* @return string[]
22+
*/
1723
private function getLabels(string $input): array
1824
{
1925
return explode('.', $input);
2026
}
2127

28+
/**
29+
* Returns labels from input in reverse
30+
*
31+
* @param string $input
32+
*
33+
* @return string[]
34+
*/
2235
private function getLabelsReverse(string $input): array
2336
{
2437
return array_reverse($this->getLabels($input));
2538
}
2639

27-
private function hasLabels(string $input): bool
40+
/**
41+
* Tells whether the domain contains multiple labels
42+
*
43+
* @param string $domain
44+
*
45+
* @return bool
46+
*/
47+
private function hasLabels(string $domain): bool
2848
{
29-
return strpos($input, '.') !== false;
49+
return strpos($domain, '.') !== false;
3050
}
3151

52+
/**
53+
* Tells whether the domain contains one single label
54+
*
55+
* @param string $domain
56+
*
57+
* @return bool
58+
*/
3259
private function isSingleLabelDomain(string $domain): bool
3360
{
3461
return !$this->hasLabels($domain);

0 commit comments

Comments
 (0)