hasJapaneseLetters() public static method

Determines whether the given string contains Japanese letters (kanji, hiragana or katakana).
See also: hasKanji()
See also: hasHiragana()
See also: hasKatakana()
public static hasJapaneseLetters ( string $str ) : boolean
$str string The string to inspect.
return boolean TRUE if it contains either kanji, hiragana or katakana, otherwise FALSE.
Esempio n. 1
0
 public function testHasNotJapaneseLetters()
 {
     $result = Analyzer::hasJapaneseLetters('This is a 「test」。');
     $this->assertEquals(FALSE, $result);
 }
Esempio n. 2
0
 /**
  * Gets a verb entry from the database using either Kanji, Hiragana or Romaji
  *
  * @param $verb
  * @return array
  */
 public static function getVerb($verb)
 {
     if (!Analyzer::hasJapaneseLetters($verb)) {
         $hepburn = new Kana();
         $verb = $hepburn->transliterate($verb);
     }
     $sql = 'SELECT * FROM verbs WHERE kanji = :kanji OR kana = :kana';
     $uri = 'sqlite:' . __DIR__ . DIRECTORY_SEPARATOR . 'verbs.db';
     $connection = new PDO($uri);
     $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
     $statement = $connection->prepare($sql);
     $statement->execute(array(':kanji' => $verb, ':kana' => $verb));
     $results = $statement->fetchAll(PDO::FETCH_ASSOC);
     return $results;
 }