public function testEndsWith()
 {
     $this->assertTrue(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'd'));
     $this->assertTrue(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'nd'));
     $this->assertTrue(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'end'));
     $this->assertTrue(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'fend'));
     $this->assertTrue(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'ifend'));
     $this->assertFalse(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'n'));
     $this->assertFalse(\pmill\Extract\Helper\StringHelper::endsWith($this->testString, 'fen'));
 }
Exemple #2
0
 /**
  * @return ExtractedStats|null
  */
 public function extractStats()
 {
     try {
         $statsCrawler = $this->getStatsPageCrawler();
         $stats = new ExtractedStats();
         $stats->setLikes(str_replace(',', '', StringHelper::filterText($statsCrawler, "#like_totals")));
         $views = StringHelper::filterText($statsCrawler, "#play_totals");
         if (StringHelper::endsWith($views, 'K')) {
             $views = rtrim($views, "K") * 1000;
         }
         $stats->setViews($views);
         return $stats;
     } catch (PageNotFoundException $e) {
         return null;
     } catch (ServerErrorException $e) {
         return null;
     }
 }