You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/links/links.php
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
<?php
2
2
3
3
/**
4
-
* Store a internal or external URL,
4
+
* URL to be tested.
5
+
*
6
+
* Store an internal or external URL,
5
7
* optionally the text of the corresponding link,
6
8
* optionally where it has been found (in which file at which line),
7
9
* and offers to test/check the existence of URL's destination.
@@ -55,7 +57,8 @@ class TestableUrl
55
57
publicconstDEFAULT_SCHEME = 'https';
56
58
57
59
/**
58
-
* Represent a URL, potentially extracted from a file, which can be tested
60
+
* Represent a URL, potentially extracted from a file, which can be tested.
61
+
*
59
62
* @param string $url The URL itself
60
63
* @param string|null $text The text of the link to the URL
61
64
* @param string|null $file The file in which the URL has been found
@@ -64,7 +67,7 @@ class TestableUrl
64
67
* @param bool|string|null $find By default, URL is considered absolute or relative; If true, the URL will be considered partial and the target must be searched to solve the URL; If a string is given, this string will be used as a search prefix
65
68
* @param bool $test Set to true to test the URL immediately at construction time
@@ -78,7 +81,8 @@ public function __construct(string $url, string $text = null, string $file = nul
78
81
}
79
82
80
83
/**
81
-
* Test/check the URL and fill its related properties (code, headers, etc.)
84
+
* Test/check the URL and fill its related properties (code, headers, etc.).
85
+
*
82
86
* @param bool $testLocations If it's a redirection (through a `location` header), test the redirect target
83
87
* @param bool $testFragment If the eventual fragment/hash/anchor part should be tested
84
88
* @param bool $cache Test again even if already tested
@@ -99,7 +103,8 @@ public function test(bool $testLocations = true, bool $testFragment = true, bool
99
103
}
100
104
101
105
/**
102
-
* Has the URL been tested/checked
106
+
* Has the URL been tested/checked.
107
+
*
103
108
* @return bool
104
109
*/
105
110
publicfunctionisTested(): bool
@@ -109,6 +114,7 @@ public function isTested(): bool
109
114
110
115
/**
111
116
* The raw URL
117
+
*
112
118
* @return string
113
119
*/
114
120
publicfunctiongetUrl(): string
@@ -184,9 +190,12 @@ public static function solveRelativePath(string $sourcePath, string $targetPath)
184
190
}
185
191
186
192
/**
193
+
* Get testable URI.
194
+
*
187
195
* If the file where the URL has been found is known,
188
196
* solve relative path of internal URL
189
-
* or add file URL to fragment
197
+
* or add file URL to fragment.
198
+
*
190
199
* @return string
191
200
*/
192
201
publicfunctiongetSolvedUrl(): string
@@ -269,18 +278,19 @@ public function isInternal(): bool
269
278
publicconstNOT_TESTABLE_CODE = 999;
270
279
271
280
/**
272
-
* Test/check a URL and return result data
281
+
* Test/check a URL and return result data.
282
+
*
273
283
* If the URL is external, return the response HTTP headers (as an array), the HTTP status code as an integer, the eventual `location` HTTP header used for redirection, if there is a fragment to test, if that fragment has been found in the content available at the URL
274
284
* If the URL is internal, return the code 200 if the target exists, 404 if not, if there is a fragment to test, if that fragment has been found in the content available at the URL
275
285
* @param string $url The URL istsel
276
-
* @param bool|null $external If it's an external URL or not
286
+
* @param bool|null $external If it's an external URL (`true`) or not (`false`), if `null`, the system try to guess it using {@see \TestableUrl::isExternalUrl()}
277
287
* @param bool $testFragment If the eventual fragment/hash/anchor part should be tested
278
288
* @param int $retryCount Number of retries on time out
279
289
* @param int $retryDelay Delay in seconds before retrying
280
290
* @param int $tryNumber Try number (first try is numbered 1)
0 commit comments