@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | use Traits_Optionable; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @see https://gist.github.com/gruber/249502 |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @see https://gist.github.com/gruber/249502 |
|
| 29 | + */ |
|
| 30 | 30 | const REGEX_URL = '#(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#i'; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | protected $subject; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string[] |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string[] |
|
| 39 | + */ |
|
| 40 | 40 | protected $schemes = array( |
| 41 | 41 | 'http', |
| 42 | 42 | 'https', |
@@ -62,49 +62,49 @@ discard block |
||
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
| 67 | - * |
|
| 68 | - * @param bool $enabled |
|
| 69 | - * @return ConvertHelper_URLFinder |
|
| 70 | - */ |
|
| 65 | + /** |
|
| 66 | + * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
| 67 | + * |
|
| 68 | + * @param bool $enabled |
|
| 69 | + * @return ConvertHelper_URLFinder |
|
| 70 | + */ |
|
| 71 | 71 | public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
| 72 | 72 | { |
| 73 | 73 | $this->setOption('sorting', $enabled); |
| 74 | 74 | return $this; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Whether to include email addresses in the search. |
|
| 79 | - * This is only relevant when using the getURLs() |
|
| 80 | - * method. |
|
| 81 | - * |
|
| 82 | - * @param bool $include |
|
| 83 | - * @return ConvertHelper_URLFinder |
|
| 84 | - */ |
|
| 77 | + /** |
|
| 78 | + * Whether to include email addresses in the search. |
|
| 79 | + * This is only relevant when using the getURLs() |
|
| 80 | + * method. |
|
| 81 | + * |
|
| 82 | + * @param bool $include |
|
| 83 | + * @return ConvertHelper_URLFinder |
|
| 84 | + */ |
|
| 85 | 85 | public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
| 86 | 86 | { |
| 87 | 87 | $this->setOption('include-emails', $include); |
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Whether to omit the mailto: that is automatically added to all email addresses. |
|
| 93 | - * |
|
| 94 | - * @param bool $omit |
|
| 95 | - * @return ConvertHelper_URLFinder |
|
| 96 | - */ |
|
| 91 | + /** |
|
| 92 | + * Whether to omit the mailto: that is automatically added to all email addresses. |
|
| 93 | + * |
|
| 94 | + * @param bool $omit |
|
| 95 | + * @return ConvertHelper_URLFinder |
|
| 96 | + */ |
|
| 97 | 97 | public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
| 98 | 98 | { |
| 99 | 99 | $this->setOption('omit-mailto', $omit); |
| 100 | 100 | return $this; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Prepares the subject string by adding a newline before all URL schemes, |
|
| 105 | - * to make it possible to parse even lists of links separated by commas or |
|
| 106 | - * the like (http://domain.com,http://domain2.com). |
|
| 107 | - */ |
|
| 103 | + /** |
|
| 104 | + * Prepares the subject string by adding a newline before all URL schemes, |
|
| 105 | + * to make it possible to parse even lists of links separated by commas or |
|
| 106 | + * the like (http://domain.com,http://domain2.com). |
|
| 107 | + */ |
|
| 108 | 108 | private function prepareSubject() : void |
| 109 | 109 | { |
| 110 | 110 | $replaces = array(); |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | $this->subject = str_replace(array_keys($replaces), array_values($replaces), $this->subject); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Fetches all URLs that can be found in the subject string. |
|
| 122 | - * |
|
| 123 | - * @return string[] |
|
| 124 | - */ |
|
| 120 | + /** |
|
| 121 | + * Fetches all URLs that can be found in the subject string. |
|
| 122 | + * |
|
| 123 | + * @return string[] |
|
| 124 | + */ |
|
| 125 | 125 | public function getURLs() : array |
| 126 | 126 | { |
| 127 | 127 | $this->prepareSubject(); |
@@ -154,13 +154,13 @@ discard block |
||
| 154 | 154 | return $result; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Retrieves all email addresses from the subject string. |
|
| 159 | - * |
|
| 160 | - * @return string[] |
|
| 161 | - * |
|
| 162 | - * @see omitMailto() |
|
| 163 | - */ |
|
| 157 | + /** |
|
| 158 | + * Retrieves all email addresses from the subject string. |
|
| 159 | + * |
|
| 160 | + * @return string[] |
|
| 161 | + * |
|
| 162 | + * @see omitMailto() |
|
| 163 | + */ |
|
| 164 | 164 | public function getEmails() : array |
| 165 | 165 | { |
| 166 | 166 | $matches = array(); |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | return 'mailto:'; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Retrieves all URLs as URLInfo instances. |
|
| 199 | - * |
|
| 200 | - * @return URLInfo[] |
|
| 201 | - */ |
|
| 197 | + /** |
|
| 198 | + * Retrieves all URLs as URLInfo instances. |
|
| 199 | + * |
|
| 200 | + * @return URLInfo[] |
|
| 201 | + */ |
|
| 202 | 202 | public function getInfos() |
| 203 | 203 | { |
| 204 | 204 | $urls = $this->getURLs(); |