getHomepageUrl()); $urls = $parser->extractArticleUrls($html); $articles = collect($urls) ->map(fn (string $url) => self::saveArticle($url)); $allArticles = $allArticles->merge($articles); } return $allArticles->filter(); } catch (Exception $e) { logger()->error("Failed to get new articles", ['error' => $e->getMessage()]); return new Collection([]); } } public static function fetchArticleData(Article $article): array { try { $html = HttpFetcher::fetchHtml($article->url); $parser = ArticleParserFactory::getParser($article->url); return $parser->extractData($html); } catch (Exception $e) { logger()->error('Exception while fetching article data', [ 'url' => $article->url, 'error' => $e->getMessage() ]); return []; } } private static function saveArticle(string $url): Article { return Article::firstOrCreate(['url' => $url]); } }