2025-06-29 21:39:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Services\Parsers;
|
|
|
|
|
|
|
|
|
|
use App\Contracts\HomepageParserInterface;
|
|
|
|
|
|
|
|
|
|
class BelgaHomepageParserAdapter implements HomepageParserInterface
|
|
|
|
|
{
|
2026-03-07 18:02:27 +01:00
|
|
|
public function __construct(
|
2026-03-08 14:18:28 +01:00
|
|
|
private readonly string $language = 'en',
|
2026-03-07 18:02:27 +01:00
|
|
|
) {}
|
|
|
|
|
|
2026-03-08 14:18:28 +01:00
|
|
|
public function getLanguage(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->language;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-29 21:39:28 +02:00
|
|
|
public function canParse(string $url): bool
|
|
|
|
|
{
|
|
|
|
|
return str_contains($url, 'belganewsagency.eu');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function extractArticleUrls(string $html): array
|
|
|
|
|
{
|
|
|
|
|
return BelgaHomepageParser::extractArticleUrls($html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getHomepageUrl(): string
|
|
|
|
|
{
|
|
|
|
|
return 'https://www.belganewsagency.eu/';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getSourceName(): string
|
|
|
|
|
{
|
|
|
|
|
return 'Belga News Agency';
|
|
|
|
|
}
|
2026-03-08 14:18:28 +01:00
|
|
|
}
|