@@ -110,38 +110,38 @@ discard block |
||
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
115 | - * |
|
116 | - * @param bool $enabled |
|
117 | - * @return $this |
|
118 | - */ |
|
113 | + /** |
|
114 | + * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
115 | + * |
|
116 | + * @param bool $enabled |
|
117 | + * @return $this |
|
118 | + */ |
|
119 | 119 | public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
120 | 120 | { |
121 | 121 | $this->setOption('sorting', $enabled); |
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - /** |
|
126 | - * Whether to include email addresses in the search. |
|
127 | - * This is only relevant when using the getURLs() |
|
128 | - * method. |
|
129 | - * |
|
130 | - * @param bool $include |
|
131 | - * @return ConvertHelper_URLFinder |
|
132 | - */ |
|
125 | + /** |
|
126 | + * Whether to include email addresses in the search. |
|
127 | + * This is only relevant when using the getURLs() |
|
128 | + * method. |
|
129 | + * |
|
130 | + * @param bool $include |
|
131 | + * @return ConvertHelper_URLFinder |
|
132 | + */ |
|
133 | 133 | public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
134 | 134 | { |
135 | 135 | $this->setOption('include-emails', $include); |
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * Whether to omit the mailto: that is automatically added to all email addresses. |
|
141 | - * |
|
142 | - * @param bool $omit |
|
143 | - * @return ConvertHelper_URLFinder |
|
144 | - */ |
|
139 | + /** |
|
140 | + * Whether to omit the mailto: that is automatically added to all email addresses. |
|
141 | + * |
|
142 | + * @param bool $omit |
|
143 | + * @return ConvertHelper_URLFinder |
|
144 | + */ |
|
145 | 145 | public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
146 | 146 | { |
147 | 147 | $this->setOption('omit-mailto', $omit); |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | ); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Fetches all URLs that can be found in the subject string. |
|
272 | - * |
|
273 | - * @return string[] |
|
274 | - */ |
|
270 | + /** |
|
271 | + * Fetches all URLs that can be found in the subject string. |
|
272 | + * |
|
273 | + * @return string[] |
|
274 | + */ |
|
275 | 275 | public function getURLs() : array |
276 | 276 | { |
277 | 277 | $this->parse(); |
@@ -474,13 +474,13 @@ discard block |
||
474 | 474 | return array_pop($parts); |
475 | 475 | } |
476 | 476 | |
477 | - /** |
|
478 | - * Retrieves all email addresses from the subject string. |
|
479 | - * |
|
480 | - * @return string[] |
|
481 | - * |
|
482 | - * @see omitMailto() |
|
483 | - */ |
|
477 | + /** |
|
478 | + * Retrieves all email addresses from the subject string. |
|
479 | + * |
|
480 | + * @return string[] |
|
481 | + * |
|
482 | + * @see omitMailto() |
|
483 | + */ |
|
484 | 484 | public function getEmails() : array |
485 | 485 | { |
486 | 486 | $this->parse(); |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | return $result; |
507 | 507 | } |
508 | 508 | |
509 | - /** |
|
510 | - * Retrieves all URLs as URLInfo instances. |
|
511 | - * |
|
512 | - * @return URLInfo[] |
|
513 | - */ |
|
509 | + /** |
|
510 | + * Retrieves all URLs as URLInfo instances. |
|
511 | + * |
|
512 | + * @return URLInfo[] |
|
513 | + */ |
|
514 | 514 | public function getInfos() : array |
515 | 515 | { |
516 | 516 | $this->parse(); |
@@ -23,24 +23,24 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class URLInfo_Parser |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | 29 | protected $url; |
30 | 30 | |
31 | - /** |
|
32 | - * @var bool |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var bool |
|
33 | + */ |
|
34 | 34 | protected $isValid = false; |
35 | 35 | |
36 | - /** |
|
37 | - * @var array |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + */ |
|
39 | 39 | protected $info; |
40 | 40 | |
41 | - /** |
|
42 | - * @var array|NULL |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var array|NULL |
|
43 | + */ |
|
44 | 44 | protected $error; |
45 | 45 | |
46 | 46 | /** |
@@ -57,25 +57,25 @@ discard block |
||
57 | 57 | 'git' |
58 | 58 | ); |
59 | 59 | |
60 | - /** |
|
61 | - * Stores a list of all unicode characters in the URL |
|
62 | - * that have been filtered out before parsing it with |
|
63 | - * parse_url. |
|
64 | - * |
|
65 | - * @var string[]string |
|
66 | - */ |
|
60 | + /** |
|
61 | + * Stores a list of all unicode characters in the URL |
|
62 | + * that have been filtered out before parsing it with |
|
63 | + * parse_url. |
|
64 | + * |
|
65 | + * @var string[]string |
|
66 | + */ |
|
67 | 67 | protected $unicodeChars = array(); |
68 | 68 | |
69 | - /** |
|
70 | - * @var bool |
|
71 | - */ |
|
69 | + /** |
|
70 | + * @var bool |
|
71 | + */ |
|
72 | 72 | protected $encodeUTF = false; |
73 | 73 | |
74 | - /** |
|
75 | - * |
|
76 | - * @param string $url The target URL. |
|
77 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
78 | - */ |
|
74 | + /** |
|
75 | + * |
|
76 | + * @param string $url The target URL. |
|
77 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
78 | + */ |
|
79 | 79 | public function __construct(string $url, bool $encodeUTF) |
80 | 80 | { |
81 | 81 | $this->url = $url; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Retrieves the array as parsed by PHP's parse_url, |
|
93 | - * filtered and adjusted as necessary. |
|
94 | - * |
|
95 | - * @return array |
|
96 | - */ |
|
91 | + /** |
|
92 | + * Retrieves the array as parsed by PHP's parse_url, |
|
93 | + * filtered and adjusted as necessary. |
|
94 | + * |
|
95 | + * @return array |
|
96 | + */ |
|
97 | 97 | public function getInfo() : array |
98 | 98 | { |
99 | 99 | return $this->info; |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Finds any non-url encoded unicode characters in |
|
120 | - * the URL, and encodes them before the URL is |
|
121 | - * passed to parse_url. |
|
122 | - */ |
|
118 | + /** |
|
119 | + * Finds any non-url encoded unicode characters in |
|
120 | + * the URL, and encodes them before the URL is |
|
121 | + * passed to parse_url. |
|
122 | + */ |
|
123 | 123 | protected function filterUnicodeChars() : void |
124 | 124 | { |
125 | 125 | $chars = ConvertHelper::string2array($this->url); |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Goes through all information in the parse_url result |
|
243 | - * array, and attempts to fix any user errors in formatting |
|
244 | - * that can be recovered from, mostly regarding stray spaces. |
|
245 | - */ |
|
241 | + /** |
|
242 | + * Goes through all information in the parse_url result |
|
243 | + * array, and attempts to fix any user errors in formatting |
|
244 | + * that can be recovered from, mostly regarding stray spaces. |
|
245 | + */ |
|
246 | 246 | protected function filterParsed() : void |
247 | 247 | { |
248 | 248 | $this->info['params'] = array(); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - /** |
|
288 | - * Recursively goes through the array, and converts all previously |
|
289 | - * URL encoded characters with their unicode character counterparts. |
|
290 | - * |
|
291 | - * @param array $subject |
|
292 | - * @return array |
|
293 | - */ |
|
287 | + /** |
|
288 | + * Recursively goes through the array, and converts all previously |
|
289 | + * URL encoded characters with their unicode character counterparts. |
|
290 | + * |
|
291 | + * @param array $subject |
|
292 | + * @return array |
|
293 | + */ |
|
294 | 294 | protected function restoreUnicodeChars(array $subject) : array |
295 | 295 | { |
296 | 296 | $result = array(); |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | return $result; |
315 | 315 | } |
316 | 316 | |
317 | - /** |
|
318 | - * Replaces all URL encoded unicode characters |
|
319 | - * in the string with the unicode character. |
|
320 | - * |
|
321 | - * @param string $string |
|
322 | - * @return string |
|
323 | - */ |
|
317 | + /** |
|
318 | + * Replaces all URL encoded unicode characters |
|
319 | + * in the string with the unicode character. |
|
320 | + * |
|
321 | + * @param string $string |
|
322 | + * @return string |
|
323 | + */ |
|
324 | 324 | protected function restoreUnicodeChar(string $string) : string |
325 | 325 | { |
326 | 326 | if(strstr($string, '%')) |
@@ -404,21 +404,21 @@ discard block |
||
404 | 404 | ); |
405 | 405 | } |
406 | 406 | |
407 | - /** |
|
408 | - * Checks whether the URL that was parsed is valid. |
|
409 | - * @return bool |
|
410 | - */ |
|
407 | + /** |
|
408 | + * Checks whether the URL that was parsed is valid. |
|
409 | + * @return bool |
|
410 | + */ |
|
411 | 411 | public function isValid() : bool |
412 | 412 | { |
413 | 413 | return $this->isValid; |
414 | 414 | } |
415 | 415 | |
416 | - /** |
|
417 | - * If the validation failed, retrieves the validation |
|
418 | - * error message. |
|
419 | - * |
|
420 | - * @return string |
|
421 | - */ |
|
416 | + /** |
|
417 | + * If the validation failed, retrieves the validation |
|
418 | + * error message. |
|
419 | + * |
|
420 | + * @return string |
|
421 | + */ |
|
422 | 422 | public function getErrorMessage() : string |
423 | 423 | { |
424 | 424 | if(isset($this->error)) { |
@@ -428,12 +428,12 @@ discard block |
||
428 | 428 | return ''; |
429 | 429 | } |
430 | 430 | |
431 | - /** |
|
432 | - * If the validation failed, retrieves the validation |
|
433 | - * error code. |
|
434 | - * |
|
435 | - * @return int |
|
436 | - */ |
|
431 | + /** |
|
432 | + * If the validation failed, retrieves the validation |
|
433 | + * error code. |
|
434 | + * |
|
435 | + * @return int |
|
436 | + */ |
|
437 | 437 | public function getErrorCode() : int |
438 | 438 | { |
439 | 439 | if(isset($this->error)) { |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | |
43 | 43 | const REGEX_MD5 = '/^[a-f0-9]{32}$/i'; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string |
|
47 | - * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
48 | - */ |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
48 | + */ |
|
49 | 49 | const REGEX_EMAIL = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i'; |
50 | 50 | |
51 | 51 | const REGEX_PHONE = '/\A[+0-9][0-9 +\-()]+\z/m'; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | */ |
98 | 98 | const REGEX_IS_HTML = '%<{0,1}[a-z\/][\s\S]*>|<[a-z\/][\s\S]*>{0,1}%i'; |
99 | 99 | |
100 | - /** |
|
101 | - * Hexadecimal color codes. Allows the following formats: |
|
102 | - * |
|
103 | - * FFFFFF |
|
104 | - * FFF |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
100 | + /** |
|
101 | + * Hexadecimal color codes. Allows the following formats: |
|
102 | + * |
|
103 | + * FFFFFF |
|
104 | + * FFF |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | 108 | const REGEX_HEX_COLOR_CODE = '/\A(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\z/iU'; |
109 | 109 | |
110 | 110 | /** |