Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 function test_OneMinuteSpeakingTime()
 {
     $text = 'aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa';
     $a = new TextAnalyzer($text);
     $this->assertEquals(60, $a->speaking_time());
 }