public function renderLatestBlogPosts()
 {
     $cacheId = $this->blogOptions->getCacheKey();
     $posts = $this->cache->contains($cacheId) ? $this->cache->fetch($cacheId) : [];
     $elements = [];
     foreach ($posts as $post) {
         $elements[] = sprintf('<li><a target="_blank" href="%s">%s</a></li>', $post['link'], $post['title']);
     }
     return sprintf('<ul class="fh5co-links blog-posts">%s</ul>', implode('', $elements));
 }
 /**
  * @param FeedInterface $feed
  * @return array
  */
 protected function processFeed(FeedInterface $feed) : array
 {
     $data = [];
     $count = 0;
     /** @var FeedInterface $entry */
     foreach ($feed as $entry) {
         if ($count >= $this->blogOptions->getElementsToDisplay()) {
             break;
         }
         $data[] = ['title' => $entry->getTitle(), 'link' => $entry->getLink()];
         $count += 1;
     }
     return $data;
 }
 /**
  * @test
  */
 public function cacheIsDeletedWhenFeedHasChyanged()
 {
     $this->templatesCache->save('foo', 'bar');
     $this->feedCache->save($this->options->getCacheKey(), [['link' => 'something else']]);
     $this->service->refreshFeed();
     $this->assertFalse($this->templatesCache->contains('foo'));
 }