1 | <?php |
||
10 | trait Misc |
||
11 | { |
||
12 | /** |
||
13 | * Convert ISO 3166-1 alpha-2 code to (English) country name. |
||
14 | * |
||
15 | * @uses Holt45::getCountriesList() |
||
16 | * |
||
17 | * @param string $key ISO 3166-1 alpha-2 code |
||
18 | * @return string Country name OR $key if no match. |
||
19 | */ |
||
20 | public static function iso3166ToName($key) |
||
26 | |||
27 | /** |
||
28 | * Tries to auto-correct parse_url()-output. |
||
29 | * |
||
30 | * @used-by Holt45::autoCorrectParseUrl() |
||
31 | * |
||
32 | * @param string $url |
||
33 | * @return string[]|false |
||
|
|||
34 | */ |
||
35 | private static function autoCorrectParseUrl($url) |
||
52 | |||
53 | /** |
||
54 | * parse url, try to correct errors and return valid url + display-url. |
||
55 | * |
||
56 | * Example: |
||
57 | * ``` |
||
58 | * http:/wwww.example.com/lorum.html => http://www.example.com/lorum.html |
||
59 | * gopher:/ww.example.com => gopher://www.example.com |
||
60 | * http:/www3.example.com/?q=asd&f=#asd =>http://www3.example.com/?q=asd&f=#asd |
||
61 | * asd://.example.com/folder/folder/ =>http://example.com/folder/folder/ |
||
62 | * .example.com/ => http://example.com/ |
||
63 | * example.com =>http://example.com |
||
64 | * subdomain.example.com => http://subdomain.example.com |
||
65 | * ``` |
||
66 | * |
||
67 | * @uses Holt45::autoCorrectParseUrl() |
||
68 | * |
||
69 | * @param string $url Any somewhat valid url. |
||
70 | * @return string[] "url" contains an auto-corrected url. "url_display" host.tld or subdomain.host.tld |
||
71 | */ |
||
72 | public static function urlParser($url) |
||
127 | |||
128 | /** |
||
129 | * To allow shorthand-requests for <Pre>, Print_R and Exit. |
||
130 | * |
||
131 | * @param array input array |
||
132 | */ |
||
133 | public static function ppre($array) |
||
140 | |||
141 | /** |
||
142 | * Generate a password-suggestion. |
||
143 | * |
||
144 | * @param int $length Length of password |
||
145 | * @param string $passwordType "simple" limit character-set to first 33 characters. "long" uses 64 characters. |
||
146 | * @return string |
||
147 | */ |
||
148 | public static function generatePassword($length = 8, $passwordType = "long") |
||
172 | } |
||
173 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.