/**
  * Execute the job.
  *
  * @return void
  */
 public function handle(FeedService $parser, ImageDownloadService $downloader)
 {
     $feed = $parser->loadDetailsFromRss($this->podcast->feed);
     $this->podcast->name = $feed['title'];
     $this->podcast->url = $feed['link'];
     $this->podcast->description = $feed['summary'];
     $image_path = $downloader->saveImage($feed['image'], md5($this->podcast->feed), 600, 600);
     if ($image_path != null) {
         $this->podcast->coverimage = $image_path;
     }
     if ($this->podcast->name == null) {
         $this->podcast->error = 17;
         // podcast could not be parsed error
     }
     $this->podcast->save();
 }
 public function testFeed(FeedService $parser)
 {
     $json = file_get_contents('https://itunes.apple.com/search?media=podcast&term=life&limit=50');
     $podcasts = json_decode($json);
     $result = '';
     foreach ($podcasts->results as $podcast) {
         $url = $podcast->feedUrl;
         $feed = $parser->loadDetailsFromRss($url);
         $result .= '<table>';
         $result .= '<tr><td><img src="' . $feed['image'] . '" width=200 height=200></td>';
         $result .= '<td><h2>' . $feed['title'] . '</h2>';
         $result .= '<p>' . $url . '</p><p>' . $feed['link'] . '</p><p>' . $feed['summary'] . '</p>';
         $result .= '</td></tr>';
         $result .= '</table>';
     }
     return $result;
 }