|
4 | 4 |
|
5 | 5 | class StringScript
|
6 | 6 | {
|
7 |
| - CONST REGEX_COMMON = '/\p{Common}/u'; |
8 |
| - CONST REGEX_ARABIC = '/\p{Arabic}/u'; |
9 |
| - CONST REGEX_ARMENIAN = '/\p{Armenian}/u'; |
10 |
| - CONST REGEX_BENGALI = '/\p{Bengali}/u'; |
11 |
| - CONST REGEX_BOPOMOFO = '/\p{Bopomofo}/u'; |
12 |
| - CONST REGEX_BRAILLE = '/\p{Braille}/u'; |
13 |
| - CONST REGEX_BUHID = '/\p{Buhid}/u'; |
14 |
| - CONST REGEX_CANADIAN_ABORIGINAL = '/\p{Canadian_Aboriginal}/u'; |
15 |
| - CONST REGEX_CHEROKEE = '/\p{Cherokee}/u'; |
16 |
| - CONST REGEX_CYRILLIC = '/\p{Cyrillic}/u'; |
17 |
| - CONST REGEX_DEVANAGARI = '/\p{Devanagari}/u'; |
18 |
| - CONST REGEX_ETHIOPIC = '/\p{Ethiopic}/u'; |
19 |
| - CONST REGEX_GEORGIAN = '/\p{Georgian}/u'; |
20 |
| - CONST REGEX_GREEK = '/\p{Greek}/u'; |
21 |
| - CONST REGEX_GUJARATI = '/\p{Gujarati}/u'; |
22 |
| - CONST REGEX_GURMUKHI = '/\p{Gurmukhi}/u'; |
23 |
| - CONST REGEX_HAN = '/\p{Han}/u'; |
24 |
| - CONST REGEX_HANGUL = '/\p{Hangul}/u'; |
25 |
| - CONST REGEX_HANUNOO = '/\p{Hanunoo}/u'; |
26 |
| - CONST REGEX_HEBREW = '/\p{Hebrew}/u'; |
27 |
| - CONST REGEX_HIRAGANA = '/\p{Hiragana}/u'; |
28 |
| - CONST REGEX_INHERITED = '/\p{Inherited}/u'; |
29 |
| - CONST REGEX_KANNADA = '/\p{Kannada}/u'; |
30 |
| - CONST REGEX_KATAKANA = '/\p{Katakana}/u'; |
31 |
| - CONST REGEX_KHMER = '/\p{Khmer}/u'; |
32 |
| - CONST REGEX_LAO = '/\p{Lao}/u'; |
33 |
| - CONST REGEX_LATIN = '/\p{Latin}/u'; |
34 |
| - CONST REGEX_LIMBU = '/\p{Limbu}/u'; |
35 |
| - CONST REGEX_MALAYALAM = '/\p{Malayalam}/u'; |
36 |
| - CONST REGEX_MONGOLIAN = '/\p{Mongolian}/u'; |
37 |
| - CONST REGEX_MYANMAR = '/\p{Myanmar}/u'; |
38 |
| - CONST REGEX_OGHAM = '/\p{Ogham}/u'; |
39 |
| - CONST REGEX_ORIYA = '/\p{Oriya}/u'; |
40 |
| - CONST REGEX_RUNIC = '/\p{Runic}/u'; |
41 |
| - CONST REGEX_SINHALA = '/\p{Sinhala}/u'; |
42 |
| - CONST REGEX_SYRIAC = '/\p{Syriac}/u'; |
43 |
| - CONST REGEX_TAGALOG = '/\p{Tagalog}/u'; |
44 |
| - CONST REGEX_TAGBANWA = '/\p{Tagbanwa}/u'; |
45 |
| - CONST REGEX_TAILE = '/\p{TaiLe}/u'; |
46 |
| - CONST REGEX_TAMIL = '/\p{Tamil}/u'; |
47 |
| - CONST REGEX_TELUGU = '/\p{Telugu}/u'; |
48 |
| - CONST REGEX_THAANA = '/\p{Thaana}/u'; |
49 |
| - CONST REGEX_THAI = '/\p{Thai}/u'; |
50 |
| - CONST REGEX_TIBETAN = '/\p{Tibetan}/u'; |
51 |
| - CONST REGEX_YI = '/\p{Yi}/u'; |
52 |
| - |
53 |
| - public static function isCommon($string) { return preg_match(self::REGEX_COMMON, $string) > 0; } |
54 |
| - public static function isArabic($string) { return preg_match(self::REGEX_ARABIC, $string) > 0; } |
55 |
| - public static function isArmenian($string) { return preg_match(self::REGEX_ARMENIAN, $string) > 0; } |
56 |
| - public static function isBengali($string) { return preg_match(self::REGEX_BENGALI, $string) > 0; } |
57 |
| - public static function isBopomofo($string) { return preg_match(self::REGEX_BOPOMOFO, $string) > 0; } |
58 |
| - public static function isBraille($string) { return preg_match(self::REGEX_BRAILLE, $string) > 0; } |
59 |
| - public static function isBuhid($string) { return preg_match(self::REGEX_BUHID, $string) > 0; } |
60 |
| - public static function isCanadian_Aboriginal($string) { return preg_match(self::REGEX_CANADIAN_ABORIGINAL, $string) > 0; } |
61 |
| - public static function isCherokee($string) { return preg_match(self::REGEX_CHEROKEE, $string) > 0; } |
62 |
| - public static function isCyrillic($string) { return preg_match(self::REGEX_CYRILLIC, $string) > 0; } |
63 |
| - public static function isDevanagari($string) { return preg_match(self::REGEX_DEVANAGARI, $string) > 0; } |
64 |
| - public static function isEthiopic($string) { return preg_match(self::REGEX_ETHIOPIC, $string) > 0; } |
65 |
| - public static function isGeorgian($string) { return preg_match(self::REGEX_GEORGIAN, $string) > 0; } |
66 |
| - public static function isGreek($string) { return preg_match(self::REGEX_GREEK, $string) > 0; } |
67 |
| - public static function isGujarati($string) { return preg_match(self::REGEX_GUJARATI, $string) > 0; } |
68 |
| - public static function isGurmukhi($string) { return preg_match(self::REGEX_GURMUKHI, $string) > 0; } |
69 |
| - public static function isHan($string) { return preg_match(self::REGEX_HAN, $string) > 0; } |
70 |
| - public static function isHangul($string) { return preg_match(self::REGEX_HANGUL, $string) > 0; } |
71 |
| - public static function isHanunoo($string) { return preg_match(self::REGEX_HANUNOO, $string) > 0; } |
72 |
| - public static function isHebrew($string) { return preg_match(self::REGEX_HEBREW, $string) > 0; } |
73 |
| - public static function isHiragana($string) { return preg_match(self::REGEX_HIRAGANA, $string) > 0; } |
74 |
| - public static function isInherited($string) { return preg_match(self::REGEX_INHERITED, $string) > 0; } |
75 |
| - public static function isKannada($string) { return preg_match(self::REGEX_KANNADA, $string) > 0; } |
76 |
| - public static function isKatakana($string) { return preg_match(self::REGEX_KATAKANA, $string) > 0; } |
77 |
| - public static function isKhmer($string) { return preg_match(self::REGEX_KHMER, $string) > 0; } |
78 |
| - public static function isLao($string) { return preg_match(self::REGEX_LAO, $string) > 0; } |
79 |
| - public static function isLatin($string) { return preg_match(self::REGEX_LATIN, $string) > 0; } |
80 |
| - public static function isLimbu($string) { return preg_match(self::REGEX_LIMBU, $string) > 0; } |
81 |
| - public static function isMalayalam($string) { return preg_match(self::REGEX_MALAYALAM, $string) > 0; } |
82 |
| - public static function isMongolian($string) { return preg_match(self::REGEX_MONGOLIAN, $string) > 0; } |
83 |
| - public static function isMyanmar($string) { return preg_match(self::REGEX_MYANMAR, $string) > 0; } |
84 |
| - public static function isOgham($string) { return preg_match(self::REGEX_OGHAM, $string) > 0; } |
85 |
| - public static function isOriya($string) { return preg_match(self::REGEX_ORIYA, $string) > 0; } |
86 |
| - public static function isRunic($string) { return preg_match(self::REGEX_RUNIC, $string) > 0; } |
87 |
| - public static function isSinhala($string) { return preg_match(self::REGEX_SINHALA, $string) > 0; } |
88 |
| - public static function isSyriac($string) { return preg_match(self::REGEX_SYRIAC, $string) > 0; } |
89 |
| - public static function isTagalog($string) { return preg_match(self::REGEX_TAGALOG, $string) > 0; } |
90 |
| - public static function isTagbanwa($string) { return preg_match(self::REGEX_TAGBANWA, $string) > 0; } |
91 |
| - public static function isTaiLe($string) { return preg_match(self::REGEX_TAILE, $string) > 0; } |
92 |
| - public static function isTamil($string) { return preg_match(self::REGEX_TAMIL, $string) > 0; } |
93 |
| - public static function isTelugu($string) { return preg_match(self::REGEX_TELUGU, $string) > 0; } |
94 |
| - public static function isThaana($string) { return preg_match(self::REGEX_THAANA, $string) > 0; } |
95 |
| - public static function isThai($string) { return preg_match(self::REGEX_THAI, $string) > 0; } |
96 |
| - public static function isTibetan($string) { return preg_match(self::REGEX_TIBETAN, $string) > 0; } |
97 |
| - public static function isYi($string) { return preg_match(self::REGEX_YI, $string) > 0; } |
98 |
| - |
99 |
| - /* -------------------------------------------------------- |
100 |
| - * Proxies for the common person |
101 |
| - * ----------------------------------------------------- */ |
102 |
| - public static function isChinese($string) { return self::isHan($string); } |
103 |
| - public static function isJapanese($string) { return self::isHiragana($string) || self::isKatakana($string); } |
| 7 | + const REGEX_COMMON = '/\p{Common}/u'; |
| 8 | + const REGEX_ARABIC = '/\p{Arabic}/u'; |
| 9 | + const REGEX_ARMENIAN = '/\p{Armenian}/u'; |
| 10 | + const REGEX_BENGALI = '/\p{Bengali}/u'; |
| 11 | + const REGEX_BOPOMOFO = '/\p{Bopomofo}/u'; |
| 12 | + const REGEX_BRAILLE = '/\p{Braille}/u'; |
| 13 | + const REGEX_BUHID = '/\p{Buhid}/u'; |
| 14 | + const REGEX_CANADIAN_ABORIGINAL = '/\p{Canadian_Aboriginal}/u'; |
| 15 | + const REGEX_CHEROKEE = '/\p{Cherokee}/u'; |
| 16 | + const REGEX_CYRILLIC = '/\p{Cyrillic}/u'; |
| 17 | + const REGEX_DEVANAGARI = '/\p{Devanagari}/u'; |
| 18 | + const REGEX_ETHIOPIC = '/\p{Ethiopic}/u'; |
| 19 | + const REGEX_GEORGIAN = '/\p{Georgian}/u'; |
| 20 | + const REGEX_GREEK = '/\p{Greek}/u'; |
| 21 | + const REGEX_GUJARATI = '/\p{Gujarati}/u'; |
| 22 | + const REGEX_GURMUKHI = '/\p{Gurmukhi}/u'; |
| 23 | + const REGEX_HAN = '/\p{Han}/u'; |
| 24 | + const REGEX_HANGUL = '/\p{Hangul}/u'; |
| 25 | + const REGEX_HANUNOO = '/\p{Hanunoo}/u'; |
| 26 | + const REGEX_HEBREW = '/\p{Hebrew}/u'; |
| 27 | + const REGEX_HIRAGANA = '/\p{Hiragana}/u'; |
| 28 | + const REGEX_INHERITED = '/\p{Inherited}/u'; |
| 29 | + const REGEX_KANNADA = '/\p{Kannada}/u'; |
| 30 | + const REGEX_KATAKANA = '/\p{Katakana}/u'; |
| 31 | + const REGEX_KHMER = '/\p{Khmer}/u'; |
| 32 | + const REGEX_LAO = '/\p{Lao}/u'; |
| 33 | + const REGEX_LATIN = '/\p{Latin}/u'; |
| 34 | + const REGEX_LIMBU = '/\p{Limbu}/u'; |
| 35 | + const REGEX_MALAYALAM = '/\p{Malayalam}/u'; |
| 36 | + const REGEX_MONGOLIAN = '/\p{Mongolian}/u'; |
| 37 | + const REGEX_MYANMAR = '/\p{Myanmar}/u'; |
| 38 | + const REGEX_OGHAM = '/\p{Ogham}/u'; |
| 39 | + const REGEX_ORIYA = '/\p{Oriya}/u'; |
| 40 | + const REGEX_RUNIC = '/\p{Runic}/u'; |
| 41 | + const REGEX_SINHALA = '/\p{Sinhala}/u'; |
| 42 | + const REGEX_SYRIAC = '/\p{Syriac}/u'; |
| 43 | + const REGEX_TAGALOG = '/\p{Tagalog}/u'; |
| 44 | + const REGEX_TAGBANWA = '/\p{Tagbanwa}/u'; |
| 45 | + const REGEX_TAILE = '/\p{TaiLe}/u'; |
| 46 | + const REGEX_TAMIL = '/\p{Tamil}/u'; |
| 47 | + const REGEX_TELUGU = '/\p{Telugu}/u'; |
| 48 | + const REGEX_THAANA = '/\p{Thaana}/u'; |
| 49 | + const REGEX_THAI = '/\p{Thai}/u'; |
| 50 | + const REGEX_TIBETAN = '/\p{Tibetan}/u'; |
| 51 | + const REGEX_YI = '/\p{Yi}/u'; |
| 52 | + |
| 53 | + public static function isCommon($string) |
| 54 | + { |
| 55 | + return preg_match(self::REGEX_COMMON, $string) > 0; |
| 56 | + } |
| 57 | + |
| 58 | + public static function isArabic($string) |
| 59 | + { |
| 60 | + return preg_match(self::REGEX_ARABIC, $string) > 0; |
| 61 | + } |
| 62 | + |
| 63 | + public static function isArmenian($string) |
| 64 | + { |
| 65 | + return preg_match(self::REGEX_ARMENIAN, $string) > 0; |
| 66 | + } |
| 67 | + |
| 68 | + public static function isBengali($string) |
| 69 | + { |
| 70 | + return preg_match(self::REGEX_BENGALI, $string) > 0; |
| 71 | + } |
| 72 | + |
| 73 | + public static function isBopomofo($string) |
| 74 | + { |
| 75 | + return preg_match(self::REGEX_BOPOMOFO, $string) > 0; |
| 76 | + } |
| 77 | + |
| 78 | + public static function isBraille($string) |
| 79 | + { |
| 80 | + return preg_match(self::REGEX_BRAILLE, $string) > 0; |
| 81 | + } |
| 82 | + |
| 83 | + public static function isBuhid($string) |
| 84 | + { |
| 85 | + return preg_match(self::REGEX_BUHID, $string) > 0; |
| 86 | + } |
| 87 | + |
| 88 | + public static function isCanadian_Aboriginal($string) |
| 89 | + { |
| 90 | + return preg_match(self::REGEX_CANADIAN_ABORIGINAL, $string) > 0; |
| 91 | + } |
| 92 | + |
| 93 | + public static function isCherokee($string) |
| 94 | + { |
| 95 | + return preg_match(self::REGEX_CHEROKEE, $string) > 0; |
| 96 | + } |
| 97 | + |
| 98 | + public static function isCyrillic($string) |
| 99 | + { |
| 100 | + return preg_match(self::REGEX_CYRILLIC, $string) > 0; |
| 101 | + } |
| 102 | + |
| 103 | + public static function isDevanagari($string) |
| 104 | + { |
| 105 | + return preg_match(self::REGEX_DEVANAGARI, $string) > 0; |
| 106 | + } |
| 107 | + |
| 108 | + public static function isEthiopic($string) |
| 109 | + { |
| 110 | + return preg_match(self::REGEX_ETHIOPIC, $string) > 0; |
| 111 | + } |
| 112 | + |
| 113 | + public static function isGeorgian($string) |
| 114 | + { |
| 115 | + return preg_match(self::REGEX_GEORGIAN, $string) > 0; |
| 116 | + } |
| 117 | + |
| 118 | + public static function isGreek($string) |
| 119 | + { |
| 120 | + return preg_match(self::REGEX_GREEK, $string) > 0; |
| 121 | + } |
| 122 | + |
| 123 | + public static function isGujarati($string) |
| 124 | + { |
| 125 | + return preg_match(self::REGEX_GUJARATI, $string) > 0; |
| 126 | + } |
| 127 | + |
| 128 | + public static function isGurmukhi($string) |
| 129 | + { |
| 130 | + return preg_match(self::REGEX_GURMUKHI, $string) > 0; |
| 131 | + } |
| 132 | + |
| 133 | + public static function isHan($string) |
| 134 | + { |
| 135 | + return preg_match(self::REGEX_HAN, $string) > 0; |
| 136 | + } |
| 137 | + |
| 138 | + public static function isHangul($string) |
| 139 | + { |
| 140 | + return preg_match(self::REGEX_HANGUL, $string) > 0; |
| 141 | + } |
| 142 | + |
| 143 | + public static function isHanunoo($string) |
| 144 | + { |
| 145 | + return preg_match(self::REGEX_HANUNOO, $string) > 0; |
| 146 | + } |
| 147 | + |
| 148 | + public static function isHebrew($string) |
| 149 | + { |
| 150 | + return preg_match(self::REGEX_HEBREW, $string) > 0; |
| 151 | + } |
| 152 | + |
| 153 | + public static function isHiragana($string) |
| 154 | + { |
| 155 | + return preg_match(self::REGEX_HIRAGANA, $string) > 0; |
| 156 | + } |
| 157 | + |
| 158 | + public static function isInherited($string) |
| 159 | + { |
| 160 | + return preg_match(self::REGEX_INHERITED, $string) > 0; |
| 161 | + } |
| 162 | + |
| 163 | + public static function isKannada($string) |
| 164 | + { |
| 165 | + return preg_match(self::REGEX_KANNADA, $string) > 0; |
| 166 | + } |
| 167 | + |
| 168 | + public static function isKatakana($string) |
| 169 | + { |
| 170 | + return preg_match(self::REGEX_KATAKANA, $string) > 0; |
| 171 | + } |
| 172 | + |
| 173 | + public static function isKhmer($string) |
| 174 | + { |
| 175 | + return preg_match(self::REGEX_KHMER, $string) > 0; |
| 176 | + } |
| 177 | + |
| 178 | + public static function isLao($string) |
| 179 | + { |
| 180 | + return preg_match(self::REGEX_LAO, $string) > 0; |
| 181 | + } |
| 182 | + |
| 183 | + public static function isLatin($string) |
| 184 | + { |
| 185 | + return preg_match(self::REGEX_LATIN, $string) > 0; |
| 186 | + } |
| 187 | + |
| 188 | + public static function isLimbu($string) |
| 189 | + { |
| 190 | + return preg_match(self::REGEX_LIMBU, $string) > 0; |
| 191 | + } |
| 192 | + |
| 193 | + public static function isMalayalam($string) |
| 194 | + { |
| 195 | + return preg_match(self::REGEX_MALAYALAM, $string) > 0; |
| 196 | + } |
| 197 | + |
| 198 | + public static function isMongolian($string) |
| 199 | + { |
| 200 | + return preg_match(self::REGEX_MONGOLIAN, $string) > 0; |
| 201 | + } |
| 202 | + |
| 203 | + public static function isMyanmar($string) |
| 204 | + { |
| 205 | + return preg_match(self::REGEX_MYANMAR, $string) > 0; |
| 206 | + } |
| 207 | + |
| 208 | + public static function isOgham($string) |
| 209 | + { |
| 210 | + return preg_match(self::REGEX_OGHAM, $string) > 0; |
| 211 | + } |
| 212 | + |
| 213 | + public static function isOriya($string) |
| 214 | + { |
| 215 | + return preg_match(self::REGEX_ORIYA, $string) > 0; |
| 216 | + } |
| 217 | + |
| 218 | + public static function isRunic($string) |
| 219 | + { |
| 220 | + return preg_match(self::REGEX_RUNIC, $string) > 0; |
| 221 | + } |
| 222 | + |
| 223 | + public static function isSinhala($string) |
| 224 | + { |
| 225 | + return preg_match(self::REGEX_SINHALA, $string) > 0; |
| 226 | + } |
| 227 | + |
| 228 | + public static function isSyriac($string) |
| 229 | + { |
| 230 | + return preg_match(self::REGEX_SYRIAC, $string) > 0; |
| 231 | + } |
| 232 | + |
| 233 | + public static function isTagalog($string) |
| 234 | + { |
| 235 | + return preg_match(self::REGEX_TAGALOG, $string) > 0; |
| 236 | + } |
| 237 | + |
| 238 | + public static function isTagbanwa($string) |
| 239 | + { |
| 240 | + return preg_match(self::REGEX_TAGBANWA, $string) > 0; |
| 241 | + } |
| 242 | + |
| 243 | + public static function isTaiLe($string) |
| 244 | + { |
| 245 | + return preg_match(self::REGEX_TAILE, $string) > 0; |
| 246 | + } |
| 247 | + |
| 248 | + public static function isTamil($string) |
| 249 | + { |
| 250 | + return preg_match(self::REGEX_TAMIL, $string) > 0; |
| 251 | + } |
| 252 | + |
| 253 | + public static function isTelugu($string) |
| 254 | + { |
| 255 | + return preg_match(self::REGEX_TELUGU, $string) > 0; |
| 256 | + } |
| 257 | + |
| 258 | + public static function isThaana($string) |
| 259 | + { |
| 260 | + return preg_match(self::REGEX_THAANA, $string) > 0; |
| 261 | + } |
| 262 | + |
| 263 | + public static function isThai($string) |
| 264 | + { |
| 265 | + return preg_match(self::REGEX_THAI, $string) > 0; |
| 266 | + } |
| 267 | + |
| 268 | + public static function isTibetan($string) |
| 269 | + { |
| 270 | + return preg_match(self::REGEX_TIBETAN, $string) > 0; |
| 271 | + } |
| 272 | + |
| 273 | + public static function isYi($string) |
| 274 | + { |
| 275 | + return preg_match(self::REGEX_YI, $string) > 0; |
| 276 | + } |
| 277 | + |
| 278 | + /* -------------------------------------------------------- |
| 279 | + * Proxies for the common person |
| 280 | + * ----------------------------------------------------- */ |
| 281 | + public static function isChinese($string) |
| 282 | + { |
| 283 | + return self::isHan($string); |
| 284 | + } |
| 285 | + |
| 286 | + public static function isJapanese($string) |
| 287 | + { |
| 288 | + return self::isHiragana($string) || self::isKatakana($string); |
| 289 | + } |
104 | 290 | }
|
0 commit comments