[ 'name' => 'Limit', 'type' => 'number', 'required' => false, 'title' => 'Number of articles to return', 'exampleValue' => self::LIMIT_DEFAULT, 'defaultValue' => self::LIMIT_DEFAULT ] ] ]; public function collectData() { $limit = $this->getInput('limit') ?: self::LIMIT_DEFAULT; $limit = min(self::LIMIT_MAX, max(self::LIMIT_MIN, $limit)); $url = sprintf(self::API_URL, $limit); $json = json_decode(getContents($url, ['apikey: ' . self::API_KEY])); if (property_exists($json, 'error')) { returnServerError($json->message); } $list = $json->items; foreach ($list as $article) { if (property_exists($article->thumbnail, 'caption')) { $caption = $article->thumbnail->caption; } else { $caption = $article->thumbnail->image->title; } $item = []; $item['uri'] = sprintf(self::ARTICLE_URL, $article->slug, $article->id); $item['title'] = $article->title; $item['timestamp'] = $article->updatedAt; $item['author'] = self::ARTICLE_AUTHOR; $item['enclosures'] = [$article->thumbnail->image->url]; $item['uid'] = $article->id; $item['content'] = sprintf( '

%s

%s', $article->metaDescription ?? $article->title, $item['uri'], $item['enclosures'][0], $caption, $caption ); $this->items[] = $item; } } }