/** * @param $text string Text to analyze * * @return string The content, with the statistics appended */ public function analyze_text($text) { $output = ''; if (is_single() && is_main_query()) { $this->text_analyzer->set_text($text); $words = $this->text_analyzer->count_words(); $characters = $this->text_analyzer->count_characters(); $reading_time = $this->text_analyzer->reading_time(); $speaking_time = $this->text_analyzer->speaking_time(); $post_id = get_the_ID(); ob_start(); include plugin_dir_path(__FILE__) . 'views/stats.php'; $output = ob_get_clean(); } return $output; }
function test_MultiWord() { $a = new TextAnalyzer('aaa bbb ccc'); $this->assertEquals(3, $a->count_words()); $this->assertEquals(11, $a->count_characters()); $this->assertEquals(0.9782608695652174, $a->reading_time()); }