39 lines
1 KiB
PHP
39 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Parsers;
|
|
|
|
use App\Contracts\HomepageParserInterface;
|
|
|
|
class BelgaHomepageParserAdapter implements HomepageParserInterface
|
|
{
|
|
/**
|
|
* Belga is English-only for now (#124). The unused $language argument keeps
|
|
* the constructor compatible with HomepageParserFactory, which passes one
|
|
* positionally to every homepage parser.
|
|
*
|
|
* @phpstan-ignore constructor.unusedParameter
|
|
*/
|
|
public function __construct(string $language = 'en') {}
|
|
|
|
public function canParse(string $url): bool
|
|
{
|
|
return str_contains($url, 'belganewsagency.eu') || str_contains($url, 'capi.belga.press');
|
|
}
|
|
|
|
public function extractArticleUrls(string $html): array
|
|
{
|
|
return BelgaHomepageParser::extractArticleUrls($html);
|
|
}
|
|
|
|
public function getHomepageUrl(): string
|
|
{
|
|
$url = config('feed.providers.belga.languages.en.url');
|
|
|
|
return is_string($url) ? $url : '';
|
|
}
|
|
|
|
public function getSourceName(): string
|
|
{
|
|
return 'Belga News Agency';
|
|
}
|
|
}
|