1 | <?php |
||
10 | trait Strings |
||
11 | { |
||
12 | /** |
||
13 | * Encrypt string |
||
14 | * |
||
15 | * NOTICE: the code in general, this method in particular, comes with absolutely no warranty. If security is |
||
16 | * important for you, then use a purpose built package. https://github.com/defuse/php-encryption seems like |
||
17 | * a good candidate. |
||
18 | * @deprecated Do not trust a two-line encryption-method. |
||
19 | * |
||
20 | * @throws Exception if extension mcrypt is not loaded. |
||
21 | * |
||
22 | * @param string $string String to encrypt |
||
23 | * @param string $key Key to encrypt/decrypt. |
||
24 | * @return string Encrypted string |
||
25 | */ |
||
26 | public static function encrypt($string, $key) |
||
50 | |||
51 | /** |
||
52 | * Decrypt string |
||
53 | * |
||
54 | * NOTICE: the code in general, this method in particular, comes with absolutely no warranty. If security is |
||
55 | * important for you, then use a purpose built package. https://github.com/defuse/php-encryption seems like |
||
56 | * a good candidate. |
||
57 | * @deprecated Do not trust a two-line decryption-method. |
||
58 | * |
||
59 | * @param string $string String to decrypt |
||
60 | * @param string $key Key to encrypt/decrypt. |
||
61 | * @return string Decrypted string |
||
62 | */ |
||
63 | public static function decrypt($string, $key) |
||
92 | |||
93 | /** |
||
94 | * Obfuscate string (url-safe and somewhat hard to guess). |
||
95 | * |
||
96 | * @param string $input The text that should be obfuscated |
||
97 | * @return string Obfuscated string |
||
98 | */ |
||
99 | public static function obfuscateString($input) |
||
103 | |||
104 | /** |
||
105 | * Deobfuscate string |
||
106 | * |
||
107 | * @param string $input Obfuscated string |
||
108 | * @return string Deobfuscated string |
||
109 | */ |
||
110 | public static function deobfuscateString($input) |
||
114 | |||
115 | /** |
||
116 | * Convert <textarea> to [textarea]. |
||
117 | * |
||
118 | * @param string $html |
||
119 | * @return string |
||
120 | */ |
||
121 | public static function textareaEncode($html) |
||
125 | |||
126 | /** |
||
127 | * Convert [textarea] to <textarea>. |
||
128 | * |
||
129 | * @param string $html |
||
130 | * @return string |
||
131 | */ |
||
132 | public static function textareaDecode($html) |
||
136 | |||
137 | /** |
||
138 | * To replace "Hallo [@var] world" with $value. |
||
139 | * |
||
140 | * Example: |
||
141 | * ```php |
||
142 | * replace_string($string, array("val1" => "foo", "val2" => "bar")) |
||
143 | * ``` |
||
144 | * |
||
145 | * @param string $langString String containing placeholder. |
||
146 | * @param array $dynamicContent key->value array. |
||
147 | * @return string String with placeholder replaced. |
||
148 | */ |
||
149 | public static function replaceString($langString, $dynamicContent = array()) |
||
156 | |||
157 | /** |
||
158 | * Creates rainbow-colored text. |
||
159 | * |
||
160 | * @uses Holt45::colorBlend() |
||
161 | * @uses Holt45::rgbhex() |
||
162 | * |
||
163 | * @param string $text Text wanted coloured. |
||
164 | * @return string String with span-tags with color. |
||
165 | */ |
||
166 | public static function rainbowText($text) |
||
215 | |||
216 | /** |
||
217 | * Get the symbol from a list of keyboard-keys... |
||
218 | * |
||
219 | * @used-by Holt45::kbdShortcut() |
||
220 | * |
||
221 | * @param string $inputKey Text |
||
222 | * @param string $inputOperatingSystem default|auto|win|mac|linux |
||
223 | * @return null|string HTML Entity (decimal) |
||
224 | */ |
||
225 | public static function kbdSymbol($inputKey, $inputOperatingSystem = "default") |
||
295 | |||
296 | /** |
||
297 | * Show fancy buttons for keyboard-shortcuts. |
||
298 | * |
||
299 | * @uses Holt45::kbdSymbol() |
||
300 | * |
||
301 | * @param array $inputArrayKeys |
||
302 | * @param string $inputOperatingSystem |
||
303 | * @param string $inputKbdClass |
||
304 | * @param string $inputKbdSymbolClass |
||
305 | * @param string $inputJoinGlue Glue |
||
306 | * @return string String of html |
||
307 | */ |
||
308 | public static function kbdShortcut( |
||
333 | |||
334 | /** |
||
335 | * Attempting to keep CSS on one line with scoped style. |
||
336 | * |
||
337 | * NOTICE: This is a rough estimate, font type, design, etc affects the results. |
||
338 | * |
||
339 | * @param string $text |
||
340 | * @param string $cssSelector |
||
341 | * @param int $fontSizePx |
||
342 | * @param int $minPageWidthPx |
||
343 | * @return null|string Scoped style |
||
344 | */ |
||
345 | public static function cssOneLineText($text, $cssSelector = "h1", $fontSizePx = 36, $minPageWidthPx = 320) |
||
365 | } |
||
366 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.