JpnForPhp\Analyzer\Analyzer::inspect PHP Method

inspect() public static method

Inspects a given string and returns useful details about it.
See also: length()
See also: countKanji()
See also: countHiragana()
See also: countKatakana()
public static inspect ( string $str ) : array
$str string The string to be inspected.
return array An associative array containing the following items: - "length" : string length. - "kanji" : number of kanji within this string. - "hiragana" : number of hiragana within this string. - "katakana" : number of katakana within this string.
    public static function inspect($str)
    {
        $result = array('length' => 0, 'kanji' => 0, 'hiragana' => 0, 'katakana' => 0);
        $result['length'] = self::length($str);
        $result['kanji'] = self::countKanji($str);
        $result['hiragana'] = self::countHiragana($str);
        $result['katakana'] = self::countKatakana($str);
        return $result;
    }

Usage Example

Example #1
0
 public function testInspectMixedCharacters()
 {
     $result = Analyzer::inspect($this->mixCharacters);
     $this->assertSame(array('length' => 19, 'kanji' => 4, 'hiragana' => 5, 'katakana' => 3), $result);
 }