1 | <?php |
||
20 | class StringHelper |
||
21 | { |
||
22 | |||
23 | const PREPOSITIONS = [ |
||
24 | 'on', 'in', 'at', 'since', 'for', 'ago', 'before', 'to', 'past', 'till', 'until', 'by', 'under', 'below', 'over', |
||
25 | 'above', 'across', 'through', 'into', 'towards', 'onto', 'from', 'of', 'off', 'about', 'via' |
||
26 | ]; |
||
27 | |||
28 | const ARTICLES = [ |
||
29 | 'a', 'an', 'the' |
||
30 | ]; |
||
31 | |||
32 | const ADVERBS = [ |
||
33 | 'yet', 'so', 'just', 'only' |
||
34 | ]; |
||
35 | |||
36 | const CONJUNCTIONS = [ |
||
37 | 'nor', 'so', 'and', 'or' |
||
38 | ]; |
||
39 | |||
40 | const ADJECTIVES = [ |
||
41 | 'down', 'up' |
||
42 | ]; |
||
43 | |||
44 | const ISO_ENCODINGS = [ |
||
45 | 'ISO-8859-1', |
||
46 | 'ISO-8859-2', |
||
47 | 'ISO-8859-3', |
||
48 | 'ISO-8859-4', |
||
49 | 'ISO-8859-5', |
||
50 | 'ISO-8859-6', |
||
51 | 'ISO-8859-7', |
||
52 | 'ISO-8859-8', |
||
53 | 'ISO-8859-9', |
||
54 | 'ISO-8859-10', |
||
55 | 'ISO-8859-11', |
||
56 | 'ISO-8859-13', |
||
57 | 'ISO-8859-14', |
||
58 | 'ISO-8859-15', |
||
59 | 'ISO-8859-16' |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * opening quote sign |
||
64 | */ |
||
65 | const OPENING_QUOTE = "“"; |
||
66 | |||
67 | /** |
||
68 | * closing quote sign |
||
69 | */ |
||
70 | const CLOSING_QUOTE = "”"; |
||
71 | |||
72 | /** |
||
73 | * @param $text |
||
74 | * @return string |
||
75 | */ |
||
76 | public static function capitalizeAll($text) |
||
86 | |||
87 | /** |
||
88 | * @param $titleString |
||
89 | * @return string |
||
90 | */ |
||
91 | public static function capitalizeForTitle($titleString) |
||
113 | |||
114 | /** |
||
115 | * @param $word |
||
116 | * @return bool |
||
117 | */ |
||
118 | public static function keepLowerCase($word) |
||
127 | |||
128 | /** |
||
129 | * @param $string |
||
130 | * @param string $encoding |
||
131 | * @return string |
||
132 | */ |
||
133 | public static function mb_ucfirst($string, $encoding = 'UTF-8') |
||
142 | |||
143 | /** |
||
144 | * @param $string |
||
145 | * @param $initializeSign |
||
146 | * @return string |
||
147 | */ |
||
148 | public static function initializeBySpaceOrHyphen($string, $initializeSign) |
||
165 | |||
166 | /** |
||
167 | * @param $string |
||
168 | * @return mixed|string |
||
169 | */ |
||
170 | public static function camelCase2Hyphen($string) |
||
176 | |||
177 | /** |
||
178 | * @param $string |
||
179 | * @return bool |
||
180 | */ |
||
181 | public static function checkLowerCaseString($string) |
||
185 | |||
186 | /** |
||
187 | * @param $string |
||
188 | * @return bool |
||
189 | */ |
||
190 | public static function checkUpperCaseString($string) |
||
194 | |||
195 | /** |
||
196 | * @param $string |
||
197 | * @return mixed |
||
198 | */ |
||
199 | public static function clearApostrophes($string) |
||
203 | |||
204 | /** |
||
205 | * replaces outer quotes of $text by given inner quotes |
||
206 | * |
||
207 | * @param $text |
||
208 | * @param $outerOpenQuote |
||
209 | * @param $outerCloseQuote |
||
210 | * @param $innerOpenQuote |
||
211 | * @param $innerCloseQuote |
||
212 | * @return string |
||
213 | */ |
||
214 | public static function replaceOuterQuotes($text, $outerOpenQuote, $outerCloseQuote, $innerOpenQuote, $innerCloseQuote) |
||
221 | |||
222 | /** |
||
223 | * @param $string |
||
224 | * @return bool |
||
225 | */ |
||
226 | public static function isLatinString($string) |
||
231 | |||
232 | /** |
||
233 | * @param $string |
||
234 | * @return bool |
||
235 | */ |
||
236 | public static function isCyrillicString($string) |
||
240 | |||
241 | } |
This check looks for accesses to local static members using the fully qualified name instead of
self::
.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBC
could just as well be replaced byself::TRIPLEDES_CBC
. Referencing local members withself::
assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.