1 | <?php |
||
17 | class Strings |
||
18 | { |
||
19 | /** |
||
20 | * Replace all specials characters from string and retuns only 128 basics |
||
21 | * NOTE: only for UTF-8 |
||
22 | * @param string $string |
||
23 | * @return string |
||
24 | */ |
||
25 | 1 | public static function replaceSpecialsChars($string) |
|
32 | |||
33 | /** |
||
34 | * Clear inputs for build in XML |
||
35 | * Only UTF-8 characters is acceptable |
||
36 | * & isolated, less than, greater than, quotation marks and apostrophes |
||
37 | * should be replaced by their html equivalent |
||
38 | * Carriage Return, Tab and Line Feed is not acceptable in strings |
||
39 | * Multiple spaces is not acceptable in strings |
||
40 | * And no other control character is acceptable either |
||
41 | * @param string|null $input |
||
42 | * @return string|null |
||
43 | */ |
||
44 | 1 | public static function replaceUnacceptableCharacters($input) |
|
59 | |||
60 | /** |
||
61 | * Converts all UTF-8 remains in ASCII |
||
62 | * @param string $input |
||
63 | * @return string |
||
64 | */ |
||
65 | public static function toASCII($input) |
||
71 | |||
72 | /** |
||
73 | * Replaces all accented characters of their ASCII equivalents |
||
74 | * @param string $input |
||
75 | * @return string |
||
76 | */ |
||
77 | 1 | public static function squashCharacters($input) |
|
86 | |||
87 | /** |
||
88 | * Replace all non-UTF-8 chars to UTF-8 |
||
89 | * Remove all control chars |
||
90 | * Remove all multiple spaces |
||
91 | * @param string $input |
||
92 | * @return string |
||
93 | */ |
||
94 | 1 | public static function normalize($input) |
|
116 | |||
117 | /** |
||
118 | * Remove all non numeric characters from string |
||
119 | * @param string $string |
||
120 | * @return string |
||
121 | */ |
||
122 | 1 | public static function onlyNumbers($string) |
|
126 | |||
127 | /** |
||
128 | * Remove unwanted attributes, prefixes, sulfixes and other control |
||
129 | * characters like \r \n \s \t |
||
130 | * @param string $string |
||
131 | * @param boolean $removeEncodingTag remove encoding tag from a xml |
||
132 | * @return string |
||
133 | */ |
||
134 | 2 | public static function clearXmlString($string, $removeEncodingTag = false) |
|
152 | |||
153 | /** |
||
154 | * Remove all characters between markers |
||
155 | * @param string $string |
||
156 | * @param string $beginning |
||
157 | * @param string $end |
||
158 | * @return string |
||
159 | */ |
||
160 | 2 | public static function deleteAllBetween($string, $beginning, $end) |
|
170 | |||
171 | /** |
||
172 | * Clears the xml after adding the protocol, removing repeated namespaces |
||
173 | * @param string $string |
||
174 | * @return string |
||
175 | */ |
||
176 | 1 | public static function clearProtocoledXML($string) |
|
189 | |||
190 | /** |
||
191 | * Remove some alien chars from txt |
||
192 | * @param string $txt |
||
193 | * @return string |
||
194 | */ |
||
195 | 1 | public static function removeSomeAlienCharsfromTxt($txt) |
|
205 | |||
206 | /** |
||
207 | * Creates a string ramdomically with the specified length |
||
208 | * @param int $length |
||
209 | * @return string |
||
210 | */ |
||
211 | 1 | public static function randomString($length) |
|
222 | } |
||
223 |