slug; $blogPost = json_decode(getContents(self::_API_URL_BLOG_POST . $slug)); if (property_exists($blogPost, 'previous')) { $this->addBlogPost($blogPost->previous); } $this->addBlogPost($blogPost); if (property_exists($blogPost, 'next')) { $this->addBlogPost($blogPost->next); } } if ($length % 3 == 1) { $slug = $blogPosts[count($blogPosts) - 1]->slug; $blogPost = json_decode(getContents(self::_API_URL_BLOG_POST . $slug)); $this->addBlogPost($blogPost); } } private function addBlogPost($blogPost) { $item = []; $splittedTimestamp = explode('-', $blogPost->publishedAt); $year = $splittedTimestamp[0]; $month = $splittedTimestamp[1]; $slug = $blogPost->slug; $uri = 'https://hytale.com/news/' . $year . '/' . $month . '/' . $slug; $item['uri'] = $uri; $item['title'] = $blogPost->title; $item['author'] = $blogPost->author; $item['timestamp'] = $blogPost->publishedAt; $item['content'] = $blogPost->body; $blogCoverS3Key = $blogPost->coverImage->s3Key; $coverImagesURLs = [ self::_BLOG_COVER_URL . $blogCoverS3Key, self::_BLOG_THUMB_URL . $blogCoverS3Key, ]; if (preg_match_all(self::_IMG_REGEX, $blogPost->body, $bodyImagesURLs)) { $item['enclosures'] = array_merge($coverImagesURLs, $bodyImagesURLs[0]); } else { $item['enclosures'] = $coverImagesURLs; } $this->items[] = $item; } }