Exemplo n.º 1
0
 /**
  * @param  string $url
  * @return array
  **/
 public function parse($url)
 {
     $data = simplexml_load_file($url);
     if ($data === false) {
         throw new \Exception('データを読み込めません');
     }
     $list = array();
     foreach ($data->entry as $entry) {
         $news = new News();
         $news->setTitle($entry->title);
         $news->setUrl($entry->url);
         $news->setTargetDate($entry->date);
         $list[] = $news;
     }
     return $list;
 }
 /**
  * @test
  * @group builder-get-news-url
  * @group builder
  */
 public function URLの取得()
 {
     $url = 'https://google.com';
     $this->news->setUrl($url);
     $this->assertEquals($url, $this->news->getUrl());
 }