Conditions | 6 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
35 | 4 | public static function contains( $type, $text ) { |
|
36 | |||
37 | 4 | if ( $type === ONOI_TESA_CHAR_EXAMINER_HIRAGANA_KATAKANA ) { |
|
38 | 1 | return preg_match('/[\x{3040}-\x{309F}]/u', $text ) > 0 || preg_match('/[\x{30A0}-\x{30FF}]/u', $text ) > 0; // isHiragana || isKatakana |
|
39 | } |
||
40 | |||
41 | 3 | if ( $type === ONOI_TESA_CHAR_EXAMINER_HANGUL ) { |
|
42 | 1 | return preg_match('/[\x{3130}-\x{318F}]/u', $text ) > 0 || preg_match('/[\x{AC00}-\x{D7AF}]/u', $text ) > 0; |
|
43 | } |
||
44 | |||
45 | // @see https://en.wikipedia.org/wiki/CJK_Unified_Ideographs |
||
46 | // Chinese, Japanese and Korean (CJK) scripts share common characters |
||
47 | // known as CJK characters |
||
48 | |||
49 | 2 | if ( $type === ONOI_TESA_CHAR_EXAMINER_CJK_UNIFIED ) { |
|
50 | 1 | return preg_match('/[\x{4e00}-\x{9fa5}]/u', $text ) > 0; |
|
51 | } |
||
52 | |||
53 | 1 | return false; |
|
54 | } |
||
55 | |||
57 |